]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 15, part 12. wchar_t is only 16 bits
authorCharles Wilson <cwilso11@gmail.com>
Fri, 20 Mar 2009 07:14:49 +0000 (03:14 -0400)
committerCharles Wilson <cwilso11@gmail.com>
Fri, 20 Mar 2009 07:14:49 +0000 (03:14 -0400)
   Check the size in configure.ac/CMakeLists.txt,
   and react as needed in libarchive/archive_string.c.

SVN-Revision: 819

CMakeLists.txt
configure.ac
libarchive/archive_string.c

index 96bbac72a2da2fb39ad3716533ef8b627ce897a5..59b5a94c5acf0032d9d0e4cb1b49f6cd004709a2 100644 (file)
@@ -467,6 +467,8 @@ IF(NOT HAVE_UINTMAX_T)
   ENDIF(MSVC)
 ENDIF(NOT HAVE_UINTMAX_T)
 #
+CHECK_TYPE_SIZE(wchar_t     SIZEOF_WCHAR_T)
+#
 # Check if _FILE_OFFSET_BITS macro needed for large files
 #
 CHECK_FILE_OFFSET_BITS()
index c2fa7f83d74079208b848f1ccd0237b4ddc06644..cd4988010fff2ac91cf115eb934cdf2e91d12de3 100644 (file)
@@ -318,6 +318,11 @@ AC_CHECK_DECL([EILSEQ],
                [AC_DEFINE(HAVE_EILSEQ, 1, [A possible errno value for invalid file format errors])],
                [],
                [#include <errno.h>])
+AC_CHECK_TYPE([wchar_t],
+               [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]wchar_t), 1, [Define to 1 if the system has the type `wchar_t'.])dnl
+               AC_CHECK_SIZEOF([wchar_t])],
+               [])
+
 AC_HEADER_TIME
 
 # Checks for library functions.
index eacfc08c1af47ac2723c92b4b00e35928aa69125..e71c239f1750ca3b68ba2b96ae71d3ff5929ff38 100644 (file)
@@ -184,6 +184,7 @@ my_wctomb_utf8(char *p, wchar_t wc)
                p[1] = 0x80 | (wc & 0x3f);
                return (2);
        }
+#if SIZEOF_WCHAR_T > 2
        if (wc <= 0xffff) {
                p[0] = 0xe0 | ((wc >> 12) & 0x0f);
                p[1] = 0x80 | ((wc >> 6) & 0x3f);
@@ -203,6 +204,15 @@ my_wctomb_utf8(char *p, wchar_t wc)
         * can actually fail.
         */
        return (-1);
+#else
+       /* is this the right thing to do when wchar_t is
+        * limited to 16 bits?
+        */
+       p[0] = 0xe0 | ((wc >> 12) & 0x0f);
+       p[1] = 0x80 | ((wc >> 6) & 0x3f);
+       p[2] = 0x80 | (wc & 0x3f);
+       return (3);
+#endif
 }
 
 static int