From 125047fc67c97e3d4d9e12dbff39ed7ddaeb4657 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Mon, 31 Aug 2009 21:35:56 -0400 Subject: [PATCH] Chuck Wilson's fixes for Cygwin and MinGW builds. SVN-Revision: 1412 --- CMakeLists.txt | 1 + Makefile.am | 4 ++-- configure.ac | 2 +- cpio/cpio_platform.h | 10 ++++++---- tar/tree.c | 10 +++++----- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af16dd533..457601667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,6 +367,7 @@ CHECK_FUNCTION_EXISTS_GLIBC(setlocale HAVE_SETLOCALE) CHECK_FUNCTION_EXISTS_GLIBC(strchr HAVE_STRCHR) CHECK_FUNCTION_EXISTS_GLIBC(strdup HAVE_STRDUP) CHECK_FUNCTION_EXISTS_GLIBC(strerror HAVE_STRERROR) +CHECK_FUNCTION_EXISTS_GLIBC(strncpy_s HAVE_STRNCPY_S) CHECK_FUNCTION_EXISTS_GLIBC(strrchr HAVE_STRRCHR) CHECK_FUNCTION_EXISTS_GLIBC(symlink HAVE_SYMLINK) CHECK_FUNCTION_EXISTS_GLIBC(timegm HAVE_TIMEGM) diff --git a/Makefile.am b/Makefile.am index 43e6b968b..6c55da8e6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -456,7 +456,7 @@ tar/test/list.h: Makefile if BUILD_BSDTAR bsdtar_test_programs= bsdtar_test -bsdtar_TESTS_ENVIRONMENT= BSDTAR=`cd $(top_builddir);/bin/pwd`/bsdtar BSDTAR_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/tar/test +bsdtar_TESTS_ENVIRONMENT= BSDTAR=`cd $(top_builddir);/bin/pwd`/bsdtar$(EXEEXT) BSDTAR_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/tar/test else bsdtar_test_programs= bsdtar_TESTS_ENVIRONMENT= @@ -567,7 +567,7 @@ cpio/test/list.h: Makefile if BUILD_BSDCPIO bsdcpio_test_programs= bsdcpio_test -bsdcpio_TESTS_ENVIRONMENT= BSDCPIO=`cd $(top_builddir);/bin/pwd`/bsdcpio BSDCPIO_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/cpio/test +bsdcpio_TESTS_ENVIRONMENT= BSDCPIO=`cd $(top_builddir);/bin/pwd`/bsdcpio$(EXEEXT) BSDCPIO_TEST_FILES=`cd $(top_srcdir);/bin/pwd`/cpio/test else bsdcpio_test_programs= bsdcpio_TESTS_ENVIRONMENT= diff --git a/configure.ac b/configure.ac index 60ae3d2a0..6cd2da1e3 100644 --- a/configure.ac +++ b/configure.ac @@ -342,7 +342,7 @@ AC_CHECK_FUNCS([fstat ftruncate futimes geteuid getpid]) AC_CHECK_FUNCS([lchflags lchmod lchown link lstat]) AC_CHECK_FUNCS([lutimes memmove memset mkdir mkfifo mknod]) AC_CHECK_FUNCS([nl_langinfo pipe poll readlink select setenv setlocale]) -AC_CHECK_FUNCS([strchr strdup strerror strrchr symlink timegm]) +AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm]) AC_CHECK_FUNCS([tzset unsetenv utime utimes vfork]) AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy]) # detects cygwin-1.7, as opposed to older versions diff --git a/cpio/cpio_platform.h b/cpio/cpio_platform.h index 880dc9611..3106fe3c6 100644 --- a/cpio/cpio_platform.h +++ b/cpio/cpio_platform.h @@ -65,18 +65,20 @@ * and format string here must be compatible with one another and * large enough for any file. */ -#if HAVE_UINTMAX_T +#if defined(_WIN32) && !defined(__CYGWIN__) +#define CPIO_FILESIZE_TYPE __int64 +#define CPIO_FILESIZE_PRINTF "%I64u" +#elif HAVE_UINTMAX_T #define CPIO_FILESIZE_TYPE uintmax_t #define CPIO_FILESIZE_PRINTF "%ju" -#else -#if HAVE_UNSIGNED_LONG_LONG +#elif HAVE_UNSIGNED_LONG_LONG #define CPIO_FILESIZE_TYPE unsigned long long #define CPIO_FILESIZE_PRINTF "%llu" #else #define CPIO_FILESIZE_TYPE unsigned long #define CPIO_FILESIZE_PRINTF "%lu" #endif -#endif + /* How to mark functions that don't return. */ #if defined(__GNUC__) && (__GNUC__ > 2 || \ diff --git a/tar/tree.c b/tar/tree.c index 5d7a1be27..3fb1e8473 100644 --- a/tar/tree.c +++ b/tar/tree.c @@ -125,7 +125,7 @@ struct tree_entry { struct tree { struct tree_entry *stack; struct tree_entry *current; -#ifdef HAVE_WINDOWS_H +#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__) HANDLE d; #define INVALID_DIR_HANDLE INVALID_HANDLE_VALUE WIN32_FIND_DATA _findData; @@ -261,7 +261,7 @@ tree_append(struct tree *t, const char *name, size_t name_length) *p++ = DIRSEP; t->path_length ++; } -#if defined(_WIN32) && !defined(__CYGWIN__) +#if HAVE_STRNCPY_S strncpy_s(p, t->buff_length - (p - t->buff), name, name_length); #else strncpy(p, name, name_length); @@ -639,7 +639,7 @@ tree_current_lstat(struct tree *t) int tree_current_is_dir(struct tree *t) { -#if defined(_WIN32) +#if defined(_WIN32) && !defined(__CYGWIN__) if (t->findData) return (t->findData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); if (tree_current_file_information(t)) @@ -682,7 +682,7 @@ tree_current_is_dir(struct tree *t) int tree_current_is_physical_dir(struct tree *t) { -#if defined(_WIN32) +#if defined(_WIN32) && !defined(__CYGWIN__) if (tree_current_is_physical_link(t)) return (0); return (tree_current_is_dir(t)); @@ -719,7 +719,7 @@ tree_current_is_physical_dir(struct tree *t) int tree_current_is_physical_link(struct tree *t) { -#if defined(_WIN32) +#if defined(_WIN32) && !defined(__CYGWIN__) if (t->findData) return ((t->findData->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && (t->findData->dwReserved0 == IO_REPARSE_TAG_SYMLINK)); -- 2.47.3