[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: portability issues with unicodeio
From: |
Bruno Haible |
Subject: |
Re: portability issues with unicodeio |
Date: |
Thu, 09 Jul 2020 17:31:21 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-179-generic; KDE/5.18.0; x86_64; ; ) |
Kiyoshi KANAZAWA wrote:
> make check passed both on Solaris 11.3 & 11.4.
Oh, I see. So my unit test was not complete.
> > It is succeeds this test, then what is the difference between the
> > coreutils printf program and the test-unicodeio.c program? Both call
> > setlocale (LC_ALL, "").
>
> I do not understand.
> What should I do next ?
I single-stepped both the coreutils printf program and the test-unicodeio.c
program, and found the issue.
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.
diff --git a/lib/unicodeio.c b/lib/unicodeio.c
index 8ae3308..81fe0dd 100644
--- a/lib/unicodeio.c
+++ b/lib/unicodeio.c
@@ -134,6 +134,10 @@ unicode_to_mb (unsigned int code,
# 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);
diff --git a/tests/test-unicodeio.c b/tests/test-unicodeio.c
index be91a91..fa28e98 100644
--- a/tests/test-unicodeio.c
+++ b/tests/test-unicodeio.c
@@ -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;