]> Savannah Git Hosting - gnulib.git/commitdiff
unicodeio: Fix wrong result on Solaris 11.
authorBruno Haible <bruno@clisp.org>
Thu, 9 Jul 2020 15:28:48 +0000 (17:28 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 9 Jul 2020 15:28:48 +0000 (17:28 +0200)
Reported by Kiyoshi Kanazawa <yoi_no_myoujou@yahoo.co.jp>
via Akim Demaille <akim.demaille@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-07/msg00036.html>.

* lib/unicodeio.c (unicode_to_mb): Handle question mark fallback
characters on Solaris.
* tests/test-unicodeio.c (main): In the "C" locale, expect either the
UTF-8 output or the specified fallback.

ChangeLog
lib/unicodeio.c
tests/test-unicodeio.c

index c2182f08c5f942422c19cbda95e9305203ab5458..556fb535255f62872d8e57c9a3398221b578be68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-07-09  Bruno Haible  <bruno@clisp.org>
+
+       unicodeio: Fix wrong result on Solaris 11.
+       Reported by Kiyoshi Kanazawa <yoi_no_myoujou@yahoo.co.jp>
+       via Akim Demaille <akim.demaille@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2020-07/msg00036.html>.
+       * lib/unicodeio.c (unicode_to_mb): Handle question mark fallback
+       characters on Solaris.
+       * tests/test-unicodeio.c (main): In the "C" locale, expect either the
+       UTF-8 output or the specified fallback.
+
 2020-07-08  Bruno Haible  <bruno@clisp.org>
 
        unicodeio: Add tests.
index 8ae330867166108f0d47ce9c5bcf0d8f9856420a..81fe0ddbf97ff93749e98dd930621c20bc694a37 100644 (file)
@@ -133,6 +133,10 @@ unicode_to_mb (unsigned int code,
           /* Irix iconv() inserts a NUL byte if it cannot convert. */
 # if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi)
           || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '\0')
+# endif
+          /* Solaris 11 iconv() inserts a '?' if it cannot convert. */
+# if !defined _LIBICONV_VERSION && defined __sun
+          || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '?')
 # endif
          )
         return failure (code, NULL, callback_arg);
index be91a9164671e926da67e06021042687455e80d6..fa28e98e66dc79f3d6015c1d7654229f0b553185 100644 (file)
@@ -62,6 +62,7 @@ main (int argc, char *argv[])
       if (argc > 1)
         switch (argv[1][0])
           {
+          case '1': /* On some platforms, the "C" locale has UTF-8 encoding.  */
           case '2':
             ASSERT (strcmp (result, TEST_CODE_AS_UTF8) == 0);
             break;