mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-06 11:50:49 +02:00
commit bash-20190130 snapshot
This commit is contained in:
+19
-5
@@ -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
@@ -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
@@ -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);
|
||||
|
||||
@@ -256,6 +256,7 @@ _rl_nsearch_abort (_rl_search_cxt *cxt)
|
||||
rl_clear_message ();
|
||||
rl_point = cxt->save_point;
|
||||
rl_mark = cxt->save_mark;
|
||||
_rl_fix_point (1);
|
||||
rl_restore_prompt ();
|
||||
|
||||
RL_UNSETSTATE (RL_STATE_NSEARCH);
|
||||
|
||||
+12
-1
@@ -1452,7 +1452,18 @@ rl_change_case (int count, int op)
|
||||
if (nwc != wc) /* just skip unchanged characters */
|
||||
{
|
||||
char *s, *e;
|
||||
mlen = wcrtomb (mb, nwc, &mps);
|
||||
mbstate_t ts;
|
||||
|
||||
memset (&ts, 0, sizeof (mbstate_t));
|
||||
mlen = wcrtomb (mb, nwc, &ts);
|
||||
if (mlen < 0)
|
||||
{
|
||||
nwc = wc;
|
||||
memset (&ts, 0, sizeof (mbstate_t));
|
||||
mlen = wcrtomb (mb, nwc, &ts);
|
||||
if (mlen < 0) /* should not happen */
|
||||
strncpy (mb, rl_line_buffer + start, mlen = m);
|
||||
}
|
||||
if (mlen > 0)
|
||||
mb[mlen] = '\0';
|
||||
/* what to do if m != mlen? adjust below */
|
||||
|
||||
@@ -196,6 +196,7 @@ rl_do_undo (void)
|
||||
/* Undoing deletes means inserting some text. */
|
||||
case UNDO_DELETE:
|
||||
rl_point = start;
|
||||
_rl_fix_point (1);
|
||||
rl_insert_text (rl_undo_list->text);
|
||||
xfree (rl_undo_list->text);
|
||||
break;
|
||||
@@ -204,6 +205,7 @@ rl_do_undo (void)
|
||||
case UNDO_INSERT:
|
||||
rl_delete_text (start, end);
|
||||
rl_point = start;
|
||||
_rl_fix_point (1);
|
||||
break;
|
||||
|
||||
/* Undoing an END means undoing everything 'til we get to a BEGIN. */
|
||||
|
||||
Reference in New Issue
Block a user