diff options
author | Rosen Penev <rosenp@gmail.com> | 2023-01-09 06:15:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-09 15:15:55 +0100 |
commit | 0348e24bab24cc46642d29e3ceab64df22553298 (patch) | |
tree | e9d44e90d33989a413c9b726aa3b9d302949d142 /libarchive | |
parent | 2e9bcba70685383426ad42c8856c50ce3214ae24 (diff) | |
download | libarchive-0348e24bab24cc46642d29e3ceab64df22553298.tar.gz |
replace time64 functions with normal ones (#1830)
Otherwise there are 32/64-bit pointer conversions going on. In Windows
since MSVC2005, time_t has been 64-bit. MinGW needs a hack to get 64-bit
time_t.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'libarchive')
-rw-r--r-- | libarchive/archive_getdate.c | 42 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_iso9660.c | 4 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_rar.c | 6 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_warc.c | 4 | ||||
-rw-r--r-- | libarchive/archive_read_support_format_xar.c | 4 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_iso9660.c | 12 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_warc.c | 6 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_xar.c | 4 | ||||
-rw-r--r-- | libarchive/archive_write_set_format_zip.c | 6 | ||||
-rw-r--r-- | libarchive/test/test_write_format_zip_compression_store.c | 6 | ||||
-rw-r--r-- | libarchive/test/test_write_format_zip_file.c | 6 | ||||
-rw-r--r-- | libarchive/test/test_write_format_zip_file_zip64.c | 6 |
12 files changed, 51 insertions, 55 deletions
diff --git a/libarchive/archive_getdate.c b/libarchive/archive_getdate.c index 47dcecc1..20ab1b15 100644 --- a/libarchive/archive_getdate.c +++ b/libarchive/archive_getdate.c @@ -698,7 +698,7 @@ Convert(time_t Month, time_t Day, time_t Year, time_t Julian; int i; struct tm *ltime; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif @@ -727,8 +727,8 @@ Convert(time_t Month, time_t Day, time_t Year, Julian *= DAY; Julian += Timezone; Julian += Hours * HOUR + Minutes * MINUTE + Seconds; -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &Julian) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &Julian) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&Julian, &tmbuf); #else @@ -746,19 +746,19 @@ DSTcorrect(time_t Start, time_t Future) time_t StartDay; time_t FutureDay; struct tm *ltime; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &Start) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &Start) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&Start, &tmbuf); #else ltime = localtime(&Start); #endif StartDay = (ltime->tm_hour + 1) % 24; -#if defined(HAVE__LOCALTIME64_S) - ltime = _localtime64_s(&tmbuf, &Future) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + ltime = localtime_s(&tmbuf, &Future) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) ltime = localtime_r(&Future, &tmbuf); #else @@ -775,13 +775,13 @@ RelativeDate(time_t Start, time_t zone, int dstmode, { struct tm *tm; time_t t, now; -#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S) +#if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S) struct tm tmbuf; #endif t = Start - zone; -#if defined(HAVE__GMTIME64_S) - tm = _gmtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_GMTIME_S) + tm = gmtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_GMTIME_R) tm = gmtime_r(&t, &tmbuf); #else @@ -802,14 +802,14 @@ RelativeMonth(time_t Start, time_t Timezone, time_t RelMonth) struct tm *tm; time_t Month; time_t Year; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif if (RelMonth == 0) return 0; -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &Start) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &Start) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&Start, &tmbuf); #else @@ -959,8 +959,8 @@ __archive_get_date(time_t now, const char *p) gds = &_gds; /* Look up the current time. */ -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&local, &now) ? NULL : &local; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&local, &now) ? NULL : &local; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&now, &local); #else @@ -969,14 +969,14 @@ __archive_get_date(time_t now, const char *p) #endif if (tm == NULL) return -1; -#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE__LOCALTIME64_S) +#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) local = *tm; #endif /* Look up UTC if we can and use that to determine the current * timezone offset. */ -#if defined(HAVE__GMTIME64_S) - gmt_ptr = _gmtime64_s(&gmt, &now) ? NULL : &gmt; +#if defined(HAVE_GMTIME_S) + gmt_ptr = gmtime_s(&gmt, &now) ? NULL : &gmt; #elif defined(HAVE_GMTIME_R) gmt_ptr = gmtime_r(&now, &gmt); #else @@ -1020,8 +1020,8 @@ __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__GMTIME64_S) - gmt_ptr = _gmtime64_s(&gmt, &now) ? NULL : &gmt; +#if defined(HAVE_GMTIME_S) + gmt_ptr = gmtime_s(&gmt, &now) ? NULL : &gmt; #elif defined(HAVE_GMTIME_R) gmt_ptr = gmtime_r(&now, &gmt); #else diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c index 596c14ac..f5414be2 100644 --- a/libarchive/archive_read_support_format_iso9660.c +++ b/libarchive/archive_read_support_format_iso9660.c @@ -3180,8 +3180,8 @@ isodate17(const unsigned char *v) static time_t time_from_tm(struct tm *t) { -#if HAVE__MKGMTIME64 - return (_mkgmtime64(t)); +#if HAVE__MKGMTIME + return _mkgmtime(t); #elif HAVE_TIMEGM /* Use platform timegm() if available. */ return (timegm(t)); diff --git a/libarchive/archive_read_support_format_rar.c b/libarchive/archive_read_support_format_rar.c index b7adb2ba..8f239da9 100644 --- a/libarchive/archive_read_support_format_rar.c +++ b/libarchive/archive_read_support_format_rar.c @@ -1830,7 +1830,7 @@ read_exttime(const char *p, struct rar *rar, const char *endp) struct tm *tm; time_t t; long nsec; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif @@ -1864,8 +1864,8 @@ read_exttime(const char *p, struct rar *rar, const char *endp) rem = (((unsigned)(unsigned char)*p) << 16) | (rem >> 8); p++; } -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c index b34c7fe3..61ab29ea 100644 --- a/libarchive/archive_read_support_format_warc.c +++ b/libarchive/archive_read_support_format_warc.c @@ -530,8 +530,8 @@ strtoi_lim(const char *str, const char **ep, int llim, int ulim) static time_t time_from_tm(struct tm *t) { -#if HAVE__MKGMTIME64 - return (_mkgmtime64(t)); +#if HAVE__MKGMTIME + return _mkgmtime(t); #elif HAVE_TIMEGM /* Use platform timegm() if available. */ return (timegm(t)); diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c index f9e2de12..ec9cb198 100644 --- a/libarchive/archive_read_support_format_xar.c +++ b/libarchive/archive_read_support_format_xar.c @@ -1139,8 +1139,8 @@ atohex(unsigned char *b, size_t bsize, const char *p, size_t psize) static time_t time_from_tm(struct tm *t) { -#if HAVE__MKGMTIME64 - return (_mkgmtime64(t)); +#if HAVE__MKGMTIME + return _mkgmtime(t); #elif HAVE_TIMEGM /* Use platform timegm() if available. */ return (timegm(t)); diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index 22e36f62..197b0ee6 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -2521,9 +2521,8 @@ get_gmoffset(struct tm *tm) static void get_tmfromtime(struct tm *tm, time_t *t) { -#if HAVE__LOCALTIME64_S - __time64_t tmp_t = (__time64_t) *t; //time_t may be shorter than 64 bits - _localtime64_s(tm, &tmp_t); +#if HAVE_LOCALTIME_S + localtime_s(tm, t); #elif HAVE_LOCALTIME_R tzset(); localtime_r(t, tm); @@ -4074,11 +4073,8 @@ write_information_block(struct archive_write *a) } memset(info.s, 0, info_size); opt = 0; -#if defined(HAVE__CTIME64_S) - { - __time64_t iso9660_birth_time_tmp = (__time64_t) iso9660->birth_time; //time_t may be shorter than 64 bits - _ctime64_s(buf, sizeof(buf), &(iso9660_birth_time_tmp)); - } +#if defined(HAVE_CTIME_S) + ctime_s(buf, sizeof(buf), &(iso9660->birth_time)); #elif defined(HAVE_CTIME_R) ctime_r(&(iso9660->birth_time), buf); #else diff --git a/libarchive/archive_write_set_format_warc.c b/libarchive/archive_write_set_format_warc.c index 6f0a45d8..0ef003e2 100644 --- a/libarchive/archive_write_set_format_warc.c +++ b/libarchive/archive_write_set_format_warc.c @@ -329,14 +329,14 @@ xstrftime(struct archive_string *as, const char *fmt, time_t t) { /** like strftime(3) but for time_t objects */ struct tm *rt; -#if defined(HAVE_GMTIME_R) || defined(HAVE__GMTIME64_S) +#if defined(HAVE_GMTIME_R) || defined(HAVE_GMTIME_S) struct tm timeHere; #endif char strtime[100]; size_t len; -#if defined(HAVE__GMTIME64_S) - rt = _gmtime64_s(&timeHere, &t) ? NULL : &timeHere; +#if defined(HAVE_GMTIME_S) + rt = gmtime_s(&timeHere, &t) ? NULL : &timeHere; #elif defined(HAVE_GMTIME_R) rt = gmtime_r(&t, &timeHere); #else diff --git a/libarchive/archive_write_set_format_xar.c b/libarchive/archive_write_set_format_xar.c index 9529ee91..7849062c 100644 --- a/libarchive/archive_write_set_format_xar.c +++ b/libarchive/archive_write_set_format_xar.c @@ -907,8 +907,8 @@ xmlwrite_time(struct archive_write *a, xmlTextWriterPtr writer, char timestr[100]; struct tm tm; -#if defined(HAVE__GMTIME64_S) - _gmtime64_s(&tm, &t); +#if defined(HAVE_GMTIME_S) + gmtime_s(&tm, &t); #elif defined(HAVE_GMTIME_R) gmtime_r(&t, &tm); #else diff --git a/libarchive/archive_write_set_format_zip.c b/libarchive/archive_write_set_format_zip.c index 86fa4858..6821049c 100644 --- a/libarchive/archive_write_set_format_zip.c +++ b/libarchive/archive_write_set_format_zip.c @@ -1382,12 +1382,12 @@ dos_time(const time_t unix_time) { struct tm *t; unsigned int dt; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif -#if defined(HAVE__LOCALTIME64_S) - t = _localtime64_s(&tmbuf, &unix_time) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + t = localtime_s(&tmbuf, &unix_time) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) t = localtime_r(&unix_time, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_compression_store.c b/libarchive/test/test_write_format_zip_compression_store.c index 4d086edf..b52d170c 100644 --- a/libarchive/test/test_write_format_zip_compression_store.c +++ b/libarchive/test/test_write_format_zip_compression_store.c @@ -129,15 +129,15 @@ static void verify_uncompressed_contents(const char *buff, size_t used) /* Misc variables */ unsigned long crc; struct tm *tm; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif /* p is the pointer to walk over the central directory, * q walks over the local headers, the data and the data descriptors. */ const char *p, *q, *local_header, *extra_start; -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &now) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &now) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&now, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_file.c b/libarchive/test/test_write_format_zip_file.c index afd0eb6e..4ccc3036 100644 --- a/libarchive/test/test_write_format_zip_file.c +++ b/libarchive/test/test_write_format_zip_file.c @@ -74,7 +74,7 @@ DEFINE_TEST(test_write_format_zip_file) struct archive_entry *ae; time_t t = 1234567890; struct tm *tm; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif size_t used, buffsize = 1000000; @@ -94,8 +94,8 @@ DEFINE_TEST(test_write_format_zip_file) zip_compression = 0; #endif -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else diff --git a/libarchive/test/test_write_format_zip_file_zip64.c b/libarchive/test/test_write_format_zip_file_zip64.c index 8a506226..6a00fe14 100644 --- a/libarchive/test/test_write_format_zip_file_zip64.c +++ b/libarchive/test/test_write_format_zip_file_zip64.c @@ -76,7 +76,7 @@ DEFINE_TEST(test_write_format_zip_file_zip64) struct archive_entry *ae; time_t t = 1234567890; struct tm *tm; -#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S) +#if defined(HAVE_LOCALTIME_R) || defined(HAVE_LOCALTIME_S) struct tm tmbuf; #endif size_t used, buffsize = 1000000; @@ -95,8 +95,8 @@ DEFINE_TEST(test_write_format_zip_file_zip64) zip_compression = 0; #endif -#if defined(HAVE__LOCALTIME64_S) - tm = _localtime64_s(&tmbuf, &t) ? NULL : &tmbuf; +#if defined(HAVE_LOCALTIME_S) + tm = localtime_s(&tmbuf, &t) ? NULL : &tmbuf; #elif defined(HAVE_LOCALTIME_R) tm = localtime_r(&t, &tmbuf); #else |