Merge branch 'dd/time-reentrancy'

Avoid gmtime() and localtime() and prefer their reentrant
counterparts.

* dd/time-reentrancy:
  mingw: use {gm,local}time_s as backend for {gm,local}time_r
  archive-zip.c: switch to reentrant localtime_r
  date.c: switch to reentrant {gm,local}time_r
This commit is contained in:
Junio C Hamano
2019-12-16 13:08:31 -08:00
3 changed files with 21 additions and 19 deletions

View File

@ -1018,16 +1018,16 @@ int pipe(int filedes[2])
struct tm *gmtime_r(const time_t *timep, struct tm *result)
{
/* gmtime() in MSVCRT.DLL is thread-safe, but not reentrant */
memcpy(result, gmtime(timep), sizeof(struct tm));
return result;
if (gmtime_s(result, timep) == 0)
return result;
return NULL;
}
struct tm *localtime_r(const time_t *timep, struct tm *result)
{
/* localtime() in MSVCRT.DLL is thread-safe, but not reentrant */
memcpy(result, localtime(timep), sizeof(struct tm));
return result;
if (localtime_s(result, timep) == 0)
return result;
return NULL;
}
char *mingw_getcwd(char *pointer, int len)