Re: portability issues with unicodeio

Bruno Haible <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.parsers.bison.bugs
Message-ID <3257239.lobq0XaQ9Q@omega>
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  <[email protected]>

	unicodeio: Fix wrong result on Solaris 11.
	Reported by Kiyoshi Kanazawa <[email protected]>
	via Akim Demaille <[email protected]> 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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.