]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Unbreak build on msys; further portability.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 26 Feb 2010 09:27:27 +0000 (04:27 -0500)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Fri, 26 Feb 2010 09:27:27 +0000 (04:27 -0500)
SVN-Revision: 1997

CMakeLists.txt
build/cmake/config.h.in
configure.ac
libarchive/archive_write_set_format_iso9660.c

index 16921adae9e45def0d6c4987160c4f8bd90a3514..3e3eba068b56648dff54bcb18b189c491b6a9898 100644 (file)
@@ -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)
index 73eb9a5e86fb7021662ef450736fc8acc2a1a6dd..0046b8664091d6d1284a191e34288329504a969a 100644 (file)
@@ -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 <ctype.h> header file. */
 #cmakedefine HAVE_CTYPE_H 1
 
 /* Define to 1 if you have the <zlib.h> 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
 
index 9c4ff397d4b1eb42a39d6f8ecf263cce342964e1..4bdd63ab7e559b841144420b90e8859f3d405f5a 100644 (file)
@@ -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])
index afd556a978d3dda8f1d820755392449df7af1e74..27312af9b6857fa3b68cb727e8c3256c95bb7a4f 100644 (file)
@@ -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)