summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-01-03 00:31:58 +0100
committerBruno Haible <bruno@clisp.org>2022-01-03 00:31:58 +0100
commit402e0d0d93aaf2c6e33432eae98ceda9a929725f (patch)
tree969c2e884f474228116ddcf6b9ff424d86af68a5 /lib
parentcb2be452cd15f00430e7079e44958995b68f69a2 (diff)
downloadgnulib-402e0d0d93aaf2c6e33432eae98ceda9a929725f.tar.gz
striconveh: Make the last change also work on Solaris 11.
* lib/striconveh.c (mem_cd_iconveh_internal): Tweak last commit.
Diffstat (limited to 'lib')
-rw-r--r--lib/striconveh.c17
1 files changed, 10 insertions, 7 deletions
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)