mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
patch 8.1.0973: pattern with syntax error gives threee error messages
Problem: Pattern with syntax error gives threee error messages. (Kuang-che Wu) Solution: Remove outdated internal error. Don't fall back to other engine after an error.
This commit is contained in:
parent
72e83c1ae5
commit
cd62512c55
@ -7969,6 +7969,7 @@ vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
{
|
{
|
||||||
regprog_T *prog = NULL;
|
regprog_T *prog = NULL;
|
||||||
char_u *expr = expr_arg;
|
char_u *expr = expr_arg;
|
||||||
|
int save_called_emsg;
|
||||||
|
|
||||||
regexp_engine = p_re;
|
regexp_engine = p_re;
|
||||||
|
|
||||||
@ -8004,6 +8005,8 @@ vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
/*
|
/*
|
||||||
* First try the NFA engine, unless backtracking was requested.
|
* First try the NFA engine, unless backtracking was requested.
|
||||||
*/
|
*/
|
||||||
|
save_called_emsg = called_emsg;
|
||||||
|
called_emsg = FALSE;
|
||||||
if (regexp_engine != BACKTRACKING_ENGINE)
|
if (regexp_engine != BACKTRACKING_ENGINE)
|
||||||
prog = nfa_regengine.regcomp(expr,
|
prog = nfa_regengine.regcomp(expr,
|
||||||
re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
|
re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
|
||||||
@ -8032,13 +8035,15 @@ vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
* If the NFA engine failed, try the backtracking engine.
|
* If the NFA engine failed, try the backtracking engine.
|
||||||
* The NFA engine also fails for patterns that it can't handle well
|
* The NFA engine also fails for patterns that it can't handle well
|
||||||
* but are still valid patterns, thus a retry should work.
|
* but are still valid patterns, thus a retry should work.
|
||||||
|
* But don't try if an error message was given.
|
||||||
*/
|
*/
|
||||||
if (regexp_engine == AUTOMATIC_ENGINE)
|
if (regexp_engine == AUTOMATIC_ENGINE && !called_emsg)
|
||||||
{
|
{
|
||||||
regexp_engine = BACKTRACKING_ENGINE;
|
regexp_engine = BACKTRACKING_ENGINE;
|
||||||
prog = bt_regengine.regcomp(expr, re_flags);
|
prog = bt_regengine.regcomp(expr, re_flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
called_emsg |= save_called_emsg;
|
||||||
|
|
||||||
if (prog != NULL)
|
if (prog != NULL)
|
||||||
{
|
{
|
||||||
|
@ -7252,12 +7252,7 @@ nfa_regcomp(char_u *expr, int re_flags)
|
|||||||
* (and count its size). */
|
* (and count its size). */
|
||||||
postfix = re2post();
|
postfix = re2post();
|
||||||
if (postfix == NULL)
|
if (postfix == NULL)
|
||||||
{
|
|
||||||
/* TODO: only give this error for debugging? */
|
|
||||||
if (post_ptr >= post_end)
|
|
||||||
siemsg("Internal error: estimated max number of states insufficient: %ld", post_end - post_start);
|
|
||||||
goto fail; /* Cascaded (syntax?) error */
|
goto fail; /* Cascaded (syntax?) error */
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In order to build the NFA, we parse the input regexp twice:
|
* In order to build the NFA, we parse the input regexp twice:
|
||||||
|
@ -1220,3 +1220,8 @@ func Test_large_hex_chars()
|
|||||||
call assert_match('E678:', v:exception)
|
call assert_match('E678:', v:exception)
|
||||||
endtry
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_one_error_msg()
|
||||||
|
" This was also giving an internal error
|
||||||
|
call assert_fails('call search(" \\((\\v[[=P=]]){185}+ ")', 'E871:')
|
||||||
|
endfunc
|
||||||
|
@ -779,6 +779,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
973,
|
||||||
/**/
|
/**/
|
||||||
972,
|
972,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user