mirror of
https://https.git.savannah.gnu.org/git/gnulib.git
synced 2026-05-13 15:13:36 +00: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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user