Skip to content

Commit adfe7b7

Browse files
committed
updated for version 7.4.613
Problem: The NFA engine does not implement the 'redrawtime' time limit. Solution: Implement the time limit.
1 parent f18db3c commit adfe7b7

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

src/regexp_nfa.c

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ static int check_char_class __ARGS((int class, int c));
311311
static void nfa_save_listids __ARGS((nfa_regprog_T *prog, int *list));
312312
static void nfa_restore_listids __ARGS((nfa_regprog_T *prog, int *list));
313313
static int nfa_re_num_cmp __ARGS((long_u val, int op, long_u pos));
314-
static long nfa_regtry __ARGS((nfa_regprog_T *prog, colnr_T col));
315-
static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
314+
static long nfa_regtry __ARGS((nfa_regprog_T *prog, colnr_T col, proftime_T *tm));
315+
static long nfa_regexec_both __ARGS((char_u *line, colnr_T col, proftime_T *tm));
316316
static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
317317
static void nfa_regfree __ARGS((regprog_T *prog));
318318
static int nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
@@ -3850,6 +3850,10 @@ pim_info(pim)
38503850

38513851
/* Used during execution: whether a match has been found. */
38523852
static int nfa_match;
3853+
#ifdef FEAT_RELTIME
3854+
static proftime_T *nfa_time_limit;
3855+
static int nfa_time_count;
3856+
#endif
38533857

38543858
static void copy_pim __ARGS((nfa_pim_T *to, nfa_pim_T *from));
38553859
static void clear_sub __ARGS((regsub_T *sub));
@@ -5449,6 +5453,10 @@ nfa_regmatch(prog, start, submatch, m)
54495453
fast_breakcheck();
54505454
if (got_int)
54515455
return FALSE;
5456+
#ifdef FEAT_RELTIME
5457+
if (nfa_time_limit != NULL && profile_passed_limit(nfa_time_limit))
5458+
return FALSE;
5459+
#endif
54525460

54535461
nfa_match = FALSE;
54545462

@@ -6789,9 +6797,18 @@ nfa_regmatch(prog, start, submatch, m)
67896797
break;
67906798

67916799
/* Allow interrupting with CTRL-C. */
6792-
fast_breakcheck();
6800+
line_breakcheck();
67936801
if (got_int)
67946802
break;
6803+
#ifdef FEAT_RELTIME
6804+
/* Check for timeout once in a twenty times to avoid overhead. */
6805+
if (nfa_time_limit != NULL && ++nfa_time_count == 20)
6806+
{
6807+
nfa_time_count = 0;
6808+
if (profile_passed_limit(nfa_time_limit))
6809+
break;
6810+
}
6811+
#endif
67956812
}
67966813

67976814
#ifdef ENABLE_LOG
@@ -6818,9 +6835,10 @@ nfa_regmatch(prog, start, submatch, m)
68186835
* Returns <= 0 for failure, number of lines contained in the match otherwise.
68196836
*/
68206837
static long
6821-
nfa_regtry(prog, col)
6838+
nfa_regtry(prog, col, tm)
68226839
nfa_regprog_T *prog;
68236840
colnr_T col;
6841+
proftime_T *tm; /* timeout limit or NULL */
68246842
{
68256843
int i;
68266844
regsubs_T subs, m;
@@ -6831,6 +6849,10 @@ nfa_regtry(prog, col)
68316849
#endif
68326850

68336851
reginput = regline + col;
6852+
#ifdef FEAT_RELTIME
6853+
nfa_time_limit = tm;
6854+
nfa_time_count = 0;
6855+
#endif
68346856

68356857
#ifdef ENABLE_LOG
68366858
f = fopen(NFA_REGEXP_RUN_LOG, "a");
@@ -6951,9 +6973,10 @@ nfa_regtry(prog, col)
69516973
* Returns <= 0 for failure, number of lines contained in the match otherwise.
69526974
*/
69536975
static long
6954-
nfa_regexec_both(line, startcol)
6976+
nfa_regexec_both(line, startcol, tm)
69556977
char_u *line;
69566978
colnr_T startcol; /* column to start looking for match */
6979+
proftime_T *tm; /* timeout limit or NULL */
69576980
{
69586981
nfa_regprog_T *prog;
69596982
long retval = 0L;
@@ -7047,7 +7070,7 @@ nfa_regexec_both(line, startcol)
70477070
prog->state[i].lastlist[1] = 0;
70487071
}
70497072

7050-
retval = nfa_regtry(prog, col);
7073+
retval = nfa_regtry(prog, col, tm);
70517074

70527075
nfa_regengine.expr = NULL;
70537076

@@ -7209,7 +7232,7 @@ nfa_regexec_nl(rmp, line, col, line_lbr)
72097232
ireg_icombine = FALSE;
72107233
#endif
72117234
ireg_maxcol = 0;
7212-
return nfa_regexec_both(line, col);
7235+
return nfa_regexec_both(line, col, NULL);
72137236
}
72147237

72157238

@@ -7245,7 +7268,7 @@ nfa_regexec_multi(rmp, win, buf, lnum, col, tm)
72457268
buf_T *buf; /* buffer in which to search */
72467269
linenr_T lnum; /* nr of line to start looking for match */
72477270
colnr_T col; /* column to start looking for match */
7248-
proftime_T *tm UNUSED; /* timeout limit or NULL */
7271+
proftime_T *tm; /* timeout limit or NULL */
72497272
{
72507273
reg_match = NULL;
72517274
reg_mmatch = rmp;
@@ -7260,7 +7283,7 @@ nfa_regexec_multi(rmp, win, buf, lnum, col, tm)
72607283
#endif
72617284
ireg_maxcol = rmp->rmm_maxcol;
72627285

7263-
return nfa_regexec_both(NULL, col);
7286+
return nfa_regexec_both(NULL, col, tm);
72647287
}
72657288

72667289
#ifdef DEBUG

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+
613,
744746
/**/
745747
612,
746748
/**/

0 commit comments

Comments
 (0)