Merge r2498:
Improve support for systems without modern wctype.h by providing local
versions of wcscpy in test_entry.c and wcscmp in main.c.
SVN-Revision: 2510
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8e61c7..776f6c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -520,6 +520,7 @@
CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT)
CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK)
CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB)
+CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP)
CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY)
CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN)
CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB)
diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in
index 925c0ba..f135576 100644
--- a/build/cmake/config.h.in
+++ b/build/cmake/config.h.in
@@ -620,6 +620,9 @@
/* Define to 1 if you have the `wcrtomb' function. */
#cmakedefine HAVE_WCRTOMB 1
+/* Define to 1 if you have the `wcscmp' function. */
+#cmakedefine HAVE_WCSCMP 1
+
/* Define to 1 if you have the `wcscpy' function. */
#cmakedefine HAVE_WCSCPY 1
diff --git a/configure.ac b/configure.ac
index 75888d8..4a653a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -413,7 +413,7 @@
AC_CHECK_FUNCS([select setenv setlocale sigaction])
AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strrchr symlink timegm])
AC_CHECK_FUNCS([tzset unsetenv utime utimensat utimes vfork])
-AC_CHECK_FUNCS([wcrtomb wcscpy wcslen wctomb wmemcmp wmemcpy])
+AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy])
# detects cygwin-1.7, as opposed to older versions
AC_CHECK_FUNCS([cygwin_conv_path])
diff --git a/libarchive/test/main.c b/libarchive/test/main.c
index b143074..f67bbc3 100644
--- a/libarchive/test/main.c
+++ b/libarchive/test/main.c
@@ -485,6 +485,22 @@
logprintf("\"\n");
}
+#ifndef HAVE_WCSCMP
+static int
+wcscmp(const wchar_t *s1, const wchar_t *s2)
+{
+
+ while (*s1 == *s2++) {
+ if (*s1++ == L'\0')
+ return 0;
+ }
+ if (*s1 > *--s2)
+ return 1;
+ else
+ return -1;
+}
+#endif
+
/* Verify that two wide strings are equal, dump them if not. */
int
assertion_equal_wstring(const char *file, int line,
diff --git a/libarchive/test/test_entry.c b/libarchive/test/test_entry.c
index 586998c..bf36cbe 100644
--- a/libarchive/test/test_entry.c
+++ b/libarchive/test/test_entry.c
@@ -27,6 +27,16 @@
#include <locale.h>
+#ifndef HAVE_WCSCPY
+static wchar_t * wcscpy(wchar_t *s1, const wchar_t *s2)
+{
+ wchar_t *dest = s1;
+ while ((*s1 = *s2) != L'\0')
+ ++s1, ++s2;
+ return dest;
+}
+#endif
+
/*
* Most of these tests are system-independent, though a few depend on
* features of the local system. Such tests are conditionalized on
@@ -150,13 +160,11 @@
/* gname */
archive_entry_set_gname(e, "group");
assertEqualString(archive_entry_gname(e), "group");
-#if HAVE_WCSCPY
wcscpy(wbuff, L"wgroup");
archive_entry_copy_gname_w(e, wbuff);
assertEqualWString(archive_entry_gname_w(e), L"wgroup");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_gname_w(e), L"wgroup");
-#endif
/* hardlink */
archive_entry_set_hardlink(e, "hardlinkname");
@@ -169,7 +177,6 @@
archive_entry_copy_hardlink(e, NULL);
assertEqualString(archive_entry_hardlink(e), NULL);
assertEqualWString(archive_entry_hardlink_w(e), NULL);
-#if HAVE_WCSCPY
wcscpy(wbuff, L"whardlink");
archive_entry_copy_hardlink_w(e, wbuff);
assertEqualWString(archive_entry_hardlink_w(e), L"whardlink");
@@ -178,7 +185,6 @@
archive_entry_copy_hardlink_w(e, NULL);
assertEqualString(archive_entry_hardlink(e), NULL);
assertEqualWString(archive_entry_hardlink_w(e), NULL);
-#endif
#if ARCHIVE_VERSION_NUMBER >= 1009000
/* ino */
archive_entry_set_ino(e, 8593);
@@ -248,13 +254,11 @@
assertEqualString(archive_entry_pathname(e), "path2");
memset(buff, 0, sizeof(buff));
assertEqualString(archive_entry_pathname(e), "path2");
-#if HAVE_WCSCPY
wcscpy(wbuff, L"wpath");
archive_entry_copy_pathname_w(e, wbuff);
assertEqualWString(archive_entry_pathname_w(e), L"wpath");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_pathname_w(e), L"wpath");
-#endif
#if ARCHIVE_VERSION_NUMBER >= 1009000
/* rdev */
@@ -302,13 +306,11 @@
/* uname */
archive_entry_set_uname(e, "user");
assertEqualString(archive_entry_uname(e), "user");
-#if HAVE_WCSCPY
wcscpy(wbuff, L"wuser");
archive_entry_copy_gname_w(e, wbuff);
assertEqualWString(archive_entry_gname_w(e), L"wuser");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_gname_w(e), L"wuser");
-#endif
/* Test fflags interface. */
archive_entry_set_fflags(e, 0x55, 0xAA);