if (*p == '^' && !(attempt & 1)) // add/remove '^'
++p;
regmatch.regprog = vim_regcomp(p, magic_isset() ? RE_MAGIC : 0);
- if (regmatch.regprog == NULL)
- {
- vim_free(pat);
- return -1;
- }
FOR_ALL_BUFS_FROM_LAST(buf)
+ {
+ if (regmatch.regprog == NULL)
+ {
+ // invalid pattern, possibly after switching engine
+ vim_free(pat);
+ return -1;
+ }
if (buf->b_p_bl == find_listed
#ifdef FEAT_DIFF
&& (!diffmode || diff_mode_buf(buf))
}
match = buf->b_fnum; // remember first match
}
+ }
vim_regfree(regmatch.regprog);
if (match >= 0) // found one match
if (attempt > 0 && patc == pat)
break; // there was no anchor, no need to try again
regmatch.regprog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
- if (regmatch.regprog == NULL)
- {
- if (patc != pat)
- vim_free(patc);
- return FAIL;
- }
}
// round == 1: Count the matches.
#endif
if (!fuzzy)
+ {
+ if (regmatch.regprog == NULL)
+ {
+ // invalid pattern, possibly after recompiling
+ if (patc != pat)
+ vim_free(patc);
+ return FAIL;
+ }
p = buflist_match(®match, buf, p_wic);
+ }
else
{
p = NULL;
/*
* Check for a match on the file name for buffer "buf" with regprog "prog".
+ * Note that rmp->regprog may become NULL when switching regexp engine.
*/
static char_u *
buflist_match(
}
/*
- * Try matching the regexp in "prog" with file name "name".
+ * Try matching the regexp in "rmp->regprog" with file name "name".
+ * Note that rmp->regprog may become NULL when switching regexp engine.
* Return "name" when there is a match, NULL when not.
*/
static char_u *
char_u *match = NULL;
char_u *p;
- if (name != NULL)
+ // extra check for valid arguments
+ if (name != NULL && rmp->regprog != NULL)
{
// Ignore case when 'fileignorecase' or the argument is set.
rmp->rm_ic = p_fic || ignore_case;