mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-12 06:30:50 +02:00
commit bash-20181019 snapshot
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user