From: Bruno Haible Date: Sun, 2 Jan 2022 23:31:58 +0000 (+0100) Subject: striconveh: Make the last change also work on Solaris 11. X-Git-Tag: v1.0~2430 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=402e0d0d93aaf2c6e33432eae98ceda9a929725f;p=gnulib.git striconveh: Make the last change also work on Solaris 11. * lib/striconveh.c (mem_cd_iconveh_internal): Tweak last commit. --- diff --git a/ChangeLog b/ChangeLog index 6f21e74097..2cb4da4cdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-01-02 Bruno Haible + striconveh: Make the last change also work on Solaris 11. + * lib/striconveh.c (mem_cd_iconveh_internal): Tweak last commit. + striconveh: Make the last change also work on musl libc. * lib/striconveh.c (mem_cd_iconveh_internal): Make the U+FFFD conversion also work with non-GNU iconv() implementations. diff --git a/lib/striconveh.c b/lib/striconveh.c index 7364828427..5b60a7e0af 100644 --- a/lib/striconveh.c +++ b/lib/striconveh.c @@ -853,7 +853,8 @@ mem_cd_iconveh_internal (const char *src, size_t srclen, (ICONV_CONST char **) &inptr, &insize, &out2ptr_try, &out2size_try); if (handler == iconveh_replacement_character - && ((res == (size_t)(-1) && errno == EILSEQ) + && (res == (size_t)(-1) + ? errno == EILSEQ /* FreeBSD iconv(), NetBSD iconv(), and Solaris 11 iconv() insert a '?' if they cannot convert. This is what we want. @@ -861,9 +862,9 @@ mem_cd_iconveh_internal (const char *src, size_t srclen, cannot convert. And musl libc iconv() inserts a '*' if it cannot convert. */ - || (res > 0 - && !(out2ptr_try - out2ptr == 1 - && *out2ptr == '?')))) + : (res > 0 + && !(out2ptr_try - out2ptr == 1 + && *out2ptr == '?')))) { /* The iconv() call failed. U+FFFD can't be converted to TO_CODESET. @@ -881,6 +882,7 @@ mem_cd_iconveh_internal (const char *src, size_t srclen, /* Accept the results of the iconv() call. */ out2ptr = out2ptr_try; out2size = out2size_try; + res = 0; } } else @@ -947,9 +949,10 @@ mem_cd_iconveh_internal (const char *src, size_t srclen, length = out2ptr - result; } # if !defined _LIBICONV_VERSION && !(defined __GLIBC__ && !defined __UCLIBC__) - /* Irix iconv() inserts a NUL byte if it cannot convert. - NetBSD iconv() inserts a question mark if it cannot - convert. + /* IRIX iconv() inserts a NUL byte if it cannot convert. + FreeBSD iconv(), NetBSD iconv(), and Solaris 11 + iconv() insert a '?' if they cannot convert. + musl libc iconv() inserts a '*' if it cannot convert. Only GNU libiconv and GNU libc are known to prefer to fail rather than doing a lossy conversion. */ if (res != (size_t)(-1) && res > 0)