From a11f15860ae39ecdc8173243a211cdafc8ac893c Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Mon, 13 Jan 2020 14:23:00 +0100 Subject: Windows: use _localtime64_s and _gmtime64_s where appropriate --- cpio/cpio.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'cpio') diff --git a/cpio/cpio.c b/cpio/cpio.c index f8dd62c5..da5c3986 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -1140,9 +1140,13 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) time_t mtime; 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 if (!now) time(&now); @@ -1190,10 +1194,17 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry) else fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M"; #endif -#ifdef HAVE_LOCALTIME_R +#if defined(HAVE_LOCALTIME_R) ltime = localtime_r(&mtime, &tmbuf); +#elif defined(HAVE__LOCALTIME64_S) + tmptime = mtime; + terr = _localtime64_s(&tmbuf, &tmptime); + if (terr) + ltime = NULL; + else + ltime = &tmbuf; #else - ltime = localtime(&mtime) + ltime = localtime(&mtime); #endif strftime(date, sizeof(date), fmt, ltime); -- cgit v1.2.1