forked from aniani/vim
updated for version 7.4.526
Problem: matchstr() fails on long text. Daniel Hahler) Solution: Return NFA_TOO_EXPENSIVE from regexec_nl(). (Christian Brabandt)
This commit is contained in:
25
src/regexp.c
25
src/regexp.c
@@ -3739,7 +3739,7 @@ static int bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, in
|
||||
* Uses curbuf for line count and 'iskeyword'.
|
||||
* if "line_lbr" is TRUE consider a "\n" in "line" to be a line break.
|
||||
*
|
||||
* Return TRUE if there is a match, FALSE if not.
|
||||
* Returns 0 for failure, number of lines contained in the match otherwise.
|
||||
*/
|
||||
static int
|
||||
bt_regexec_nl(rmp, line, col, line_lbr)
|
||||
@@ -3759,7 +3759,8 @@ bt_regexec_nl(rmp, line, col, line_lbr)
|
||||
ireg_icombine = FALSE;
|
||||
#endif
|
||||
ireg_maxcol = 0;
|
||||
return (bt_regexec_both(line, col, NULL) != 0);
|
||||
|
||||
return bt_regexec_both(line, col, NULL);
|
||||
}
|
||||
|
||||
static long bt_regexec_multi __ARGS((regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm));
|
||||
@@ -3781,8 +3782,6 @@ bt_regexec_multi(rmp, win, buf, lnum, col, tm)
|
||||
colnr_T col; /* column to start looking for match */
|
||||
proftime_T *tm; /* timeout limit or NULL */
|
||||
{
|
||||
long r;
|
||||
|
||||
reg_match = NULL;
|
||||
reg_mmatch = rmp;
|
||||
reg_buf = buf;
|
||||
@@ -3796,14 +3795,13 @@ bt_regexec_multi(rmp, win, buf, lnum, col, tm)
|
||||
#endif
|
||||
ireg_maxcol = rmp->rmm_maxcol;
|
||||
|
||||
r = bt_regexec_both(NULL, col, tm);
|
||||
|
||||
return r;
|
||||
return bt_regexec_both(NULL, col, tm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Match a regexp against a string ("line" points to the string) or multiple
|
||||
* lines ("line" is NULL, use reg_getline()).
|
||||
* Returns 0 for failure, number of lines contained in the match otherwise.
|
||||
*/
|
||||
static long
|
||||
bt_regexec_both(line, col, tm)
|
||||
@@ -3811,9 +3809,9 @@ bt_regexec_both(line, col, tm)
|
||||
colnr_T col; /* column to start looking for match */
|
||||
proftime_T *tm UNUSED; /* timeout limit or NULL */
|
||||
{
|
||||
bt_regprog_T *prog;
|
||||
char_u *s;
|
||||
long retval = 0L;
|
||||
bt_regprog_T *prog;
|
||||
char_u *s;
|
||||
long retval = 0L;
|
||||
|
||||
/* Create "regstack" and "backpos" if they are not allocated yet.
|
||||
* We allocate *_INITIAL amount of bytes first and then set the grow size
|
||||
@@ -8201,11 +8199,12 @@ vim_regexec_both(rmp, line, col, nl)
|
||||
|
||||
p_re = save_p_re;
|
||||
}
|
||||
return result;
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: "*prog" may be freed and changed.
|
||||
* Return TRUE if there is a match, FALSE if not.
|
||||
*/
|
||||
int
|
||||
vim_regexec_prog(prog, ignore_case, line, col)
|
||||
@@ -8226,6 +8225,7 @@ vim_regexec_prog(prog, ignore_case, line, col)
|
||||
|
||||
/*
|
||||
* Note: "rmp->regprog" may be freed and changed.
|
||||
* Return TRUE if there is a match, FALSE if not.
|
||||
*/
|
||||
int
|
||||
vim_regexec(rmp, line, col)
|
||||
@@ -8241,6 +8241,7 @@ vim_regexec(rmp, line, col)
|
||||
/*
|
||||
* Like vim_regexec(), but consider a "\n" in "line" to be a line break.
|
||||
* Note: "rmp->regprog" may be freed and changed.
|
||||
* Return TRUE if there is a match, FALSE if not.
|
||||
*/
|
||||
int
|
||||
vim_regexec_nl(rmp, line, col)
|
||||
@@ -8297,5 +8298,5 @@ vim_regexec_multi(rmp, win, buf, lnum, col, tm)
|
||||
p_re = save_p_re;
|
||||
}
|
||||
|
||||
return result;
|
||||
return result <= 0 ? 0 : result;
|
||||
}
|
||||
|
@@ -741,6 +741,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
526,
|
||||
/**/
|
||||
525,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user