From 0b273fff2f1bcec210669dad3a4eaaafe1089aba Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 30 Jul 2020 03:29:29 +0200 Subject: [PATCH] unicodeio: Fix wrong result on musl libc. Reported by A. Wilcox in . * 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 | 10 ++++++++++ lib/unicodeio.c | 6 +++++- m4/unicodeio.m4 | 6 +++--- modules/unicodeio | 1 + 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c5fd79351f..9b9f044f9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2020-07-29 Bruno Haible + + unicodeio: Fix wrong result on musl libc. + Reported by A. Wilcox in + . + * 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 fsusage, regex, stat-size: remove Cray support diff --git a/lib/unicodeio.c b/lib/unicodeio.c index b616e3d61f..7d5e1fbcd2 100644 --- a/lib/unicodeio.c +++ b/lib/unicodeio.c @@ -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); diff --git a/m4/unicodeio.m4 b/m4/unicodeio.m4 index 11bcd180d1..a2e9bf0270 100644 --- a/m4/unicodeio.m4 +++ b/m4/unicodeio.m4 @@ -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 ]) diff --git a/modules/unicodeio b/modules/unicodeio index 51721db72d..d7a3a4a95d 100644 --- a/modules/unicodeio +++ b/modules/unicodeio @@ -5,6 +5,7 @@ Files: lib/unicodeio.h lib/unicodeio.c m4/unicodeio.m4 +m4/musl.m4 Depends-on: unistr/u8-uctomb -- 2.39.5