* lib/quotearg.c: Include <uchar.h> instead of <wchar.h>, <wctype.h>.
(quotearg_buffer_restyled): Use mbrtoc32, c32isprint instead of mbrtowc,
iswprint.
* modules/quotearg (Files): Remove m4/mbstate_t.m4, m4/mbrtowc.m4
(redundant).
(Depends-on): Add uchar, mbrtoc32, c32isprint. Remove wchar, wctype-h,
mbrtowc.
(Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/quotearg-tests (Makefile.am): Link test-quotearg with
$(LIBUNISTRING) $(LIBC32CONV).
* modules/quotearg-simple (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/quotearg-simple-tests (Makefile.am): Link test-quotearg-simple
with $(LIBUNISTRING) $(LIBC32CONV).
--
* modules/quote (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
--
* modules/acl (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/acl-tests (Makefile.am): Link test-set-mode-acl and
test-copy-acl with $(LIBUNISTRING) $(LIBC32CONV).
* modules/copy-file (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/copy-file-tests (Makefile.am): Link test-copy-file with
$(LIBUNISTRING) $(LIBC32CONV).
--
* modules/argmatch (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/argmatch-tests (Makefile.am): Link test-argmatch with
$(LIBUNISTRING) $(LIBC32CONV).
* modules/backup-rename (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/backupfile (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/human (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
--
* modules/sh-quote (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/sh-quote-tests (Makefile.am): Link test-sh-quote with
$(LIBUNISTRING) $(LIBC32CONV).
* modules/system-quote (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/system-quote-tests (Makefile.am): Link test-system-quote-main
with $(LIBUNISTRING) $(LIBC32CONV).
* modules/csharpcomp (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/csharpexec (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/javacomp (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/javaexec (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
--
* modules/string-desc-quotearg (Link): New section.
* modules/string-desc-quotearg-tests (Makefile.am): Link
test-string-desc-quotearg with $(LIBUNISTRING) $(LIBC32CONV).
--
* modules/xmemcoll (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
--
* modules/closeout (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/readtokens-tests (Makefile.am): Link test-readtokens with
$(LIBUNISTRING) $(LIBC32CONV).
--
* modules/closein (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
* modules/closein-tests (Makefile.am): Link test-closein with
$(LIBUNISTRING) $(LIBC32CONV).
* modules/yesno-tests (Makefile.am): Link test-yesno with
$(LIBUNISTRING) $(LIBC32CONV).
+2023-07-01 Bruno Haible <bruno@clisp.org>
+
+ quotearg: Overcome wchar_t limitations.
+ * lib/quotearg.c: Include <uchar.h> instead of <wchar.h>, <wctype.h>.
+ (quotearg_buffer_restyled): Use mbrtoc32, c32isprint instead of mbrtowc,
+ iswprint.
+ * modules/quotearg (Files): Remove m4/mbstate_t.m4, m4/mbrtowc.m4
+ (redundant).
+ (Depends-on): Add uchar, mbrtoc32, c32isprint. Remove wchar, wctype-h,
+ mbrtowc.
+ (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/quotearg-tests (Makefile.am): Link test-quotearg with
+ $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/quotearg-simple (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/quotearg-simple-tests (Makefile.am): Link test-quotearg-simple
+ with $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/quote (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/acl (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/acl-tests (Makefile.am): Link test-set-mode-acl and
+ test-copy-acl with $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/copy-file (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/copy-file-tests (Makefile.am): Link test-copy-file with
+ $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/argmatch (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/argmatch-tests (Makefile.am): Link test-argmatch with
+ $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/backup-rename (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/backupfile (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/human (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/sh-quote (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/sh-quote-tests (Makefile.am): Link test-sh-quote with
+ $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/system-quote (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/system-quote-tests (Makefile.am): Link test-system-quote-main
+ with $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/csharpcomp (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/csharpexec (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/javacomp (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/javaexec (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/string-desc-quotearg (Link): New section.
+ * modules/string-desc-quotearg-tests (Makefile.am): Link
+ test-string-desc-quotearg with $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/xmemcoll (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/closeout (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/readtokens-tests (Makefile.am): Link test-readtokens with
+ $(LIBUNISTRING) $(LIBC32CONV).
+ --
+ * modules/closein (Link): Add $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/closein-tests (Makefile.am): Link test-closein with
+ $(LIBUNISTRING) $(LIBC32CONV).
+ * modules/yesno-tests (Makefile.am): Link test-yesno with
+ $(LIBUNISTRING) $(LIBC32CONV).
+
2023-06-30 Bruno Haible <bruno@clisp.org>
Accommodate a difference between mbrtowc and mbrtoc32.
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <wchar.h>
-#include <wctype.h>
+#include <uchar.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
case '`': case '|':
/* A shell special character. In theory, '$' and '`' could
be the first bytes of multibyte characters, which means
- we should check them with mbrtowc, but in practice this
+ we should check them with mbrtoc32, but in practice this
doesn't happen so it's not worth worrying about. */
if (quoting_style == shell_always_quoting_style
&& elide_outer_quotes)
do
{
- wchar_t w;
- size_t bytes = mbrtowc (&w, &arg[i + m],
- argsize - (i + m), &mbstate);
+ char32_t w;
+ size_t bytes = mbrtoc32 (&w, &arg[i + m],
+ argsize - (i + m), &mbstate);
if (bytes == 0)
break;
else if (bytes == (size_t) -1)
}
else
{
+ if (bytes == (size_t) -3)
+ bytes = 0;
/* Work around a bug with older shells that "see" a '\'
that is really the 2nd byte of a multibyte character.
In practice the problem is limited to ASCII
}
}
- if (! iswprint (w))
+ if (! c32isprint (w))
printable = false;
m += bytes;
}
"acl.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIB_ACL)
$(QCOPY_ACL_LIB)
test-copy-acl.sh test-copy-acl-1.sh test-copy-acl-2.sh
TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL)
check_PROGRAMS += test-set-mode-acl test-copy-acl test-sameacls
-test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(MBRTOWC_LIB)
-test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) @LIBINTL@ $(MBRTOWC_LIB)
+test_set_mode_acl_LDADD = $(LDADD) $(LIB_ACL) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
+test_copy_acl_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
test_sameacls_LDADD = $(LDADD) $(LIB_ACL) @LIBINTL@ $(MBRTOWC_LIB)
"argmatch.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Makefile.am:
TESTS += test-argmatch
check_PROGRAMS += test-argmatch
-test_argmatch_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_argmatch_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
"backupfile.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
"backupfile.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
"closein.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Makefile.am:
TESTS += test-closein.sh
check_PROGRAMS += test-closein
-test_closein_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_closein_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
"closeout.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Link:
$(LIB_ACL)
$(QCOPY_ACL_LIB)
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
TESTS += test-copy-file.sh test-copy-file-1.sh test-copy-file-2.sh
TESTS_ENVIRONMENT += USE_ACL=$(USE_ACL)
check_PROGRAMS += test-copy-file
-test_copy_file_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(CLOCK_TIME_LIB) @LIBINTL@ $(MBRTOWC_LIB)
+test_copy_file_LDADD = $(LDADD) $(LIB_ACL) $(QCOPY_ACL_LIB) $(CLOCK_TIME_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
"csharpcomp.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIBTHREAD)
License:
"csharpexec.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIBTHREAD)
License:
"human.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
"javacomp.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(GETRANDOM_LIB)
$(LIBTHREAD)
"javaexec.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIBTHREAD)
License:
"quote.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
lib/quotearg.h
lib/quotearg.c
lib/quote.h
-m4/mbstate_t.m4
-m4/mbrtowc.m4
m4/quotearg.m4
Depends-on:
attribute
c-strcaseeq
+c32isprint
extensions
gettext-h
-mbrtowc
+mbrtoc32
mbsinit
memcmp
minmax
localcharset
stdbool
stdint
-wchar
-wctype-h
+uchar
xalloc
configure.ac:
"quotearg.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Include:
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Makefile.am:
TESTS += test-quotearg-simple
check_PROGRAMS += test-quotearg-simple
-test_quotearg_simple_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_quotearg_simple_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
host_os='@host_os@'
check_PROGRAMS += test-quotearg
-test_quotearg_LDADD = $(LDADD) $(SETLOCALE_LIB) @LIBINTL@ $(MBRTOWC_LIB)
+test_quotearg_LDADD = $(LDADD) $(SETLOCALE_LIB) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
Makefile.am:
TESTS += test-readtokens.sh
check_PROGRAMS += test-readtokens
-test_readtokens_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_readtokens_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
"sh-quote.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Makefile.am:
TESTS += test-sh-quote
check_PROGRAMS += test-sh-quote
-test_sh_quote_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_sh_quote_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
Include:
"string-desc-quotearg.h"
+Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
+$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
+
License:
GPL
Makefile.am:
TESTS += test-string-desc-quotearg
check_PROGRAMS += test-string-desc-quotearg
-test_string_desc_quotearg_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_string_desc_quotearg_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
"system-quote.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Makefile.am:
TESTS += test-system-quote.sh
check_PROGRAMS += test-system-quote-main test-system-quote-child
-test_system_quote_main_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_system_quote_main_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)
# The test-system-quote-child program must be a real executable, not a libtool
# wrapper script, and should link against as few libraries as possible.
# Therefore don't link it against any libraries other than -lc.
"xmemcoll.h"
Link:
+$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
+$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL
Makefile.am:
TESTS += test-yesno.sh
check_PROGRAMS += test-yesno
-test_yesno_LDADD = $(LDADD) @LIBINTL@ $(MBRTOWC_LIB)
+test_yesno_LDADD = $(LDADD) $(LIBUNISTRING) @LIBINTL@ $(MBRTOWC_LIB) $(LIBC32CONV)