]> Savannah Git Hosting - gnulib.git/commitdiff
unicodeio: Fix wrong result on musl libc.
authorBruno Haible <bruno@clisp.org>
Thu, 30 Jul 2020 01:29:29 +0000 (03:29 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 30 Jul 2020 01:30:11 +0000 (03:30 +0200)
Reported by A. Wilcox <awilfox@adelielinux.org> in
<https://www.openwall.com/lists/musl/2020/07/29/2>.

* lib/unicodeio.c (unicode_to_mb): Handle asterisk fallback characters
on musl libc.
* m4/unicodeio.m4 (gl_UNICODEIO): Invoke gl_MUSL_LIBC.
* modules/unicodeio (Files): Add m4/musl.m4.

ChangeLog
lib/unicodeio.c
m4/unicodeio.m4
modules/unicodeio

index c5fd79351f2a88b0fe1dec63a56b450a5536e6b3..9b9f044f9bbbb0a904aba5483f2e5f91076d5eae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-07-29  Bruno Haible  <bruno@clisp.org>
+
+       unicodeio: Fix wrong result on musl libc.
+       Reported by A. Wilcox <awilfox@adelielinux.org> in
+       <https://www.openwall.com/lists/musl/2020/07/29/2>.
+       * lib/unicodeio.c (unicode_to_mb): Handle asterisk fallback characters
+       on musl libc.
+       * m4/unicodeio.m4 (gl_UNICODEIO): Invoke gl_MUSL_LIBC.
+       * modules/unicodeio (Files): Add m4/musl.m4.
+
 2020-07-29  Paul Eggert  <eggert@cs.ucla.edu>
 
        fsusage, regex, stat-size: remove Cray support
index b616e3d61f7fccd624916267f63e3e6e9f0556d0..7d5e1fbcd282dcbd11c1c69fb71b4ca67a188bf1 100644 (file)
@@ -130,7 +130,7 @@ unicode_to_mb (unsigned int code,
                    (ICONV_CONST char **)&inptr, &inbytesleft,
                    &outptr, &outbytesleft);
       if (inbytesleft > 0 || res == (size_t)(-1)
-          /* Irix iconv() inserts a NUL byte if it cannot convert. */
+          /* 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
@@ -138,6 +138,10 @@ unicode_to_mb (unsigned int code,
              convert.  */
 # if !defined _LIBICONV_VERSION && (defined __NetBSD__ || defined __sun)
           || (res > 0 && outptr - outbuf == 1 && *outbuf == '?')
+# endif
+          /* musl libc iconv() inserts a '*' if it cannot convert.  */
+# if !defined _LIBICONV_VERSION && MUSL_LIBC
+          || (res > 0 && outptr - outbuf == 1 && *outbuf == '*')
 # endif
          )
         return failure (code, NULL, callback_arg);
index 11bcd180d1c51d03bd9b5011d229a06428bc1be7..a2e9bf02709367bbfd010c6e48b72f254950467d 100644 (file)
@@ -1,4 +1,4 @@
-# unicodeio.m4 serial 2
+# unicodeio.m4 serial 3
 dnl Copyright (C) 2002-2003, 2009-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,6 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_UNICODEIO],
 [
-  dnl No prerequisites of lib/unicodeio.c.
-  :
+  dnl Prerequisites of lib/unicodeio.c.
+  gl_MUSL_LIBC
 ])
index 51721db72d19f25926149a3c9ef5ba11e63178ae..d7a3a4a95d45ab0a78f2cffa3b132e42d27c600f 100644 (file)
@@ -5,6 +5,7 @@ Files:
 lib/unicodeio.h
 lib/unicodeio.c
 m4/unicodeio.m4
+m4/musl.m4
 
 Depends-on:
 unistr/u8-uctomb