]> Savannah Git Hosting - gnulib.git/commitdiff
striconveh: Make the last change also work on Solaris 11.
authorBruno Haible <bruno@clisp.org>
Sun, 2 Jan 2022 23:31:58 +0000 (00:31 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 2 Jan 2022 23:31:58 +0000 (00:31 +0100)
* lib/striconveh.c (mem_cd_iconveh_internal): Tweak last commit.

ChangeLog
lib/striconveh.c

index 6f21e7409756c0df3db784168764ade694af695f..2cb4da4cdca0e02b8c89b21d49876ebf903dc60b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 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.
index 736482842705ee16709c8ab5fff1a5962a6051a7..5b60a7e0af3afe24ce4efe92fef3ba5b2c56bb87 100644 (file)
@@ -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)