Re: [PATCH 2/2] quotearg: support USE_C_LOCALE variant

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Organization GNU
Message-ID <3759130.R56niFO833@nimes>
Paul Eggert wrote:
> Thanks for mentioning that. I installed the attached to try to fix this.

The gzip CI now shows a compilation error on musl libc and on macOS:

gcc -DHAVE_CONFIG_H -I. -I../../lib   -Wall   -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unused-const-variable -Wno-unsuffixed-float-constants -Wno-error -g -O2 -MT libgzip_a-quotearg.o -MD -MP -MF .deps/libgzip_a-quotearg.Tpo -c -o libgzip_a-quotearg.o `test -f 'quotearg.c' || echo '../../lib/'`quotearg.c
../../lib/quotearg.c: In function 'chisprint':
../../lib/quotearg.c:105:10: error: implicit declaration of function 'c_isprint'; did you mean 'chisprint'? [-Wimplicit-function-declaration]
  105 |   return c_isprint (c);
      |          ^~~~~~~~~
      |          chisprint
make[3]: *** [Makefile:3158: libgzip_a-quotearg.o] Error 1

This patch fixes it. (Tested on musl libc.)


2026-05-26  Bruno Haible  <[email protected]>

	quotearg: Fix compilation error in USE_C_LOCALE code.
	* lib/quotearg.c: If USE_C_LOCALE && C_LOCALE_MIGHT_BE_MULTIBYTE,
	include c-ctype.h instead of <ctype.h>.
	* modules/quotearg (Depends-on): Add c-ctype.

diff --git a/lib/quotearg.c b/lib/quotearg.c
index 1c31a1ec04..64850af1e1 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -72,13 +72,14 @@ typedef struct incomplete_mbstate *mbstate;
 #  define GNULIB_MBRTOC32_REGULAR 1
 # endif
 #else
-# include <ctype.h>
 # include <wchar.h>
 typedef mbstate_t mbstate;
 # if USE_C_LOCALE
-# include <wctype.h>
+#  include <c-ctype.h>
+#  include <wctype.h>
 typedef wchar_t wch;
 # else
+#  include <ctype.h>
 #  include <uchar.h>
 typedef char32_t wch;
 # endif
diff --git a/modules/quotearg b/modules/quotearg
index 7e61400ef1..02e54d989d 100644
--- a/modules/quotearg
+++ b/modules/quotearg
@@ -10,6 +10,7 @@ m4/musl.m4
 
 Depends-on:
 attribute
+c-ctype
 c32isprint
 extensions
 gettext-h
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.