]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Update comment about the return code of conversion functions.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sat, 26 Mar 2011 01:13:24 +0000 (21:13 -0400)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sat, 26 Mar 2011 01:13:24 +0000 (21:13 -0400)
archive_string_append_from_unicode_to_mbs always returns -1
if the platform have neither wctomb nor wcrtomb.

SVN-Revision: 3076

libarchive/archive_string.c
libarchive/archive_string.h

index 13137f170c489d50d70bf818ceb8814d0b3bc28e..3a0a397ded343bdf93526dba3f347744a8a849a6 100644 (file)
@@ -427,6 +427,7 @@ archive_string_conversion_from_charset(struct archive *a, const char *charset)
 
 /*
  * Convert MBS to WCS.
+ * Note: returns -1 if conversion fails.
  */
 int
 archive_wstring_append_from_mbs(struct archive *a,
@@ -456,6 +457,7 @@ archive_wstring_append_from_mbs(struct archive *a,
 
 /*
  * Convert MBS to WCS.
+ * Note: returns -1 if conversion fails.
  */
 int
 archive_wstring_append_from_mbs(struct archive *a,
@@ -499,7 +501,7 @@ archive_wstring_append_from_mbs(struct archive *a,
 
 /*
  * WCS ==> MBS.
- * Note: returns NULL if conversion fails.
+ * Note: returns -1 if conversion fails.
  *
  * Win32 builds use WideCharToMultiByte from the Windows API.
  * (Maybe Cygwin should too?  WideCharToMultiByte will know a
@@ -538,25 +540,17 @@ archive_string_append_from_unicode_to_mbs(struct archive *a,
        return (0);
 }
 
-#else
+#elif defined(HAVE_WCTOMB) || defined(HAVE_WCRTOMB)
 
 /*
  * Translates a wide character string into current locale character set
- * and appends to the archive_string.  Note: returns NULL if conversion
+ * and appends to the archive_string.  Note: returns -1 if conversion
  * fails.
- *
- * Non-Windows uses ISO C wcrtomb() or wctomb() to perform the conversion
- * one character at a time.  If a non-Windows platform doesn't have
- * either of these, fall back to the built-in UTF8 conversion.
  */
 int
 archive_string_append_from_unicode_to_mbs(struct archive *a,
     struct archive_string *as, const wchar_t *w, size_t len)
 {
-#if !defined(HAVE_WCTOMB) && !defined(HAVE_WCRTOMB)
-       /* If there's no built-in locale support, fall back to UTF8 always. */
-       return archive_string_append_from_unicode_to_utf8(as, w, len);
-#else
        /* We cannot use the standard wcstombs() here because it
         * cannot tell us how big the output buffer should be.  So
         * I've built a loop around wcrtomb() or wctomb() that
@@ -600,10 +594,24 @@ archive_string_append_from_unicode_to_mbs(struct archive *a,
        *p = '\0';
        archive_strcat(as, buff);
        return (0);
-#endif
 }
 
-#endif /* _WIN32 && ! __CYGWIN__ */
+#else /* HAVE_WCTOMB || HAVE_WCRTOMB */
+
+/*
+ * TODO: Test if __STDC_ISO_10646__ is defined.
+ * Non-Windows uses ISO C wcrtomb() or wctomb() to perform the conversion
+ * one character at a time.  If a non-Windows platform doesn't have
+ * either of these, fall back to the built-in UTF8 conversion.
+ */
+int
+archive_string_append_from_unicode_to_mbs(struct archive *a,
+    struct archive_string *as, const wchar_t *w, size_t len)
+{
+       return (-1);
+}
+
+#endif /* HAVE_WCTOMB || HAVE_WCRTOMB */
 
 
 
index a091a14ea71807ae114f4a19379ed3407f5b2c8c..b5b6e6da484e0e3452ba160042f837b98e31b25f 100644 (file)
@@ -82,7 +82,7 @@ int
 archive_string_append_from_unicode_to_utf8(struct archive_string *, const wchar_t *, size_t);
 
 /* Convert a Unicode string to current locale and append the result. */
-/* Returns NULL if conversion fails. */
+/* Returns -1 if conversion fails. */
 int
 archive_string_append_from_unicode_to_mbs(struct archive *, struct archive_string *, const wchar_t *, size_t);