From: Michihiro NAKAJIMA Date: Sat, 26 Mar 2011 01:13:24 +0000 (-0400) Subject: Update comment about the return code of conversion functions. X-Git-Tag: v3.0.0a~602 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87df2f0b2a2916a703e03bb9a332cb24720c993c;p=thirdparty%2Flibarchive.git Update comment about the return code of conversion functions. archive_string_append_from_unicode_to_mbs always returns -1 if the platform have neither wctomb nor wcrtomb. SVN-Revision: 3076 --- diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c index 13137f170..3a0a397de 100644 --- a/libarchive/archive_string.c +++ b/libarchive/archive_string.c @@ -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 */ diff --git a/libarchive/archive_string.h b/libarchive/archive_string.h index a091a14ea..b5b6e6da4 100644 --- a/libarchive/archive_string.h +++ b/libarchive/archive_string.h @@ -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);