1
0
forked from aniani/vim

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().
This commit is contained in:
Bram Moolenaar
2019-05-10 21:28:38 +02:00
parent 4ca41534b7
commit 63d2555c9c
10 changed files with 83 additions and 35 deletions

View File

@@ -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);