2022-01-02 Bruno Haible <bruno@clisp.org>
+ 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.
(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.
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.
/* Accept the results of the iconv() call. */
out2ptr = out2ptr_try;
out2size = out2size_try;
+ res = 0;
}
}
else
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)