commit bash-20191004 snapshot

This commit is contained in:
Chet Ramey
2019-10-07 11:02:34 -04:00
parent 41e92b981d
commit f7ec6b1a00
18 changed files with 329 additions and 102 deletions
+6 -5
View File
@@ -91,7 +91,6 @@ extern int signal_is_pending __P((int));
extern void run_pending_traps __P((void));
extern int extended_glob;
extern int posix_glob_backslash;
/* Global variable which controls whether or not * matches .*.
Non-zero means don't match .*. */
@@ -475,6 +474,12 @@ wdequote_pathname (pathname)
/* Convert the wide character string into unibyte character set. */
memset (&ps, '\0', sizeof(mbstate_t));
n = wcsrtombs(pathname, (const wchar_t **)&wpathname, len, &ps);
if (n == (size_t)-1 || *wpathname != 0) /* what? now you tell me? */
{
wpathname = orig_wpathname;
memset (&ps, '\0', sizeof(mbstate_t));
n = xwcsrtombs (pathname, (const wchar_t **)&wpathname, len, &ps);
}
pathname[len] = '\0';
/* Can't just free wpathname here; wcsrtombs changes it in many cases. */
@@ -1421,7 +1426,6 @@ only_filename:
if (directory_len > 0 && hasglob == 2 && (flags & GX_RECURSE) == 0)
{
#if 1
dequote_pathname (directory_name);
if (glob_testdir (directory_name, 0) < 0)
{
@@ -1429,9 +1433,6 @@ only_filename:
free (directory_name);
return ((char **)&glob_error_return);
}
#else
return ((char **)&glob_error_return);
#endif
}
/* Handle GX_MARKDIRS here. */
+5 -1
View File
@@ -70,7 +70,11 @@ INTERNAL_GLOB_PATTERN_P (pattern)
return 0;
}
return ((bsquote && posix_glob_backslash) ? 2 : 0);
#if 0
return bsquote ? 2 : 0;
#else
return (0);
#endif
}
#undef INTERNAL_GLOB_PATTERN_P
+115 -1
View File
@@ -1,6 +1,6 @@
/* xmbsrtowcs.c -- replacement function for mbsrtowcs */
/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -35,6 +35,11 @@
#if HANDLE_MULTIBYTE
#include <errno.h>
#if !defined (errno)
extern int errno;
#endif
#define WSBUF_INC 32
#ifndef FREE
@@ -406,4 +411,113 @@ xdupmbstowcs (destp, indicesp, src)
return (wcnum - 1);
}
/* Convert wide character string to multibyte character string. Treat invalid
wide characters as bytes. Used only in unusual circumstances.
Written by Bruno Haible <bruno@clisp.org>, 2008, adapted by Chet Ramey
for use in Bash. */
/* Convert wide character string *SRCP to a multibyte character string and
store the result in DEST. Store at most LEN bytes in DEST. */
size_t
xwcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
{
const wchar_t *src;
size_t cur_max; /* XXX - locale_cur_max */
char buf[64], *destptr, *tmp_dest;
unsigned char uc;
mbstate_t prev_state;
cur_max = MB_CUR_MAX;
if (cur_max > sizeof (buf)) /* Holy cow. */
return (size_t)-1;
src = *srcp;
if (dest != NULL)
{
destptr = dest;
for (; len > 0; src++)
{
wchar_t wc;
size_t ret;
wc = *src;
/* If we have room, store directly into DEST. */
tmp_dest = destptr;
ret = wcrtomb (len >= cur_max ? destptr : buf, wc, ps);
if (ret == (size_t)(-1)) /* XXX */
{
/* Since this is used for globbing and other uses of filenames,
treat invalid wide character sequences as bytes. This is
intended to be symmetric with xdupmbstowcs2. */
handle_byte:
destptr = tmp_dest; /* in case wcrtomb modified it */
uc = wc;
ret = 1;
if (len >= cur_max)
*destptr = uc;
else
buf[0] = uc;
if (ps)
memset (ps, 0, sizeof (mbstate_t));
}
if (ret > cur_max) /* Holy cow */
goto bad_input;
if (len < ret)
break;
if (len < cur_max)
memcpy (destptr, buf, ret);
if (wc == 0)
{
src = NULL;
/* Here mbsinit (ps). */
break;
}
destptr += ret;
len -= ret;
}
*srcp = src;
return destptr - dest;
}
else
{
/* Ignore dest and len, don't store *srcp at the end, and
don't clobber *ps. */
mbstate_t state = *ps;
size_t totalcount = 0;
for (;; src++)
{
wchar_t wc;
size_t ret;
wc = *src;
ret = wcrtomb (buf, wc, &state);
if (ret == (size_t)(-1))
goto bad_input2;
if (wc == 0)
{
/* Here mbsinit (&state). */
break;
}
totalcount += ret;
}
return totalcount;
}
bad_input:
*srcp = src;
bad_input2:
errno = EILSEQ;
return (size_t)(-1);
}
#endif /* HANDLE_MULTIBYTE */
+11 -28
View File
@@ -1335,12 +1335,13 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
memset (&ps2, 0, sizeof (mbstate_t));
}
#endif
if (_rl_completion_case_fold)
for (si = 0; (c1 = match_list[i][si]) && (c2 = match_list[i + 1][si]); si++)
{
for (si = 0;
(c1 = _rl_to_lower(match_list[i][si])) &&
(c2 = _rl_to_lower(match_list[i + 1][si]));
si++)
if (_rl_completion_case_fold)
{
c1 = _rl_to_lower (c1);
c2 = _rl_to_lower (c2);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
@@ -1352,35 +1353,17 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
break;
continue;
}
wc1 = towlower (wc1);
wc2 = towlower (wc2);
if (_rl_completion_case_fold)
{
wc1 = towlower (wc1);
wc2 = towlower (wc2);
}
if (wc1 != wc2)
break;
else if (v1 > 1)
si += v1 - 1;
}
else
#endif
if (c1 != c2)
break;
}
else
{
for (si = 0;
(c1 = match_list[i][si]) &&
(c2 = match_list[i + 1][si]);
si++)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
mbstate_t ps_back;
ps_back = ps1;
if (!_rl_compare_chars (match_list[i], si, &ps1, match_list[i+1], si, &ps2))
break;
else if ((v = _rl_get_char_len (&match_list[i][si], &ps_back)) > 1)
si += v - 1;
}
else
#endif
if (c1 != c2)
break;