commit bash-20190130 snapshot

This commit is contained in:
Chet Ramey
2019-02-01 09:03:24 -05:00
parent ca5d21091b
commit 8a9718cfc9
17 changed files with 194 additions and 40 deletions
+19 -5
View File
@@ -159,7 +159,7 @@ glob_pattern_p (pattern)
wchar_t *wpattern;
int r;
if (MB_CUR_MAX == 1)
if (MB_CUR_MAX == 1 || mbsmbchar (pattern) == 0)
return (internal_glob_pattern_p ((unsigned char *)pattern));
/* Convert strings to wide chars, and call the multibyte version. */
@@ -173,7 +173,7 @@ glob_pattern_p (pattern)
return r;
#else
return (internal_glob_pattern_p (pattern));
return (internal_glob_pattern_p ((unsigned char *)pattern));
#endif
}
@@ -431,6 +431,12 @@ wdequote_pathname (pathname)
int i, j;
wchar_t *orig_wpathname;
if (mbsmbchar (pathname) == 0)
{
udequote_pathname (pathname);
return;
}
len = strlen (pathname);
/* Convert the strings into wide characters. */
n = xdupmbstowcs (&wpathname, NULL, pathname);
@@ -1071,7 +1077,7 @@ glob_filename (pathname, flags)
char *directory_name, *filename, *dname, *fn;
unsigned int directory_len;
int free_dirname; /* flag */
int dflags;
int dflags, hasglob;
result = (char **) malloc (sizeof (char *));
result_size = 1;
@@ -1120,9 +1126,12 @@ glob_filename (pathname, flags)
free_dirname = 1;
}
hasglob = 0;
/* If directory_name contains globbing characters, then we
have to expand the previous levels. Just recurse. */
if (directory_len > 0 && glob_pattern_p (directory_name))
have to expand the previous levels. Just recurse.
If glob_pattern_p returns != [0,1] we have a pattern that has backslash
quotes but no unquoted glob pattern characters. We dequote it below. */
if (directory_len > 0 && (hasglob = glob_pattern_p (directory_name)) == 1)
{
char **directories, *d, *p;
register unsigned int i;
@@ -1342,6 +1351,11 @@ only_filename:
free (directory_name);
return (NULL);
}
if (directory_len > 0 && hasglob == 2) /* need to dequote */
{
dequote_pathname (directory_name);
directory_len = strlen (directory_name);
}
/* Handle GX_MARKDIRS here. */
result[0] = (char *) malloc (directory_len + 1);
if (result[0] == NULL)
+16 -7
View File
@@ -26,10 +26,10 @@ INTERNAL_GLOB_PATTERN_P (pattern)
{
register const GCHAR *p;
register GCHAR c;
int bopen;
int bopen, bsquote;
p = pattern;
bopen = 0;
bopen = bsquote = 0;
while ((c = *p++) != L('\0'))
switch (c)
@@ -55,13 +55,22 @@ INTERNAL_GLOB_PATTERN_P (pattern)
case L('\\'):
/* Don't let the pattern end in a backslash (GMATCH returns no match
if the pattern ends in a backslash anyway), but otherwise return 1,
since the matching engine uses backslash as an escape character
and it can be removed. */
return (*p != L('\0'));
if the pattern ends in a backslash anyway), but otherwise note that
we have seen this, since the matching engine uses backslash as an
escape character and it can be removed. We return 2 later if we
have seen only backslash-escaped characters, so interested callers
know they can shortcut and just dequote the pathname. */
if (*p != L('\0'))
{
p++;
bsquote = 1;
}
else if (*p == L('\0'))
return 0;
continue;
}
return 0;
return bsquote ? 2 : 0;
}
#undef INTERNAL_GLOB_PATTERN_P
+1 -1
View File
@@ -529,7 +529,7 @@ xstrmatch (pattern, string, flags)
if (MB_CUR_MAX == 1)
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
if (mbsmbchar (string) == 0 && mbsmbchar (pattern) == 0 && posix_cclass_only (pattern) )
if (mbsmbchar (string) == 0 && mbsmbchar (pattern) == 0 && posix_cclass_only (pattern))
return (internal_strmatch ((unsigned char *)pattern, (unsigned char *)string, flags));
n = xdupmbstowcs (&wpattern, NULL, pattern);