found_new_match = searchit(NULL, ins_buf, pos,
compl_direction,
compl_pattern, 1L, SEARCH_KEEP + SEARCH_NFMSG,
- RE_LAST, (linenr_T)0, NULL);
+ RE_LAST, (linenr_T)0, NULL, NULL);
--msg_silent;
if (!compl_started || set_match_pos)
{
pos = save_cursor = curwin->w_cursor;
subpatnum = searchit(curwin, curbuf, &pos, dir, pat, 1L,
- options, RE_SEARCH, (linenr_T)lnum_stop, &tm);
+ options, RE_SEARCH, (linenr_T)lnum_stop, &tm, NULL);
if (subpatnum != FAIL)
{
if (flags & SP_SUBPAT)
for (;;)
{
n = searchit(curwin, curbuf, &pos, dir, pat, 1L,
- options, RE_SEARCH, lnum_stop, &tm);
+ options, RE_SEARCH, lnum_stop, &tm, NULL);
if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos)))
/* didn't find it or found the first match again: FAIL */
break;
); ++lnum)
{
nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum,
- (colnr_T)0, NULL);
+ (colnr_T)0, NULL, NULL);
if (nmatch)
{
colnr_T copycol;
|| nmatch_tl > 0
|| (nmatch = vim_regexec_multi(®match, curwin,
curbuf, sub_firstlnum,
- matchcol, NULL)) == 0
+ matchcol, NULL, NULL)) == 0
|| regmatch.startpos[0].lnum > 0)
{
if (new_start != NULL)
}
if (nmatch == -1 && !lastone)
nmatch = vim_regexec_multi(®match, curwin, curbuf,
- sub_firstlnum, matchcol, NULL);
+ sub_firstlnum, matchcol, NULL, NULL);
/*
* 5. break if there isn't another match in this line
{
lnum = curwin->w_cursor.lnum;
match = vim_regexec_multi(®match, curwin, curbuf, lnum,
- (colnr_T)0, NULL);
+ (colnr_T)0, NULL, NULL);
if ((type == 'g' && match) || (type == 'v' && !match))
global_exe_one(cmd, lnum);
}
{
/* a match on this line? */
match = vim_regexec_multi(®match, curwin, curbuf, lnum,
- (colnr_T)0, NULL);
+ (colnr_T)0, NULL, NULL);
if ((type == 'g' && match) || (type == 'v' && !match))
{
ml_setmarked(lnum);
curwin->w_cursor.col = 0;
searchcmdlen = 0;
if (!do_search(NULL, c, cmd, 1L,
- SEARCH_HIS | SEARCH_MSG, NULL))
+ SEARCH_HIS | SEARCH_MSG, NULL, NULL))
{
curwin->w_cursor = pos;
cmd = NULL;
if (searchit(curwin, curbuf, &pos,
*cmd == '?' ? BACKWARD : FORWARD,
(char_u *)"", 1L, SEARCH_MSG,
- i, (linenr_T)0, NULL) != FAIL)
+ i, (linenr_T)0, NULL, NULL) != FAIL)
lnum = pos.lnum;
else
{
i = searchit(curwin, curbuf, &t,
c == Ctrl_G ? FORWARD : BACKWARD,
ccline.cmdbuff, count, search_flags,
- RE_SEARCH, 0, NULL);
+ RE_SEARCH, 0, NULL, NULL);
--emsg_off;
if (i)
{
i = do_search(NULL, firstc, ccline.cmdbuff, count,
SEARCH_KEEP + SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK,
#ifdef FEAT_RELTIME
- &tm
+ &tm, NULL
#else
- NULL
+ NULL, NULL
#endif
);
--emsg_off;
searchflags += SEARCH_START;
i = msg_scroll;
(void)do_search(NULL, down ? '/' : '?', ga.ga_data, 1L,
- searchflags, NULL);
+ searchflags, NULL, NULL);
msg_scroll = i; /* don't let an error message set msg_scroll */
}
{
valid = FALSE;
t = searchit(curwin, curbuf, &curwin->w_cursor, FORWARD,
- pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL);
+ pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL, NULL);
if (curwin->w_cursor.lnum >= old_pos.lnum)
t = FAIL; /* match after start is failure too */
curwin->w_set_curswant = TRUE;
i = do_search(cap->oap, dir, pat, cap->count1,
- opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL);
+ opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL, NULL);
if (i == 0)
clearop(cap->oap);
else
int vim_regexec_prog(regprog_T **prog, int ignore_case, char_u *line, colnr_T col);
int vim_regexec(regmatch_T *rmp, char_u *line, colnr_T col);
int vim_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col);
-long vim_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm);
+long vim_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm, int *timed_out);
/* vim: set ft=c : */
void reset_search_dir(void);
void set_last_search_pat(char_u *s, int idx, int magic, int setlast);
void last_pat_prog(regmmatch_T *regmatch);
-int searchit(win_T *win, buf_T *buf, pos_T *pos, int dir, char_u *pat, long count, int options, int pat_use, linenr_T stop_lnum, proftime_T *tm);
+int searchit(win_T *win, buf_T *buf, pos_T *pos, int dir, char_u *pat, long count, int options, int pat_use, linenr_T stop_lnum, proftime_T *tm, int *timed_out);
void set_search_direction(int cdir);
-int do_search(oparg_T *oap, int dirc, char_u *pat, long count, int options, proftime_T *tm);
+int do_search(oparg_T *oap, int dirc, char_u *pat, long count, int options, proftime_T *tm, int *timed_out);
int search_for_exact_line(buf_T *buf, pos_T *pos, int dir, char_u *pat);
int searchc(cmdarg_T *cap, int t_cmd);
pos_T *findmatch(oparg_T *oap, int initc);
save_cursor = curwin->w_cursor;
curwin->w_cursor.lnum = 0;
if (!do_search(NULL, '/', qf_ptr->qf_pattern, (long)1,
- SEARCH_KEEP, NULL))
+ SEARCH_KEEP, NULL, NULL))
curwin->w_cursor = save_cursor;
}
{
col = 0;
while (vim_regexec_multi(®match, curwin, buf, lnum,
- col, NULL) > 0)
+ col, NULL, NULL) > 0)
{
/* Pass the buffer number so that it gets used even for a
* dummy buffer, unless duplicate_name is set, then the
} regbehind_T;
static char_u *reg_getline(linenr_T lnum);
-static long bt_regexec_both(char_u *line, colnr_T col, proftime_T *tm);
+static long bt_regexec_both(char_u *line, colnr_T col, proftime_T *tm, int *timed_out);
static long regtry(bt_regprog_T *prog, colnr_T col);
static void cleanup_subexpr(void);
#ifdef FEAT_SYN_HL
#endif
rex.reg_maxcol = 0;
- return bt_regexec_both(line, col, NULL);
+ return bt_regexec_both(line, col, NULL, NULL);
}
/*
buf_T *buf, /* buffer in which to search */
linenr_T lnum, /* nr of line to start looking for match */
colnr_T col, /* column to start looking for match */
- proftime_T *tm) /* timeout limit or NULL */
+ proftime_T *tm, /* timeout limit or NULL */
+ int *timed_out) /* flag set on timeout or NULL */
{
rex.reg_match = NULL;
rex.reg_mmatch = rmp;
#endif
rex.reg_maxcol = rmp->rmm_maxcol;
- return bt_regexec_both(NULL, col, tm);
+ return bt_regexec_both(NULL, col, tm, timed_out);
}
/*
bt_regexec_both(
char_u *line,
colnr_T col, /* column to start looking for match */
- proftime_T *tm UNUSED) /* timeout limit or NULL */
+ proftime_T *tm UNUSED, /* timeout limit or NULL */
+ int *timed_out UNUSED) /* flag set on timeout or NULL */
{
bt_regprog_T *prog;
char_u *s;
{
tm_count = 0;
if (profile_passed_limit(tm))
+ {
+ if (timed_out != NULL)
+ *timed_out = TRUE;
break;
+ }
}
#endif
}
buf_T *buf, /* buffer in which to search */
linenr_T lnum, /* nr of line to start looking for match */
colnr_T col, /* column to start looking for match */
- proftime_T *tm) /* timeout limit or NULL */
+ proftime_T *tm, /* timeout limit or NULL */
+ int *timed_out) /* flag is set when timeout limit reached */
{
int result;
regexec_T rex_save;
rex_save = rex;
rex_in_use = TRUE;
- result = rmp->regprog->engine->regexec_multi(rmp, win, buf, lnum, col, tm);
+ result = rmp->regprog->engine->regexec_multi(
+ rmp, win, buf, lnum, col, tm, timed_out);
/* NFA engine aborted because it's very slow. */
if (rmp->regprog->re_engine == AUTOMATIC_ENGINE
rmp->regprog = vim_regcomp(pat, re_flags);
if (rmp->regprog != NULL)
result = rmp->regprog->engine->regexec_multi(
- rmp, win, buf, lnum, col, tm);
+ rmp, win, buf, lnum, col, tm, timed_out);
vim_free(pat);
}
p_re = save_p_re;
{
regprog_T *(*regcomp)(char_u*, int);
void (*regfree)(regprog_T *);
- int (*regexec_nl)(regmatch_T*, char_u*, colnr_T, int);
- long (*regexec_multi)(regmmatch_T*, win_T*, buf_T*, linenr_T, colnr_T, proftime_T*);
+ int (*regexec_nl)(regmatch_T *, char_u *, colnr_T, int);
+ long (*regexec_multi)(regmmatch_T *, win_T *, buf_T *, linenr_T, colnr_T, proftime_T *, int *);
char_u *expr;
};
static void nfa_save_listids(nfa_regprog_T *prog, int *list);
static void nfa_restore_listids(nfa_regprog_T *prog, int *list);
static int nfa_re_num_cmp(long_u val, int op, long_u pos);
-static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm);
-static long nfa_regexec_both(char_u *line, colnr_T col, proftime_T *tm);
+static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm, int *timed_out);
+static long nfa_regexec_both(char_u *line, colnr_T col, proftime_T *tm, int *timed_out);
static regprog_T *nfa_regcomp(char_u *expr, int re_flags);
static void nfa_regfree(regprog_T *prog);
static int nfa_regexec_nl(regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr);
-static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm);
+static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm, int *timed_out);
static int match_follows(nfa_state_T *startstate, int depth);
static int failure_chance(nfa_state_T *state, int depth);
static int nfa_match;
#ifdef FEAT_RELTIME
static proftime_T *nfa_time_limit;
+static int *nfa_timed_out;
static int nfa_time_count;
#endif
return 0L;
}
+#ifdef FEAT_RELTIME
+ static int
+nfa_did_time_out()
+{
+ if (nfa_time_limit != NULL && profile_passed_limit(nfa_time_limit))
+ {
+ if (nfa_timed_out != NULL)
+ *nfa_timed_out = TRUE;
+ return TRUE;
+ }
+ return FALSE;
+}
+#endif
+
/*
* Main matching routine.
*
if (got_int)
return FALSE;
#ifdef FEAT_RELTIME
- if (nfa_time_limit != NULL && profile_passed_limit(nfa_time_limit))
+ if (nfa_did_time_out())
return FALSE;
#endif
/* compute nextlist */
for (listidx = 0; listidx < thislist->n; ++listidx)
{
+ /* If the list gets very long there probably is something wrong.
+ * At least allow interrupting with CTRL-C. */
+ fast_breakcheck();
+ if (got_int)
+ break;
+#ifdef FEAT_RELTIME
+ if (nfa_time_limit != NULL && ++nfa_time_count == 20)
+ {
+ nfa_time_count = 0;
+ if (nfa_did_time_out())
+ break;
+ }
+#endif
t = &thislist->t[listidx];
#ifdef NFA_REGEXP_DEBUG_LOG
if (nfa_time_limit != NULL && ++nfa_time_count == 20)
{
nfa_time_count = 0;
- if (profile_passed_limit(nfa_time_limit))
+ if (nfa_did_time_out())
break;
}
#endif
nfa_regtry(
nfa_regprog_T *prog,
colnr_T col,
- proftime_T *tm UNUSED) /* timeout limit or NULL */
+ proftime_T *tm UNUSED, /* timeout limit or NULL */
+ int *timed_out UNUSED) /* flag set on timeout or NULL */
{
int i;
regsubs_T subs, m;
reginput = regline + col;
#ifdef FEAT_RELTIME
nfa_time_limit = tm;
+ nfa_timed_out = timed_out;
nfa_time_count = 0;
#endif
nfa_regexec_both(
char_u *line,
colnr_T startcol, /* column to start looking for match */
- proftime_T *tm) /* timeout limit or NULL */
+ proftime_T *tm, /* timeout limit or NULL */
+ int *timed_out) /* flag set on timeout or NULL */
{
nfa_regprog_T *prog;
long retval = 0L;
prog->state[i].lastlist[1] = 0;
}
- retval = nfa_regtry(prog, col, tm);
+ retval = nfa_regtry(prog, col, tm, timed_out);
nfa_regengine.expr = NULL;
rex.reg_icombine = FALSE;
#endif
rex.reg_maxcol = 0;
- return nfa_regexec_both(line, col, NULL);
+ return nfa_regexec_both(line, col, NULL, NULL);
}
buf_T *buf, /* buffer in which to search */
linenr_T lnum, /* nr of line to start looking for match */
colnr_T col, /* column to start looking for match */
- proftime_T *tm) /* timeout limit or NULL */
+ proftime_T *tm, /* timeout limit or NULL */
+ int *timed_out) /* flag set on timeout or NULL */
{
rex.reg_match = NULL;
rex.reg_mmatch = rmp;
#endif
rex.reg_maxcol = rmp->rmm_maxcol;
- return nfa_regexec_both(NULL, col, tm);
+ return nfa_regexec_both(NULL, col, tm, timed_out);
}
#ifdef DEBUG
int regprog_is_copy = (shl != &search_hl && cur != NULL
&& shl == &cur->hl
&& cur->match.regprog == cur->hl.rm.regprog);
+ int timed_out = FALSE;
nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum,
matchcol,
#ifdef FEAT_RELTIME
- &(shl->tm)
+ &(shl->tm), &timed_out
#else
- NULL
+ NULL, NULL
#endif
);
/* Copy the regprog, in case it got freed and recompiled. */
if (regprog_is_copy)
cur->match.regprog = cur->hl.rm.regprog;
- if (called_emsg || got_int)
+ if (called_emsg || got_int || timed_out)
{
/* Error while handling regexp: stop using this regexp. */
if (shl == &search_hl)
int options,
int pat_use, /* which pattern to use when "pat" is empty */
linenr_T stop_lnum, /* stop after this line number when != 0 */
- proftime_T *tm UNUSED) /* timeout limit or NULL */
+ proftime_T *tm UNUSED, /* timeout limit or NULL */
+ int *timed_out UNUSED) /* set when timed out or NULL */
{
int found;
linenr_T lnum; /* no init to shut up Apollo cc */
nmatched = vim_regexec_multi(®match, win, buf,
lnum, col,
#ifdef FEAT_RELTIME
- tm
+ tm, timed_out
#else
- NULL
+ NULL, NULL
#endif
);
/* Abort searching on an error (e.g., out of stack). */
- if (called_emsg)
+ if (called_emsg
+#ifdef FEAT_RELTIME
+ || (timed_out != NULL && *timed_out)
+#endif
+ )
break;
if (nmatched > 0)
{
win, buf, lnum + matchpos.lnum,
matchcol,
#ifdef FEAT_RELTIME
- tm
+ tm, timed_out
#else
- NULL
+ NULL, NULL
#endif
)) == 0)
{
win, buf, lnum + matchpos.lnum,
matchcol,
#ifdef FEAT_RELTIME
- tm
+ tm, timed_out
#else
- NULL
+ NULL, NULL
#endif
)) == 0)
break;
* twice.
*/
if (!p_ws || stop_lnum != 0 || got_int || called_emsg
+#ifdef FEAT_RELTIME
+ || (timed_out != NULL && *timed_out)
+#endif
#ifdef FEAT_SEARCH_EXTRA
- || break_loop
+ || break_loop
#endif
- || found || loop)
+ || found || loop)
break;
/*
? top_bot_msg : bot_top_msg), TRUE);
}
if (got_int || called_emsg
+#ifdef FEAT_RELTIME
+ || (timed_out != NULL && *timed_out)
+#endif
#ifdef FEAT_SEARCH_EXTRA
|| break_loop
#endif
char_u *pat,
long count,
int options,
- proftime_T *tm) /* timeout limit or NULL */
+ proftime_T *tm, /* timeout limit or NULL */
+ int *timed_out) /* flag set on timeout or NULL */
{
pos_T pos; /* position of the last match */
char_u *searchstr;
(SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS
+ SEARCH_MSG + SEARCH_START
+ ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF))),
- RE_LAST, (linenr_T)0, tm);
+ RE_LAST, (linenr_T)0, tm, timed_out);
if (dircp != NULL)
*dircp = dirc; /* restore second '/' or '?' for normal_cmd() */
result = searchit(curwin, curbuf, &pos, (dir ? FORWARD : BACKWARD),
spats[last_idx].pat, (long) (i ? count : 1),
- SEARCH_KEEP | flags, RE_SEARCH, 0, NULL);
+ SEARCH_KEEP | flags, RE_SEARCH, 0, NULL, NULL);
/* First search may fail, but then start searching from the
* beginning of the file (cursor might be on the search match)
* already on the next match */
if (!one_char)
result = searchit(curwin, curbuf, &pos, (forward ? FORWARD : BACKWARD),
- spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0, NULL);
+ spats[last_idx].pat, 0L, flags | SEARCH_KEEP, RE_SEARCH, 0,
+ NULL, NULL);
if (!VIsual_active)
VIsual = start_pos;
}
if (searchit(curwin, curbuf, &pos, FORWARD, pattern, 1,
- SEARCH_KEEP + flag, RE_SEARCH, 0, NULL) != FAIL)
+ SEARCH_KEEP + flag, RE_SEARCH, 0, NULL, NULL) != FAIL)
{
/* Zero-width pattern should match somewhere, then we can check if
* start and end are in the same position. */
{
regmatch.startpos[0].col++;
nmatched = vim_regexec_multi(®match, curwin, curbuf,
- pos.lnum, regmatch.startpos[0].col, NULL);
+ pos.lnum, regmatch.startpos[0].col, NULL, NULL);
if (!nmatched)
break;
} while (regmatch.startpos[0].col < pos.col);
curwin->w_cursor.lnum = 0;
while (!got_int)
{
- if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP, NULL) == 0
+ if (do_search(NULL, '/', frompat, 1L, SEARCH_KEEP, NULL, NULL) == 0
|| u_save_cursor() == FAIL)
break;
#endif
rmp->rmm_maxcol = syn_buf->b_p_smc;
- r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, NULL);
+ r = vim_regexec_multi(rmp, syn_win, syn_buf, lnum, col, NULL, NULL);
#ifdef FEAT_PROFILE
if (syn_time_on)
save_lnum = curwin->w_cursor.lnum;
curwin->w_cursor.lnum = 0; /* start search before first line */
if (do_search(NULL, pbuf[0], pbuf + 1, (long)1,
- search_options, NULL))
+ search_options, NULL, NULL))
retval = OK;
else
{
*/
p_ic = TRUE;
if (!do_search(NULL, pbuf[0], pbuf + 1, (long)1,
- search_options, NULL))
+ search_options, NULL, NULL))
{
/*
* Failed to find pattern, take a guess: "^func ("
*tagp.tagname_end = NUL;
sprintf((char *)pbuf, "^%s\\s\\*(", tagp.tagname);
if (!do_search(NULL, '/', pbuf, (long)1,
- search_options, NULL))
+ search_options, NULL, NULL))
{
/* Guess again: "^char * \<func (" */
sprintf((char *)pbuf, "^\\[#a-zA-Z_]\\.\\*\\<%s\\s\\*(",
tagp.tagname);
if (!do_search(NULL, '/', pbuf, (long)1,
- search_options, NULL))
+ search_options, NULL, NULL))
found = 0;
}
*tagp.tagname_end = cc;
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 643,
/**/
642,
/**/