]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Reduce diffs between libarchive/test/test.h and tar/test/test.h
authorTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 21:31:53 +0000 (17:31 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 2 Aug 2009 21:31:53 +0000 (17:31 -0400)
SVN-Revision: 1314

libarchive/test/test.h
tar/test/test.h

index ec8d072fd742c1a2ceb94886d5f9c0ccf2d821fa..806d8a858fb7b244384da27baa471ad731051375 100644 (file)
 #ifdef USE_DMALLOC
 #include <dmalloc.h>
 #endif
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#if HAVE_DIRENT_H
 #include <dirent.h>
 #else
 #include <direct.h>
-#endif
-#if defined(__CYGWIN__)
-/* Cygwin-1.7.x is lazy about populating nlinks, so don't
- * expect it to be accurate. */
-# define NLINKS_INACCURATE_FOR_DIRS
+#define dirent direct
 #endif
 #include <errno.h>
 #include <fcntl.h>
 #include <windows.h>
 #endif
 
+/*
+ * System-specific tweaks.  We really want to minimize these
+ * as much as possible, since they make it harder to understand
+ * the mainline code.
+ */
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include "../bsdtar_windows.h"
+#define strdup _strdup
+#define LOCALE_DE      "deu"
+#else
+#define LOCALE_DE      "de_DE.UTF-8"
+#endif
+
+#ifdef _MSC_VER
+#define snprintf       sprintf_s
+#endif
+
+#if defined(__CYGWIN__)
+/* Cygwin-1.7.x is lazy about populating nlinks, so don't
+ * expect it to be accurate. */
+# define NLINKS_INACCURATE_FOR_DIRS
+#endif
 
 #ifdef __FreeBSD__
 #include <sys/cdefs.h>  /* For __FBSDID */
 #endif
 #endif
 
-#ifdef _MSC_VER
-#define snprintf       sprintf_s
-#endif
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define LOCALE_DE      "deu"
-#define strdup _strdup
-#else
-#define LOCALE_DE      "de_DE.UTF-8"
-#endif
-
 #ifndef O_BINARY
 #define        O_BINARY 0
 #endif
   test_setup(__FILE__, __LINE__);test_assert_text_file_contents
 #define assertIsDir(pathname, mode)            \
   test_assert_is_dir(__FILE__, __LINE__, pathname, mode)
-#define assertIsSymlink(pathname, contents)    \
-  test_assert_is_symlink(__FILE__, __LINE__, pathname, contents)
 #define assertIsReg(pathname, mode)            \
   test_assert_is_reg(__FILE__, __LINE__, pathname, mode)
+#define assertIsSymlink(pathname, contents)    \
+  test_assert_is_symlink(__FILE__, __LINE__, pathname, contents)
 /* Create a directory, report error if it fails. */
 #define assertMakeDir(dirname, mode)   \
   test_assert_make_dir(__FILE__, __LINE__, dirname, mode)
@@ -203,8 +211,8 @@ int test_assert_file_not_exists(const char *, ...);
 int test_assert_file_nlinks(const char *, int, const char *, int);
 int test_assert_file_size(const char *, int, const char *, long);
 int test_assert_is_dir(const char *, int, const char *, int);
-int test_assert_is_symlink(const char *, int, const char *, const char *);
 int test_assert_is_reg(const char *, int, const char *, int);
+int test_assert_is_symlink(const char *, int, const char *, const char *);
 int test_assert_make_dir(const char *, int, const char *, int);
 int test_assert_make_hardlink(const char *, int, const char *newpath, const char *);
 int test_assert_make_symlink(const char *, int, const char *newpath, const char *);
index 996eb6b3579ce4307bcbed64f8bbae7bd8df993e..da44ec6837b709b04c80231d86cd65f78b0b95a0 100644 (file)
 #error Oops: No config.h and no pre-built configuration in test.h.
 #endif
 
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#include <sys/types.h>  /* Windows requires this before sys/stat.h */
+#include <sys/stat.h>
+
+#ifdef USE_DMALLOC
+#include <dmalloc.h>
+#endif
+#if HAVE_DIRENT_H
 #include <dirent.h>
 #else
-#define dirent direct
-#include "../bsdtar_windows.h"
 #include <direct.h>
-#endif
-#if defined(__CYGWIN__)
-/* In cygwin-1.7.x, the .nlinks field of directories is
- * deliberately inaccurate, because to populate it requires
- * stat'ing every file in the directory, which is slow.
- * So, as an optimization cygwin doesn't do that in newer
- * releases; all correct applications on any platform should
- * never rely on it being > 1, so this optimization doesn't
- * impact the operation of correctly coded applications.
- * Therefore, the cpio test should not check its accuracy
- */
-# define NLINKS_INACCURATE_FOR_DIRS
+#define dirent direct
 #endif
 #include <errno.h>
 #include <fcntl.h>
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>  /* Windows requires this before sys/stat.h */
-#include <sys/stat.h>
-#if !defined(_WIN32) || defined(__CYGWIN__)
+#include <time.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <time.h>
 #include <wchar.h>
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
 
-#ifdef USE_DMALLOC
-#include <dmalloc.h>
+/*
+ * System-specific tweaks.  We really want to minimize these
+ * as much as possible, since they make it harder to understand
+ * the mainline code.
+ */
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include "../bsdtar_windows.h"
+#define strdup _strdup
+#define LOCALE_DE      "deu"
+#else
+#define LOCALE_DE      "de_DE.UTF-8"
+#endif
+
+#ifdef _MSC_VER
+#define snprintf       sprintf_s
+#endif
+
+#if defined(__CYGWIN__)
+/* Cygwin-1.7.x is lazy about populating nlinks, so don't
+ * expect it to be accurate. */
+# define NLINKS_INACCURATE_FOR_DIRS
 #endif
 
 #ifdef __FreeBSD__
 #endif
 #endif
 
-#ifdef _MSC_VER
-#define snprintf       sprintf_s
-#endif
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define LOCALE_DE      "deu"
-#else
-#define LOCALE_DE      "de_DE.UTF-8"
-#endif
-
 /*
  * Redefine DEFINE_TEST for use in defining the test functions.
  */