summaryrefslogtreecommitdiff
path: root/src/undo.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-10 21:28:38 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-10 21:28:38 +0200
commit63d2555c9cefbbeeca3ec87fdd5d241e9488f9dd (patch)
treef96d5dcd14268406b6c78c002f9bb63db7fc9cb9 /src/undo.c
parent4ca41534b726c4116d2e430e877e34146b4d4831 (diff)
downloadvim-git-63d2555c9cefbbeeca3ec87fdd5d241e9488f9dd.tar.gz
patch 8.1.1313: warnings for using localtime() and ctime()v8.1.1313
Problem: Warnings for using localtime() and ctime(). Solution: Use localtime_r() if available. Avoid using ctime().
Diffstat (limited to 'src/undo.c')
-rw-r--r--src/undo.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/undo.c b/src/undo.c
index 1d2614449..2f1924ce1 100644
--- 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);