From: Michihiro NAKAJIMA Date: Fri, 26 Feb 2010 09:27:27 +0000 (-0500) Subject: Unbreak build on msys; further portability. X-Git-Tag: v3.0.0a~1175 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=411d7de8a7c997ff679b676c78661e97a6411044;p=thirdparty%2Flibarchive.git Unbreak build on msys; further portability. SVN-Revision: 1997 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 16921adae..3e3eba068 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -374,6 +374,7 @@ CHECK_SYMBOL_EXISTS(_CrtSetReportMode "crtdbg.h" HAVE__CrtSetReportMode) CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS) CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN) CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT) +CHECK_FUNCTION_EXISTS_GLIBC(ctime_r HAVE_CTIME_R) CHECK_FUNCTION_EXISTS_GLIBC(fchdir HAVE_FCHDIR) CHECK_FUNCTION_EXISTS_GLIBC(fchflags HAVE_FCHFLAGS) CHECK_FUNCTION_EXISTS_GLIBC(fchmod HAVE_FCHMOD) @@ -424,7 +425,9 @@ CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB) CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY) CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN) CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB) -CHECK_FUNCTION_EXISTS_GLIBC(_localtime64_s HAVE_LOCALTIME64_S) +CHECK_FUNCTION_EXISTS_GLIBC(_ctime64_s HAVE__CTIME64_S) +CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE) +CHECK_FUNCTION_EXISTS_GLIBC(_localtime64_s HAVE__LOCALTIME64_S) CHECK_FUNCTION_EXISTS_GLIBC(_mkgmtime64 HAVE__MKGMTIME64) CHECK_SYMBOL_EXISTS(wmemcmp "wchar.h" HAVE_WMEMCMP) CHECK_SYMBOL_EXISTS(wmemcpy "wchar.h" HAVE_WMEMCPY) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 73eb9a5e8..0046b8664 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -69,6 +69,9 @@ /* Define to 1 if you have the `CreateHardLinkW' function. */ #cmakedefine HAVE_CREATEHARDLINKW 1 +/* Define to 1 if you have the `ctime_r' function. */ +#cmakedefine HAVE_CTIME_R 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_CTYPE_H 1 @@ -644,6 +647,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ZLIB_H 1 +/* Define to 1 if you have the `_ctime64_s' function. */ +#cmakedefine HAVE__CTIME64_S 1 + +/* Define to 1 if you have the `_get_timezone' function. */ +#cmakedefine HAVE__GET_TIMEZONE 1 + /* Define to 1 if you have the `_localtime64_s' function. */ #cmakedefine HAVE__LOCALTIME64_S 1 diff --git a/configure.ac b/configure.ac index 9c4ff397d..4bdd63ab7 100644 --- a/configure.ac +++ b/configure.ac @@ -397,7 +397,7 @@ AC_FUNC_VPRINTF # To avoid necessity for including windows.h or special forward declaration # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *' AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *]) -AC_CHECK_FUNCS([chflags chown chroot]) +AC_CHECK_FUNCS([chflags chown chroot ctime_r]) AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fork]) AC_CHECK_FUNCS([fstat ftruncate futimens futimes geteuid getpid]) AC_CHECK_FUNCS([lchflags lchmod lchown link localtime_r lstat]) diff --git a/libarchive/archive_write_set_format_iso9660.c b/libarchive/archive_write_set_format_iso9660.c index afd556a97..27312af9b 100644 --- a/libarchive/archive_write_set_format_iso9660.c +++ b/libarchive/archive_write_set_format_iso9660.c @@ -2548,9 +2548,9 @@ get_gmoffset(struct tm *tm) { long offset; -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(HAVE__GET_TIMEZONE) _get_timezone(&offset); -#elif defined(__CYGWIN__) +#elif defined(__CYGWIN__) || defined(__MINGW32__) offset = _timezone; #else offset = timezone; @@ -2562,6 +2562,19 @@ get_gmoffset(struct tm *tm) } #endif +static void +get_tmfromtime(struct tm *tm, time_t *t) +{ +#if HAVE_LOCALTIME_R + tzset(); + localtime_r(t, tm); +#elif HAVE__LOCALTIME64_S + _localtime64_s(tm, t); +#else + memcpy(tm, localtime(t), sizeof(*tm)); +#endif +} + /* * Date and Time Format. * ISO9660 Standard 8.4.26.1 @@ -2571,14 +2584,7 @@ set_date_time(unsigned char *p, time_t t) { struct tm tm; -#if HAVE_LOCALTIME_R - tzset(); - localtime_r(&t, &tm); -#elif HAVE__LOCALTIME64_S - _localtime64_s(&tm, &t) -#else - memcpy(&tm, localtime(&t), sizeof(tm)); -#endif + get_tmfromtime(&tm, &t); set_digit(p, 4, tm.tm_year + 1900); set_digit(p+4, 2, tm.tm_mon + 1); set_digit(p+6, 2, tm.tm_mday); @@ -2601,14 +2607,7 @@ set_time_915(unsigned char *p, time_t t) { struct tm tm; -#if HAVE_LOCALTIME_R - tzset(); - localtime_r(&t, &tm); -#elif HAVE__LOCALTIME64_S - _localtime64_s(&tm, &t) -#else - memcpy(&tm, localtime(&t), sizeof(tm)); -#endif + get_tmfromtime(&tm, &t); set_num_711(p+0, tm.tm_year); set_num_711(p+1, tm.tm_mon+1); set_num_711(p+2, tm.tm_mday); @@ -4039,10 +4038,13 @@ write_information_block(struct archive_write *a) } memset(info.s, 0, info_size); opt = 0; -#if defined(_WIN32) && !defined(__CYGWIN__) - ctime_s(buf, sizeof(buf), &(iso9660->birth_time)); -#else +#if defined(HAVE__CTIME64_S) + _ctime64_s(buf, sizeof(buf), &(iso9660->birth_time)); +#elif defined(HAVE_CTIME_R) ctime_r(&(iso9660->birth_time), buf); +#else + strncpy(buf, ctime(&(iso9660->birth_time)), sizeof(buf)-1); + buf[sizeof(buf)-1] = '\0'; #endif archive_string_sprintf(&info, "INFO %s%s", buf, archive_version_string()); @@ -4541,8 +4543,8 @@ _write_file_descriptors(struct archive_write *a, struct isoent *isoent) if (rs <= 0) { archive_set_error(&a->archive, errno, - "Can't read temporary file(%zd)", - rs); + "Can't read temporary file(%jd)", + (intmax_t)rs); return (ARCHIVE_FATAL); } size -= rs; @@ -4597,7 +4599,8 @@ write_file_descriptors(struct archive_write *a) rs = read(np->file->temp_fd, wb, rsize); if (rs <= 0) { archive_set_error(&a->archive, errno, - "Can't read temporary file(%zd)", rs); + "Can't read temporary file(%jd)", + (intmax_t)rs); return (ARCHIVE_FATAL); } size -= rs; @@ -7300,7 +7303,8 @@ setup_boot_information(struct archive_write *a) rs = read(np->file->temp_fd, iso9660->wbuff, rsize); if (rs <= 0) { archive_set_error(&a->archive, errno, - "Can't read temporary file(%zd)", rs); + "Can't read temporary file(%jd)", + (intmax_t)rs); return (ARCHIVE_FATAL); } for (i = 0; i < rs; i += 4)