|
|
22c937 |
To: vim_dev@googlegroups.com
|
|
|
22c937 |
Subject: Patch 7.4.613
|
|
|
22c937 |
Fcc: outbox
|
|
|
22c937 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
22c937 |
Mime-Version: 1.0
|
|
|
22c937 |
Content-Type: text/plain; charset=UTF-8
|
|
|
22c937 |
Content-Transfer-Encoding: 8bit
|
|
|
22c937 |
------------
|
|
|
22c937 |
|
|
|
22c937 |
Patch 7.4.613
|
|
|
22c937 |
Problem: The NFA engine does not implement the 'redrawtime' time limit.
|
|
|
22c937 |
Solution: Implement the time limit.
|
|
|
22c937 |
Files: src/regexp_nfa.c
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
*** ../vim-7.4.612/src/regexp_nfa.c 2015-01-27 14:54:07.944583588 +0100
|
|
|
22c937 |
--- src/regexp_nfa.c 2015-02-03 16:25:58.681726505 +0100
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 311,318 ****
|
|
|
22c937 |
static void nfa_save_listids __ARGS((nfa_regprog_T *prog, int *list));
|
|
|
22c937 |
static void nfa_restore_listids __ARGS((nfa_regprog_T *prog, int *list));
|
|
|
22c937 |
static int nfa_re_num_cmp __ARGS((long_u val, int op, long_u pos));
|
|
|
22c937 |
! static long nfa_regtry __ARGS((nfa_regprog_T *prog, colnr_T col));
|
|
|
22c937 |
! static long nfa_regexec_both __ARGS((char_u *line, colnr_T col));
|
|
|
22c937 |
static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
|
|
|
22c937 |
static void nfa_regfree __ARGS((regprog_T *prog));
|
|
|
22c937 |
static int nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
|
|
|
22c937 |
--- 311,318 ----
|
|
|
22c937 |
static void nfa_save_listids __ARGS((nfa_regprog_T *prog, int *list));
|
|
|
22c937 |
static void nfa_restore_listids __ARGS((nfa_regprog_T *prog, int *list));
|
|
|
22c937 |
static int nfa_re_num_cmp __ARGS((long_u val, int op, long_u pos));
|
|
|
22c937 |
! static long nfa_regtry __ARGS((nfa_regprog_T *prog, colnr_T col, proftime_T *tm));
|
|
|
22c937 |
! static long nfa_regexec_both __ARGS((char_u *line, colnr_T col, proftime_T *tm));
|
|
|
22c937 |
static regprog_T *nfa_regcomp __ARGS((char_u *expr, int re_flags));
|
|
|
22c937 |
static void nfa_regfree __ARGS((regprog_T *prog));
|
|
|
22c937 |
static int nfa_regexec_nl __ARGS((regmatch_T *rmp, char_u *line, colnr_T col, int line_lbr));
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 3850,3855 ****
|
|
|
22c937 |
--- 3850,3859 ----
|
|
|
22c937 |
|
|
|
22c937 |
/* Used during execution: whether a match has been found. */
|
|
|
22c937 |
static int nfa_match;
|
|
|
22c937 |
+ #ifdef FEAT_RELTIME
|
|
|
22c937 |
+ static proftime_T *nfa_time_limit;
|
|
|
22c937 |
+ static int nfa_time_count;
|
|
|
22c937 |
+ #endif
|
|
|
22c937 |
|
|
|
22c937 |
static void copy_pim __ARGS((nfa_pim_T *to, nfa_pim_T *from));
|
|
|
22c937 |
static void clear_sub __ARGS((regsub_T *sub));
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 5449,5454 ****
|
|
|
22c937 |
--- 5453,5462 ----
|
|
|
22c937 |
fast_breakcheck();
|
|
|
22c937 |
if (got_int)
|
|
|
22c937 |
return FALSE;
|
|
|
22c937 |
+ #ifdef FEAT_RELTIME
|
|
|
22c937 |
+ if (nfa_time_limit != NULL && profile_passed_limit(nfa_time_limit))
|
|
|
22c937 |
+ return FALSE;
|
|
|
22c937 |
+ #endif
|
|
|
22c937 |
|
|
|
22c937 |
nfa_match = FALSE;
|
|
|
22c937 |
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6789,6797 ****
|
|
|
22c937 |
break;
|
|
|
22c937 |
|
|
|
22c937 |
/* Allow interrupting with CTRL-C. */
|
|
|
22c937 |
! fast_breakcheck();
|
|
|
22c937 |
if (got_int)
|
|
|
22c937 |
break;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef ENABLE_LOG
|
|
|
22c937 |
--- 6797,6814 ----
|
|
|
22c937 |
break;
|
|
|
22c937 |
|
|
|
22c937 |
/* Allow interrupting with CTRL-C. */
|
|
|
22c937 |
! line_breakcheck();
|
|
|
22c937 |
if (got_int)
|
|
|
22c937 |
break;
|
|
|
22c937 |
+ #ifdef FEAT_RELTIME
|
|
|
22c937 |
+ /* Check for timeout once in a twenty times to avoid overhead. */
|
|
|
22c937 |
+ if (nfa_time_limit != NULL && ++nfa_time_count == 20)
|
|
|
22c937 |
+ {
|
|
|
22c937 |
+ nfa_time_count = 0;
|
|
|
22c937 |
+ if (profile_passed_limit(nfa_time_limit))
|
|
|
22c937 |
+ break;
|
|
|
22c937 |
+ }
|
|
|
22c937 |
+ #endif
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef ENABLE_LOG
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6818,6826 ****
|
|
|
22c937 |
* Returns <= 0 for failure, number of lines contained in the match otherwise.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static long
|
|
|
22c937 |
! nfa_regtry(prog, col)
|
|
|
22c937 |
nfa_regprog_T *prog;
|
|
|
22c937 |
colnr_T col;
|
|
|
22c937 |
{
|
|
|
22c937 |
int i;
|
|
|
22c937 |
regsubs_T subs, m;
|
|
|
22c937 |
--- 6835,6844 ----
|
|
|
22c937 |
* Returns <= 0 for failure, number of lines contained in the match otherwise.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static long
|
|
|
22c937 |
! nfa_regtry(prog, col, tm)
|
|
|
22c937 |
nfa_regprog_T *prog;
|
|
|
22c937 |
colnr_T col;
|
|
|
22c937 |
+ proftime_T *tm; /* timeout limit or NULL */
|
|
|
22c937 |
{
|
|
|
22c937 |
int i;
|
|
|
22c937 |
regsubs_T subs, m;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6831,6836 ****
|
|
|
22c937 |
--- 6849,6858 ----
|
|
|
22c937 |
#endif
|
|
|
22c937 |
|
|
|
22c937 |
reginput = regline + col;
|
|
|
22c937 |
+ #ifdef FEAT_RELTIME
|
|
|
22c937 |
+ nfa_time_limit = tm;
|
|
|
22c937 |
+ nfa_time_count = 0;
|
|
|
22c937 |
+ #endif
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef ENABLE_LOG
|
|
|
22c937 |
f = fopen(NFA_REGEXP_RUN_LOG, "a");
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 6951,6959 ****
|
|
|
22c937 |
* Returns <= 0 for failure, number of lines contained in the match otherwise.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static long
|
|
|
22c937 |
! nfa_regexec_both(line, startcol)
|
|
|
22c937 |
char_u *line;
|
|
|
22c937 |
colnr_T startcol; /* column to start looking for match */
|
|
|
22c937 |
{
|
|
|
22c937 |
nfa_regprog_T *prog;
|
|
|
22c937 |
long retval = 0L;
|
|
|
22c937 |
--- 6973,6982 ----
|
|
|
22c937 |
* Returns <= 0 for failure, number of lines contained in the match otherwise.
|
|
|
22c937 |
*/
|
|
|
22c937 |
static long
|
|
|
22c937 |
! nfa_regexec_both(line, startcol, tm)
|
|
|
22c937 |
char_u *line;
|
|
|
22c937 |
colnr_T startcol; /* column to start looking for match */
|
|
|
22c937 |
+ proftime_T *tm; /* timeout limit or NULL */
|
|
|
22c937 |
{
|
|
|
22c937 |
nfa_regprog_T *prog;
|
|
|
22c937 |
long retval = 0L;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7047,7053 ****
|
|
|
22c937 |
prog->state[i].lastlist[1] = 0;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
! retval = nfa_regtry(prog, col);
|
|
|
22c937 |
|
|
|
22c937 |
nfa_regengine.expr = NULL;
|
|
|
22c937 |
|
|
|
22c937 |
--- 7070,7076 ----
|
|
|
22c937 |
prog->state[i].lastlist[1] = 0;
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
! retval = nfa_regtry(prog, col, tm);
|
|
|
22c937 |
|
|
|
22c937 |
nfa_regengine.expr = NULL;
|
|
|
22c937 |
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7209,7215 ****
|
|
|
22c937 |
ireg_icombine = FALSE;
|
|
|
22c937 |
#endif
|
|
|
22c937 |
ireg_maxcol = 0;
|
|
|
22c937 |
! return nfa_regexec_both(line, col);
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
--- 7232,7238 ----
|
|
|
22c937 |
ireg_icombine = FALSE;
|
|
|
22c937 |
#endif
|
|
|
22c937 |
ireg_maxcol = 0;
|
|
|
22c937 |
! return nfa_regexec_both(line, col, NULL);
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7245,7251 ****
|
|
|
22c937 |
buf_T *buf; /* buffer in which to search */
|
|
|
22c937 |
linenr_T lnum; /* nr of line to start looking for match */
|
|
|
22c937 |
colnr_T col; /* column to start looking for match */
|
|
|
22c937 |
! proftime_T *tm UNUSED; /* timeout limit or NULL */
|
|
|
22c937 |
{
|
|
|
22c937 |
reg_match = NULL;
|
|
|
22c937 |
reg_mmatch = rmp;
|
|
|
22c937 |
--- 7268,7274 ----
|
|
|
22c937 |
buf_T *buf; /* buffer in which to search */
|
|
|
22c937 |
linenr_T lnum; /* nr of line to start looking for match */
|
|
|
22c937 |
colnr_T col; /* column to start looking for match */
|
|
|
22c937 |
! proftime_T *tm; /* timeout limit or NULL */
|
|
|
22c937 |
{
|
|
|
22c937 |
reg_match = NULL;
|
|
|
22c937 |
reg_mmatch = rmp;
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 7260,7266 ****
|
|
|
22c937 |
#endif
|
|
|
22c937 |
ireg_maxcol = rmp->rmm_maxcol;
|
|
|
22c937 |
|
|
|
22c937 |
! return nfa_regexec_both(NULL, col);
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef DEBUG
|
|
|
22c937 |
--- 7283,7289 ----
|
|
|
22c937 |
#endif
|
|
|
22c937 |
ireg_maxcol = rmp->rmm_maxcol;
|
|
|
22c937 |
|
|
|
22c937 |
! return nfa_regexec_both(NULL, col, tm);
|
|
|
22c937 |
}
|
|
|
22c937 |
|
|
|
22c937 |
#ifdef DEBUG
|
|
|
22c937 |
*** ../vim-7.4.612/src/version.c 2015-02-03 16:07:44.193584399 +0100
|
|
|
22c937 |
--- src/version.c 2015-02-03 16:48:54.770821421 +0100
|
|
|
22c937 |
***************
|
|
|
22c937 |
*** 743,744 ****
|
|
|
22c937 |
--- 743,746 ----
|
|
|
22c937 |
{ /* Add new patch number below this line */
|
|
|
22c937 |
+ /**/
|
|
|
22c937 |
+ 613,
|
|
|
22c937 |
/**/
|
|
|
22c937 |
|
|
|
22c937 |
--
|
|
|
22c937 |
In Joseph Heller's novel "Catch-22", the main character tries to get out of a
|
|
|
22c937 |
war by proving he is crazy. But the mere fact he wants to get out of the war
|
|
|
22c937 |
only shows he isn't crazy -- creating the original "Catch-22".
|
|
|
22c937 |
|
|
|
22c937 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
22c937 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
22c937 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
22c937 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|