1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

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).
This commit is contained in:
Bruno Haible
2023-06-30 22:54:12 +02:00
parent 2dfd7cc0f3
commit 2d422a55f4
32 changed files with 124 additions and 24 deletions

View File

@@ -1,3 +1,63 @@
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.

View File

@@ -41,8 +41,7 @@
#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)
@@ -535,7 +534,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
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)
@@ -620,9 +619,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
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)
@@ -639,6 +638,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
}
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
@@ -659,7 +660,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
}
}
if (! iswprint (w))
if (! c32isprint (w))
printable = false;
m += bytes;
}

View File

@@ -21,7 +21,9 @@ Include:
"acl.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIB_ACL)
$(QCOPY_ACL_LIB)

View File

@@ -25,6 +25,6 @@ TESTS += \
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)

View File

@@ -27,7 +27,9 @@ Include:
"argmatch.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -9,5 +9,5 @@ configure.ac:
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)

View File

@@ -36,7 +36,9 @@ Include:
"backupfile.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -37,7 +37,9 @@ Include:
"backupfile.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -21,7 +21,9 @@ Include:
"closein.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -12,4 +12,4 @@ configure.ac:
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)

View File

@@ -23,7 +23,9 @@ Include:
"closeout.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -38,7 +38,9 @@ Include:
Link:
$(LIB_ACL)
$(QCOPY_ACL_LIB)
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -18,4 +18,4 @@ Makefile.am:
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)

View File

@@ -28,7 +28,9 @@ Include:
"csharpcomp.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIBTHREAD)
License:

View File

@@ -28,7 +28,9 @@ Include:
"csharpexec.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIBTHREAD)
License:

View File

@@ -27,7 +27,9 @@ Include:
"human.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -43,7 +43,9 @@ Include:
"javacomp.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(GETRANDOM_LIB)
$(LIBTHREAD)

View File

@@ -29,7 +29,9 @@ Include:
"javaexec.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
$(LIBTHREAD)
License:

View File

@@ -17,7 +17,9 @@ Include:
"quote.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -5,16 +5,15 @@ Files:
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
@@ -22,8 +21,7 @@ quotearg-simple
localcharset
stdbool
stdint
wchar
wctype-h
uchar
xalloc
configure.ac:
@@ -36,7 +34,9 @@ Include:
"quotearg.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -13,7 +13,9 @@ Makefile.am:
Include:
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -19,4 +19,4 @@ AC_CHECK_FUNCS_ONCE([mprotect])
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)

View File

@@ -29,4 +29,4 @@ TESTS_ENVIRONMENT += \
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)

View File

@@ -11,4 +11,4 @@ configure.ac:
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)

View File

@@ -19,7 +19,9 @@ Include:
"sh-quote.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -8,4 +8,4 @@ configure.ac:
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)

View File

@@ -18,6 +18,11 @@ lib_SOURCES += string-desc-quotearg.c
Include:
"string-desc-quotearg.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -9,4 +9,4 @@ configure.ac:
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)

View File

@@ -20,7 +20,9 @@ Include:
"system-quote.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -18,7 +18,7 @@ configure.ac:
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.

View File

@@ -22,7 +22,9 @@ Include:
"xmemcoll.h"
Link:
$(LTLIBUNISTRING) when linking with libtool, $(LIBUNISTRING) otherwise
$(MBRTOWC_LIB)
$(LTLIBC32CONV) when linking with libtool, $(LIBC32CONV) otherwise
License:
GPL

View File

@@ -12,4 +12,4 @@ configure.ac:
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)