mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0646: the hlsearch test fails on fast systems
Problem: The hlsearch test fails on fast systems.
Solution: Make the search pattern slower. Fix that the old regexp engine
doesn't timeout properly.
0946326580
This commit is contained in:
parent
fbd8209286
commit
0a471e009a
@ -3496,7 +3496,7 @@ static long bt_regexec_both(char_u *line,
|
||||
&& (utf_fold(prog->regstart) == utf_fold(c)
|
||||
|| (c < 255 && prog->regstart < 255
|
||||
&& mb_tolower(prog->regstart) == mb_tolower(c))))) {
|
||||
retval = regtry(prog, col);
|
||||
retval = regtry(prog, col, tm, timed_out);
|
||||
} else {
|
||||
retval = 0;
|
||||
}
|
||||
@ -3520,9 +3520,10 @@ static long bt_regexec_both(char_u *line,
|
||||
break;
|
||||
}
|
||||
|
||||
retval = regtry(prog, col);
|
||||
if (retval > 0)
|
||||
retval = regtry(prog, col, tm, timed_out);
|
||||
if (retval > 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* if not currently on the first line, get it again */
|
||||
if (reglnum != 0) {
|
||||
@ -3603,7 +3604,8 @@ void unref_extmatch(reg_extmatch_T *em)
|
||||
* regtry - try match of "prog" with at regline["col"].
|
||||
* Returns 0 for failure, number of lines contained in the match otherwise.
|
||||
*/
|
||||
static long regtry(bt_regprog_T *prog, colnr_T col)
|
||||
static long regtry(bt_regprog_T *prog, colnr_T col,
|
||||
proftime_T *tm, int *timed_out)
|
||||
{
|
||||
reginput = regline + col;
|
||||
need_clear_subexpr = TRUE;
|
||||
@ -3611,8 +3613,9 @@ static long regtry(bt_regprog_T *prog, colnr_T col)
|
||||
if (prog->reghasz == REX_SET)
|
||||
need_clear_zsubexpr = TRUE;
|
||||
|
||||
if (regmatch(prog->program + 1) == 0)
|
||||
if (regmatch(prog->program + 1, tm, timed_out) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
cleanup_subexpr();
|
||||
if (REG_MULTI) {
|
||||
@ -3768,9 +3771,11 @@ static long bl_maxval;
|
||||
* Returns FALSE when there is no match. Leaves reginput and reglnum in an
|
||||
* undefined state!
|
||||
*/
|
||||
static int
|
||||
regmatch (
|
||||
char_u *scan /* Current node. */
|
||||
static int
|
||||
regmatch(
|
||||
char_u *scan, // Current node.
|
||||
proftime_T *tm,
|
||||
int *timed_out
|
||||
)
|
||||
{
|
||||
char_u *next; /* Next node. */
|
||||
@ -3779,12 +3784,14 @@ regmatch (
|
||||
regitem_T *rp;
|
||||
int no;
|
||||
int status; /* one of the RA_ values: */
|
||||
int tm_count; /* counter for checking timeout */
|
||||
#define RA_FAIL 1 /* something failed, abort */
|
||||
#define RA_CONT 2 /* continue in inner loop */
|
||||
#define RA_BREAK 3 /* break inner loop */
|
||||
#define RA_MATCH 4 /* successful match */
|
||||
#define RA_NOMATCH 5 /* didn't match */
|
||||
|
||||
tm_count = 0;
|
||||
/* Make "regstack" and "backpos" empty. They are allocated and freed in
|
||||
* bt_regexec_both() to reduce malloc()/free() calls. */
|
||||
regstack.ga_len = 0;
|
||||
@ -3814,6 +3821,13 @@ regmatch (
|
||||
status = RA_FAIL;
|
||||
break;
|
||||
}
|
||||
if (tm != NULL && ++tm_count == 100) {
|
||||
tm_count = 0;
|
||||
if (profile_passed_limit(*tm)) {
|
||||
status = RA_FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
status = RA_CONT;
|
||||
|
||||
#ifdef REGEXP_DEBUG
|
||||
|
@ -38,7 +38,8 @@ func Test_hlsearch_hangs()
|
||||
endif
|
||||
|
||||
" This pattern takes a long time to match, it should timeout.
|
||||
help
|
||||
new
|
||||
call setline(1, ['aaa', repeat('abc ', 100000), 'ccc'])
|
||||
let start = reltime()
|
||||
set hlsearch nolazyredraw redrawtime=101
|
||||
let @/ = '\%#=1a*.*X\@<=b*'
|
||||
@ -47,7 +48,7 @@ func Test_hlsearch_hangs()
|
||||
call assert_true(elapsed > 0.1)
|
||||
call assert_true(elapsed < 1.0)
|
||||
set nohlsearch redrawtime&
|
||||
quit
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_hlsearch_eol_highlight()
|
||||
|
Loading…
Reference in New Issue
Block a user