]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
cleanup _localtime64_s (#1820)
authorRosen Penev <rosenp@gmail.com>
Tue, 20 Dec 2022 12:48:42 +0000 (04:48 -0800)
committerGitHub <noreply@github.com>
Tue, 20 Dec 2022 12:48:42 +0000 (13:48 +0100)
Signed-off-by: Rosen Penev <rosenp@gmail.com>
17 files changed:
cpio/cpio.c
cpio/test/test_option_t.c
libarchive/archive_getdate.c
libarchive/archive_read_open_file.c
libarchive/archive_read_support_format_iso9660.c
libarchive/archive_read_support_format_rar.c
libarchive/archive_read_support_format_warc.c
libarchive/archive_read_support_format_xar.c
libarchive/archive_write_set_format_iso9660.c
libarchive/archive_write_set_format_warc.c
libarchive/archive_write_set_format_xar.c
libarchive/archive_write_set_format_zip.c
libarchive/test/test_write_format_zip_compression_store.c
libarchive/test/test_write_format_zip_file.c
libarchive/test/test_write_format_zip_file_zip64.c
tar/util.c
test_utils/test_main.c

index 68a6301a8789274b3e1def3addd0a5b67a455914..4acab9d2a118854def046819557e04d8eb0c229d 100644 (file)
@@ -1205,15 +1205,15 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
        else
                fmt = cpio->day_first ? "%e %b %H:%M" : "%b %e %H:%M";
 #endif
-#if defined(HAVE_LOCALTIME_R)
-       ltime = localtime_r(&mtime, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
+#if defined(HAVE__LOCALTIME64_S)
        tmptime = mtime;
        terr = _localtime64_s(&tmbuf, &tmptime);
        if (terr)
                ltime = NULL;
        else
                ltime = &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
+       ltime = localtime_r(&mtime, &tmbuf);
 #else
        ltime = localtime(&mtime);
 #endif
index 0f2dda27cc20a114bdf59c952c8d6036f4b33f10..3d27b72dd52be7fc60bda52d5747a2aba9c4d70a 100644 (file)
@@ -95,15 +95,15 @@ DEFINE_TEST(test_option_t)
 #ifdef HAVE_LOCALE_H
        setlocale(LC_ALL, "");
 #endif
-#if defined(HAVE_LOCALTIME_R)
-        tmptr = localtime_r(&mtime, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
+#if defined(HAVE__LOCALTIME64_S)
         tmptime = mtime;
         terr = _localtime64_s(&tmbuf, &tmptime);
         if (terr)
                 tmptr = NULL;
         else
                 tmptr = &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
+        tmptr = localtime_r(&mtime, &tmbuf);
 #else
         tmptr = localtime(&mtime);
 #endif
index 39e224cb901022b3e69dcb23018170ba3ffbff61..47dcecc146a0e4f8b50728ca98ee3ad2ccff38f5 100644 (file)
@@ -701,10 +701,6 @@ Convert(time_t Month, time_t Day, time_t Year,
 #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 (Year < 69)
                Year += 2000;
@@ -731,15 +727,10 @@ Convert(time_t Month, time_t Day, time_t Year,
        Julian *= DAY;
        Julian += Timezone;
        Julian += Hours * HOUR + Minutes * MINUTE + Seconds;
-#if defined(HAVE_LOCALTIME_R)
+#if defined(HAVE__LOCALTIME64_S)
+       ltime = _localtime64_s(&tmbuf, &Julian) ? NULL : &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
        ltime = localtime_r(&Julian, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
-       tmptime = Julian;
-       terr = _localtime64_s(&tmbuf, &tmptime);
-       if (terr)
-               ltime = NULL;
-       else
-               ltime = &tmbuf;
 #else
        ltime = localtime(&Julian);
 #endif
@@ -759,32 +750,17 @@ DSTcorrect(time_t Start, time_t Future)
        struct tm       tmbuf;
 #endif
 #if defined(HAVE__LOCALTIME64_S)
-       errno_t         terr;
-       __time64_t      tmptime;
-#endif
-
-#if defined(HAVE_LOCALTIME_R)
+       ltime = _localtime64_s(&tmbuf, &Start) ? NULL : &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
        ltime = localtime_r(&Start, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
-       tmptime = Start;
-       terr = _localtime64_s(&tmbuf, &tmptime);
-       if (terr)
-               ltime = NULL;
-       else
-               ltime = &tmbuf;
 #else
        ltime = localtime(&Start);
 #endif
        StartDay = (ltime->tm_hour + 1) % 24;
-#if defined(HAVE_LOCALTIME_R)
+#if defined(HAVE__LOCALTIME64_S)
+       ltime = _localtime64_s(&tmbuf, &Future) ? NULL : &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
        ltime = localtime_r(&Future, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
-       tmptime = Future;
-       terr = _localtime64_s(&tmbuf, &tmptime);
-       if (terr)
-               ltime = NULL;
-       else
-               ltime = &tmbuf;
 #else
        ltime = localtime(&Future);
 #endif
@@ -802,21 +778,12 @@ RelativeDate(time_t Start, time_t zone, int dstmode,
 #if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S)
        struct tm       tmbuf;
 #endif
-#if defined(HAVE__GMTIME64_S)
-       errno_t         terr;
-       __time64_t      tmptime;
-#endif
 
        t = Start - zone;
-#if defined(HAVE_GMTIME_R)
+#if defined(HAVE__GMTIME64_S)
+       tm = _gmtime64_s(&tmbuf, &t) ? NULL : &tmbuf;
+#elif defined(HAVE_GMTIME_R)
        tm = gmtime_r(&t, &tmbuf);
-#elif defined(HAVE__GMTIME64_S)
-       tmptime = t;
-       terr = _gmtime64_s(&tmbuf, &tmptime);
-       if (terr)
-               tm = NULL;
-       else
-               tm = &tmbuf;
 #else
        tm = gmtime(&t);
 #endif
@@ -838,22 +805,13 @@ RelativeMonth(time_t Start, time_t Timezone, time_t RelMonth)
 #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 (RelMonth == 0)
                return 0;
-#if defined(HAVE_LOCALTIME_R)
+#if defined(HAVE__LOCALTIME64_S)
+       tm = _localtime64_s(&tmbuf, &Start) ? NULL : &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
        tm = localtime_r(&Start, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
-       tmptime = Start;
-       terr = _localtime64_s(&tmbuf, &tmptime);
-       if (terr)
-               tm = NULL;
-       else
-               tm = &tmbuf;
 #else
        tm = localtime(&Start);
 #endif
@@ -993,10 +951,6 @@ __archive_get_date(time_t now, const char *p)
        time_t          Start;
        time_t          tod;
        long            tzone;
-#if defined(HAVE__LOCALTIME64_S) || defined(HAVE__GMTIME64_S)
-       errno_t         terr;
-       __time64_t      tmptime;
-#endif
 
        /* Clear out the parsed token array. */
        memset(tokens, 0, sizeof(tokens));
@@ -1005,15 +959,10 @@ __archive_get_date(time_t now, const char *p)
        gds = &_gds;
 
        /* Look up the current time. */
-#if defined(HAVE_LOCALTIME_R)
+#if defined(HAVE__LOCALTIME64_S)
+       tm = _localtime64_s(&local, &now) ? NULL : &local;
+#elif defined(HAVE_LOCALTIME_R)
        tm = localtime_r(&now, &local);
-#elif defined(HAVE__LOCALTIME64_S)
-       tmptime = now;
-       terr = _localtime64_s(&local, &tmptime);
-       if (terr)
-               tm = NULL;
-       else
-               tm = &local;
 #else
        memset(&local, 0, sizeof(local));
        tm = localtime(&now);
@@ -1026,15 +975,10 @@ __archive_get_date(time_t now, const char *p)
 
        /* Look up UTC if we can and use that to determine the current
         * timezone offset. */
-#if defined(HAVE_GMTIME_R)
+#if defined(HAVE__GMTIME64_S)
+       gmt_ptr = _gmtime64_s(&gmt, &now) ? NULL : &gmt;
+#elif defined(HAVE_GMTIME_R)
        gmt_ptr = gmtime_r(&now, &gmt);
-#elif defined(HAVE__GMTIME64_S)
-       tmptime = now;
-       terr = _gmtime64_s(&gmt, &tmptime);
-       if (terr)
-               gmt_ptr = NULL;
-       else
-               gmt_ptr = &gmt;
 #else
        memset(&gmt, 0, sizeof(gmt));
        gmt_ptr = gmtime(&now);
@@ -1076,15 +1020,10 @@ __archive_get_date(time_t now, const char *p)
         * time components instead of the local timezone. */
        if (gds->HaveZone && gmt_ptr != NULL) {
                now -= gds->Timezone;
-#if defined(HAVE_GMTIME_R)
+#if defined(HAVE__GMTIME64_S)
+               gmt_ptr = _gmtime64_s(&gmt, &now) ? NULL : &gmt;
+#elif defined(HAVE_GMTIME_R)
                gmt_ptr = gmtime_r(&now, &gmt);
-#elif defined(HAVE__GMTIME64_S)
-               tmptime = now;
-               terr = _gmtime64_s(&gmt, &tmptime);
-               if (terr)
-                       gmt_ptr = NULL;
-               else
-                       gmt_ptr = &gmt;
 #else
                gmt_ptr = gmtime(&now);
 #endif
index 101dae6cd9e304e322cc099e7e0f689167591a5c..03719e8bff0ce7d0ad7660fa7212df180dd62d5d 100644 (file)
@@ -154,10 +154,10 @@ file_skip(struct archive *a, void *client_data, int64_t request)
 #ifdef __ANDROID__
         /* fileno() isn't safe on all platforms ... see above. */
        if (lseek(fileno(mine->f), skip, SEEK_CUR) < 0)
-#elif HAVE_FSEEKO
-       if (fseeko(mine->f, skip, SEEK_CUR) != 0)
 #elif HAVE__FSEEKI64
        if (_fseeki64(mine->f, skip, SEEK_CUR) != 0)
+#elif HAVE_FSEEKO
+       if (fseeko(mine->f, skip, SEEK_CUR) != 0)
 #else
        if (fseek(mine->f, skip, SEEK_CUR) != 0)
 #endif
index 33bf330cbfe4001e274f9d70df706165bf5b9705..596c14ac282b90676e88252996533396822317c5 100644 (file)
@@ -1901,7 +1901,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
         * NUMBER of RRIP "PX" extension.
         * Note: Old mkisofs did not record that FILE SERIAL NUMBER
         * in ISO images.
-        * Note2: xorriso set 0 to the location of a symlink file. 
+        * Note2: xorriso set 0 to the location of a symlink file.
         */
        if (file->size == 0 && location >= 0) {
                /* If file->size is zero, its location points wrong place,
@@ -1955,7 +1955,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
                         * made by makefs is not zero and its location is
                         * the same as those of next regular file. That is
                         * the same as hard like file and it causes unexpected
-                        * error. 
+                        * error.
                         */
                        if (file->size > 0 &&
                            (file->mode & AE_IFMT) == AE_IFLNK) {
@@ -2747,7 +2747,7 @@ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660,
                         * If directory entries all which are descendant of
                         * rr_moved are still remaining, expose their.
                         */
-                       if (iso9660->re_files.first != NULL && 
+                       if (iso9660->re_files.first != NULL &&
                            iso9660->rr_moved != NULL &&
                            iso9660->rr_moved->rr_moved_has_re_only)
                                /* Expose "rr_moved" entry. */
@@ -3180,11 +3180,11 @@ isodate17(const unsigned char *v)
 static time_t
 time_from_tm(struct tm *t)
 {
-#if HAVE_TIMEGM
+#if HAVE__MKGMTIME64
+        return (_mkgmtime64(t));
+#elif HAVE_TIMEGM
         /* Use platform timegm() if available. */
         return (timegm(t));
-#elif HAVE__MKGMTIME64
-        return (_mkgmtime64(t));
 #else
         /* Else use direct calculation using POSIX assumptions. */
         /* First, fix up tm_yday based on the year/month/day. */
index 793e8e9852148f33e16c8531ee830a9f7cea33e2..b7adb2ba844f3f05d59511388f6420caf5ee781b 100644 (file)
@@ -1833,10 +1833,6 @@ read_exttime(const char *p, struct rar *rar, const char *endp)
 #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 (p + 2 > endp)
     return (-1);
@@ -1868,15 +1864,10 @@ read_exttime(const char *p, struct rar *rar, const char *endp)
         rem = (((unsigned)(unsigned char)*p) << 16) | (rem >> 8);
         p++;
       }
-#if defined(HAVE_LOCALTIME_R)
+#if defined(HAVE__LOCALTIME64_S)
+      tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
       tm = localtime_r(&t, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
-      tmptime = t;
-      terr = _localtime64_s(&tmbuf, &tmptime);
-      if (terr)
-        tm = NULL;
-      else
-        tm = &tmbuf;
 #else
       tm = localtime(&t);
 #endif
index 27329962d6d105a4681e74e2ea17d892937a67ac..b34c7fe3f79a7ec821dbe8932d50c76d3ca24cb3 100644 (file)
@@ -530,11 +530,11 @@ strtoi_lim(const char *str, const char **ep, int llim, int ulim)
 static time_t
 time_from_tm(struct tm *t)
 {
-#if HAVE_TIMEGM
+#if HAVE__MKGMTIME64
+        return (_mkgmtime64(t));
+#elif HAVE_TIMEGM
         /* Use platform timegm() if available. */
         return (timegm(t));
-#elif HAVE__MKGMTIME64
-        return (_mkgmtime64(t));
 #else
         /* Else use direct calculation using POSIX assumptions. */
         /* First, fix up tm_yday based on the year/month/day. */
index ec5b06edacd59be4ce292eec5088d1a113a06abd..f9e2de125048db42b2f61a13e9c0e4b16ced2168 100644 (file)
@@ -1127,7 +1127,7 @@ atohex(unsigned char *b, size_t bsize, const char *p, size_t psize)
                        x |= p[1] - '0';
                else
                        return (-1);
-               
+
                *b++ = x;
                bsize--;
                p += 2;
@@ -1139,11 +1139,11 @@ atohex(unsigned char *b, size_t bsize, const char *p, size_t psize)
 static time_t
 time_from_tm(struct tm *t)
 {
-#if HAVE_TIMEGM
+#if HAVE__MKGMTIME64
+        return (_mkgmtime64(t));
+#elif HAVE_TIMEGM
         /* Use platform timegm() if available. */
         return (timegm(t));
-#elif HAVE__MKGMTIME64
-        return (_mkgmtime64(t));
 #else
         /* Else use direct calculation using POSIX assumptions. */
         /* First, fix up tm_yday based on the year/month/day. */
index 58b7216a8071bb5c392f3995e6d9064297b2b165..22e36f62b38d31a3453b5664132d997d0a0f8d78 100644 (file)
@@ -652,7 +652,7 @@ struct iso_option {
 #define VOLUME_IDENTIFIER_SIZE         32
 
        /*
-        * Usage  : !zisofs [DEFAULT] 
+        * Usage  : !zisofs [DEFAULT]
         *        :    Disable to generate RRIP 'ZF' extension.
         *        : zisofs
         *        :    Make files zisofs file and generate RRIP 'ZF'
@@ -689,7 +689,7 @@ struct iso9660 {
        uint64_t                 bytes_remaining;
        int                      need_multi_extent;
 
-       /* Temporary string buffer for Joliet extension. */ 
+       /* Temporary string buffer for Joliet extension. */
        struct archive_string    utf16be;
        struct archive_string    mbs;
 
@@ -2521,12 +2521,12 @@ get_gmoffset(struct tm *tm)
 static void
 get_tmfromtime(struct tm *tm, time_t *t)
 {
-#if HAVE_LOCALTIME_R
-       tzset();
-       localtime_r(t, tm);
-#elif HAVE__LOCALTIME64_S
+#if HAVE__LOCALTIME64_S
        __time64_t tmp_t = (__time64_t) *t; //time_t may be shorter than 64 bits
        _localtime64_s(tm, &tmp_t);
+#elif HAVE_LOCALTIME_R
+       tzset();
+       localtime_r(t, tm);
 #else
        memcpy(tm, localtime(t), sizeof(*tm));
 #endif
index 46b05734121c348c06d6b9177d8cfccfcb5d5421..6f0a45d88c50969dafa84e71e1a1888b10351181 100644 (file)
@@ -331,28 +331,19 @@ xstrftime(struct archive_string *as, const char *fmt, time_t t)
        struct tm *rt;
 #if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S)
        struct tm timeHere;
-#endif
-#if defined(HAVE__GMTIME64_S)
-       errno_t terr;
-       __time64_t tmptime;
 #endif
        char strtime[100];
        size_t len;
 
-#ifdef HAVE_GMTIME_R
-       if ((rt = gmtime_r(&t, &timeHere)) == NULL)
-               return;
-#elif defined(HAVE__GMTIME64_S)
-       tmptime = t;
-       terr = _gmtime64_s(&timeHere, &tmptime);
-       if (terr)
-               rt = NULL;
-       else
-               rt = &timeHere;
+#if defined(HAVE__GMTIME64_S)
+       rt = _gmtime64_s(&timeHere, &t) ? NULL : &timeHere;
+#elif defined(HAVE_GMTIME_R)
+       rt = gmtime_r(&t, &timeHere);
 #else
-       if ((rt = gmtime(&t)) == NULL)
-               return;
+       rt = gmtime(&t);
 #endif
+       if (!rt)
+               return;
        /* leave the hard yacker to our role model strftime() */
        len = strftime(strtime, sizeof(strtime)-1, fmt, rt);
        archive_strncat(as, strtime, len);
index d885f5c256d37f56e92d448023a0d07fb78804e3..9529ee9167bd6d6bbabb42eeab777f7a245d6fc3 100644 (file)
@@ -906,15 +906,11 @@ xmlwrite_time(struct archive_write *a, xmlTextWriterPtr writer,
 {
        char timestr[100];
        struct tm tm;
-#if defined(HAVE__GMTIME64_S)
-       __time64_t tmptime;
-#endif
 
-#if defined(HAVE_GMTIME_R)
+#if defined(HAVE__GMTIME64_S)
+       _gmtime64_s(&tm, &t);
+#elif defined(HAVE_GMTIME_R)
        gmtime_r(&t, &tm);
-#elif defined(HAVE__GMTIME64_S)
-       tmptime = t;
-       _gmtime64_s(&tm, &tmptime);
 #else
        memcpy(&tm, gmtime(&t), sizeof(tm));
 #endif
index 8c14a7027ebacc902e41686bde417544e976f7a8..86fa4858d323cd414f5b619d09ef548022f90218 100644 (file)
@@ -1385,22 +1385,11 @@ dos_time(const time_t unix_time)
 #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
 
-       /* This will not preserve time when creating/extracting the archive
-        * on two systems with different time zones. */
-#if defined(HAVE_LOCALTIME_R)
+#if defined(HAVE__LOCALTIME64_S)
+       t = _localtime64_s(&tmbuf, &unix_time) ? NULL : &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
        t = localtime_r(&unix_time, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
-       tmptime = unix_time;
-       terr = _localtime64_s(&tmbuf, &tmptime);
-       if (terr)
-               t = NULL;
-       else
-               t = &tmbuf;
 #else
        t = localtime(&unix_time);
 #endif
index ed0908787579502b760407f2bc1f14982cc1a4ae..aae50afb22640291cd2d2f27ccff240c97f7c7b3 100644 (file)
@@ -140,15 +140,15 @@ static void verify_uncompressed_contents(const char *buff, size_t used)
         * q walks over the local headers, the data and the data descriptors. */
        const char *p, *q, *local_header, *extra_start;
 
-#if defined(HAVE_LOCALTIME_R)
-       tm = localtime_r(&now, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
+#if defined(HAVE__LOCALTIME64_S)
        tmptime = now;
        terr = _localtime64_s(&tmbuf, &tmptime);
        if (terr)
                tm = NULL;
        else
                tm = &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
+       tm = localtime_r(&now, &tmbuf);
 #else
        tm = localtime(&now);
 #endif
index 7796a48cdac30f4ba0765b4a3aacb0b6f65602bd..ff3c13dcef73baf201d366d328fb61bdd348bc88 100644 (file)
@@ -98,15 +98,15 @@ DEFINE_TEST(test_write_format_zip_file)
        zip_compression = 0;
 #endif
 
-#if defined(HAVE_LOCALTIME_R)
-       tm = localtime_r(&t, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
+#if defined(HAVE__LOCALTIME64_S)
        tmptime = t;
        terr = _localtime64_s(&tmbuf, &tmptime);
        if (terr)
                tm = NULL;
        else
                tm = &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
+       tm = localtime_r(&t, &tmbuf);
 #else
        tm = localtime(&t);
 #endif
index c4161bc3a89b9c9126f04fd5c3b630fd4a5e460f..8e3b12e166f6823eecea0bcdaa7bcbbf3507e41a 100644 (file)
@@ -99,15 +99,15 @@ DEFINE_TEST(test_write_format_zip_file_zip64)
        zip_compression = 0;
 #endif
 
-#if defined(HAVE_LOCALTIME_R)
-       tm = localtime_r(&t, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
+#if defined(HAVE__LOCALTIME64_S)
        tmptime = t;
        terr = _localtime64_s(&tmbuf, &tmptime);
        if (terr)
                tm = NULL;
        else
                tm = &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
+       tm = localtime_r(&t, &tmbuf);
 #else
        tm = localtime(&t);
 #endif
index 5a4ab0b3a0fad2f44ccbecd54ee3a8b028b49123..6ce26c133a1fc0163c37da74d96f5d7ae0ca7697 100644 (file)
@@ -746,15 +746,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";
-#if defined(HAVE_LOCALTIME_R)
-       ltime = localtime_r(&tim, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
+#if defined(HAVE__LOCALTIME64_S)
        tmptime = tim;
        terr = _localtime64_s(&tmbuf, &tmptime);
        if (terr)
                ltime = NULL;
        else
                ltime = &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
+       ltime = localtime_r(&tim, &tmbuf);
 #else
        ltime = localtime(&tim);
 #endif
index 74250ad748c2d7fc046d525b3980ae752900534f..a733c9e56a5d2f029bad6876b0926e06d38191ea 100644 (file)
@@ -2345,7 +2345,7 @@ static void assert_version_id(char **qq, size_t *ss)
                q += 3;
                s -= 3;
        }
-       
+
        /* Skip a single trailing a,b,c, or d. */
        if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
                ++q;
@@ -2391,7 +2391,7 @@ void assertVersion(const char *prog, const char *base)
 
        /* Version message should start with name of program, then space. */
        assert(s > prog_len + 1);
-       
+
        failure("Version must start with '%s': ``%s''", base, p);
        if (!assertEqualMem(q, base, prog_len)) {
                free(p);
@@ -2729,7 +2729,7 @@ canNodump(void)
 /* Get extended attribute value from a path */
 void *
 getXattr(const char *path, const char *name, size_t *sizep)
-{ 
+{
        void *value = NULL;
 #if ARCHIVE_XATTR_SUPPORT
        ssize_t size;
@@ -3863,7 +3863,7 @@ main(int argc, char **argv)
        int test_set[sizeof(tests) / sizeof(tests[0])];
        int i = 0, j = 0, tests_run = 0, tests_failed = 0, option;
        int testprogdir_len;
-#ifdef PROGRAM 
+#ifdef PROGRAM
        int tmp2_len;
 #endif
        time_t now;
@@ -4109,15 +4109,15 @@ main(int argc, char **argv)
         */
        now = time(NULL);
        for (i = 0; ; i++) {
-#if defined(HAVE_LOCALTIME_R)
-               tmptr = localtime_r(&now, &tmbuf);
-#elif defined(HAVE__LOCALTIME64_S)
+#if defined(HAVE__LOCALTIME64_S)
                tmptime = now;
                terr = _localtime64_s(&tmbuf, &tmptime);
                if (terr)
                        tmptr = NULL;
                else
                        tmptr = &tmbuf;
+#elif defined(HAVE_LOCALTIME_R)
+               tmptr = localtime_r(&now, &tmbuf);
 #else
                tmptr = localtime(&now);
 #endif