Skip to content

Commit 3452786

Browse files
committed
updated for version 7.4.526
Problem: matchstr() fails on long text. Daniel Hahler) Solution: Return NFA_TOO_EXPENSIVE from regexec_nl(). (Christian Brabandt)
1 parent cd3dc23 commit 3452786

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/regexp.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3739,7 +3739,7 @@ static int bt_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, in
37393739
* Uses curbuf for line count and 'iskeyword'.
37403740
* if "line_lbr" is TRUE consider a "\n" in "line" to be a line break.
37413741
*
3742-
* Return TRUE if there is a match, FALSE if not.
3742+
* Returns 0 for failure, number of lines contained in the match otherwise.
37433743
*/
37443744
static int
37453745
bt_regexec_nl(rmp, line, col, line_lbr)
@@ -3759,7 +3759,8 @@ bt_regexec_nl(rmp, line, col, line_lbr)
37593759
ireg_icombine = FALSE;
37603760
#endif
37613761
ireg_maxcol = 0;
3762-
return (bt_regexec_both(line, col, NULL) != 0);
3762+
3763+
return bt_regexec_both(line, col, NULL);
37633764
}
37643765

37653766
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)
37813782
colnr_T col; /* column to start looking for match */
37823783
proftime_T *tm; /* timeout limit or NULL */
37833784
{
3784-
long r;
3785-
37863785
reg_match = NULL;
37873786
reg_mmatch = rmp;
37883787
reg_buf = buf;
@@ -3796,24 +3795,23 @@ bt_regexec_multi(rmp, win, buf, lnum, col, tm)
37963795
#endif
37973796
ireg_maxcol = rmp->rmm_maxcol;
37983797

3799-
r = bt_regexec_both(NULL, col, tm);
3800-
3801-
return r;
3798+
return bt_regexec_both(NULL, col, tm);
38023799
}
38033800

38043801
/*
38053802
* Match a regexp against a string ("line" points to the string) or multiple
38063803
* lines ("line" is NULL, use reg_getline()).
3804+
* Returns 0 for failure, number of lines contained in the match otherwise.
38073805
*/
38083806
static long
38093807
bt_regexec_both(line, col, tm)
38103808
char_u *line;
38113809
colnr_T col; /* column to start looking for match */
38123810
proftime_T *tm UNUSED; /* timeout limit or NULL */
38133811
{
3814-
bt_regprog_T *prog;
3815-
char_u *s;
3816-
long retval = 0L;
3812+
bt_regprog_T *prog;
3813+
char_u *s;
3814+
long retval = 0L;
38173815

38183816
/* Create "regstack" and "backpos" if they are not allocated yet.
38193817
* We allocate *_INITIAL amount of bytes first and then set the grow size
@@ -8201,11 +8199,12 @@ vim_regexec_both(rmp, line, col, nl)
82018199

82028200
p_re = save_p_re;
82038201
}
8204-
return result;
8202+
return result > 0;
82058203
}
82068204

82078205
/*
82088206
* Note: "*prog" may be freed and changed.
8207+
* Return TRUE if there is a match, FALSE if not.
82098208
*/
82108209
int
82118210
vim_regexec_prog(prog, ignore_case, line, col)
@@ -8226,6 +8225,7 @@ vim_regexec_prog(prog, ignore_case, line, col)
82268225

82278226
/*
82288227
* Note: "rmp->regprog" may be freed and changed.
8228+
* Return TRUE if there is a match, FALSE if not.
82298229
*/
82308230
int
82318231
vim_regexec(rmp, line, col)
@@ -8241,6 +8241,7 @@ vim_regexec(rmp, line, col)
82418241
/*
82428242
* Like vim_regexec(), but consider a "\n" in "line" to be a line break.
82438243
* Note: "rmp->regprog" may be freed and changed.
8244+
* Return TRUE if there is a match, FALSE if not.
82448245
*/
82458246
int
82468247
vim_regexec_nl(rmp, line, col)
@@ -8297,5 +8298,5 @@ vim_regexec_multi(rmp, win, buf, lnum, col, tm)
82978298
p_re = save_p_re;
82988299
}
82998300

8300-
return result;
8301+
return result <= 0 ? 0 : result;
83018302
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
526,
744746
/**/
745747
525,
746748
/**/

0 commit comments

Comments
 (0)