summaryrefslogtreecommitdiff
path: root/tar
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2020-01-13 14:23:00 +0100
committerMartin Matuska <martin@matuska.org>2020-01-13 16:16:13 +0100
commita11f15860ae39ecdc8173243a211cdafc8ac893c (patch)
tree0c49b30b9e9f1bbda11a24033b1f7161562846d2 /tar
parentbdea136855bf7d7cb42cc90c6fbe0c1b4719859d (diff)
downloadlibarchive-a11f15860ae39ecdc8173243a211cdafc8ac893c.tar.gz
Windows: use _localtime64_s and _gmtime64_s where appropriate
Diffstat (limited to 'tar')
-rw-r--r--tar/util.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tar/util.c b/tar/util.c
index 85c5446a..8ebec64c 100644
--- a/tar/util.c
+++ b/tar/util.c
@@ -667,9 +667,13 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
time_t tim;
static time_t now;
struct tm *ltime;
-#ifdef HAVE_LOCALTIME_R
+#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
@@ -741,8 +745,15 @@ 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";
-#ifdef HAVE_LOCALTIME_R
+#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