diff options
| author | Martin Matuska <mm@FreeBSD.org> | 2020-02-11 23:48:03 +0000 |
|---|---|---|
| committer | Martin Matuska <mm@FreeBSD.org> | 2020-02-11 23:48:03 +0000 |
| commit | 8185c4ae244f9a52ad987b36e7d6300500054d00 (patch) | |
| tree | 11e2d7cd0caf20998ed1e1146e1c1d7fc747165e /tar/util.c | |
| parent | 98c1f51f769841d99d879099f9075ff60d51ee4a (diff) | |
Diffstat (limited to 'tar/util.c')
| -rw-r--r-- | tar/util.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tar/util.c b/tar/util.c index 662db5baa796..8ebec64c48d9 100644 --- a/tar/util.c +++ b/tar/util.c @@ -666,6 +666,14 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) const char *fmt; time_t tim; static time_t now; + struct tm *ltime; +#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) + struct tm tmbuf; +#endif +#if defined(HAVE__LOCALTIME64_S) + errno_t terr; + __time64_t tmptime; +#endif /* * We avoid collecting the entire list in memory at once by @@ -737,7 +745,19 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) fmt = bsdtar->day_first ? DAY_FMT " %b %Y" : "%b " DAY_FMT " %Y"; else fmt = bsdtar->day_first ? DAY_FMT " %b %H:%M" : "%b " DAY_FMT " %H:%M"; - strftime(tmp, sizeof(tmp), fmt, localtime(&tim)); +#if defined(HAVE_LOCALTIME_R) + ltime = localtime_r(&tim, &tmbuf); +#elif defined(HAVE__LOCALTIME64_S) + tmptime = tim; + terr = _localtime64_s(&tmbuf, &tmptime); + if (terr) + ltime = NULL; + else + ltime = &tmbuf; +#else + ltime = localtime(&tim); +#endif + strftime(tmp, sizeof(tmp), fmt, ltime); fprintf(out, " %s ", tmp); safe_fprintf(out, "%s", archive_entry_pathname(entry)); |
