Mercurial > vim
diff src/undo.c @ 16621:7ad3fc329e08 v8.1.1313
patch 8.1.1313: warnings for using localtime() and ctime()
commit https://github.com/vim/vim/commit/63d2555c9cefbbeeca3ec87fdd5d241e9488f9dd
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 10 21:28:38 2019 +0200
patch 8.1.1313: warnings for using localtime() and ctime()
Problem: Warnings for using localtime() and ctime().
Solution: Use localtime_r() if available. Avoid using ctime().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 10 May 2019 21:30:07 +0200 |
parents | 840fa633ad64 |
children | 58009c45c31c |
line wrap: on
line diff
--- a/src/undo.c +++ b/src/undo.c @@ -3110,11 +3110,19 @@ ex_undolist(exarg_T *eap UNUSED) u_add_time(char_u *buf, size_t buflen, time_t tt) { #ifdef HAVE_STRFTIME +# ifdef HAVE_LOCALTIME_R + struct tm tmval; +# endif struct tm *curtime; if (vim_time() - tt >= 100) { curtime = localtime(&tt); +# ifdef HAVE_LOCALTIME_R + curtime = localtime_r(&tt, &tmval); +# else + curtime = localtime(&tt); +# endif if (vim_time() - tt < (60L * 60L * 12L)) /* within 12 hours */ (void)strftime((char *)buf, buflen, "%H:%M:%S", curtime);