commit bash-20181019 snapshot

This commit is contained in:
Chet Ramey
2018-10-22 16:47:48 -04:00
parent f19b1b7334
commit b577a7bc74
9 changed files with 177 additions and 9 deletions
+17 -3
View File
@@ -199,7 +199,7 @@ int
_hs_history_patsearch (const char *string, int direction, int flags)
{
char *pat;
size_t len;
size_t len, start;
int ret, unescaped_backslash;
#if defined (HAVE_FNMATCH)
@@ -216,12 +216,26 @@ _hs_history_patsearch (const char *string, int direction, int flags)
}
if (unescaped_backslash)
return -1;
pat = (char *)xmalloc (len + 2);
pat = (char *)xmalloc (len + 3);
/* If the search string is not anchored, we'll be calling fnmatch (assuming
we have it). Prefix a `*' to the front of the search string so we search
anywhere in the line. */
if ((flags & ANCHORED_SEARCH) == 0 && string[0] != '*')
{
pat[0] = '*';
start = 1;
len++;
}
else
{
start = 0;
}
/* Attempt to reduce the number of searches by tacking a `*' onto the end
of a pattern that doesn't have one. Assume a pattern that ends in a
backslash contains an even number of trailing backslashes; we check
above */
strcpy (pat, string);
strcpy (pat + start, string);
if (pat[len - 1] != '*')
{
pat[len] = '*'; /* XXX */
+1 -1
View File
@@ -135,7 +135,7 @@ noninc_search_from_pos (char *string, int pos, int dir, int flags, int *ncp)
sflags |= ANCHORED_SEARCH;
s++;
}
ret = _hs_history_patsearch (string, dir, sflags);
ret = _hs_history_patsearch (s, dir, sflags);
}
else if (*string == '^')
ret = history_search_prefix (string + 1, dir);