mirror of
https://github.com/neovim/neovim.git
synced 2025-09-26 21:18:34 +00:00
vim-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.
cd62512c55
This commit is contained in:
@@ -7090,6 +7090,7 @@ regprog_T *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;
|
||||||
|
|
||||||
@@ -7116,9 +7117,11 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
bt_regengine.expr = expr;
|
bt_regengine.expr = expr;
|
||||||
nfa_regengine.expr = expr;
|
nfa_regengine.expr = expr;
|
||||||
|
|
||||||
/*
|
//
|
||||||
* 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));
|
||||||
@@ -7143,11 +7146,13 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags)
|
|||||||
// If the NFA engine failed, try the backtracking engine. The NFA engine
|
// If the NFA engine failed, try the backtracking engine. The NFA engine
|
||||||
// also fails for patterns that it can't handle well but are still valid
|
// also fails for patterns that it can't handle well but are still valid
|
||||||
// patterns, thus a retry should work.
|
// patterns, thus a retry should work.
|
||||||
if (regexp_engine == AUTOMATIC_ENGINE) {
|
// But don't try if an error message was given.
|
||||||
|
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) {
|
||||||
// Store the info needed to call regcomp() again when the engine turns out
|
// Store the info needed to call regcomp() again when the engine turns out
|
||||||
|
@@ -6476,16 +6476,10 @@ static regprog_T *nfa_regcomp(char_u *expr, int re_flags)
|
|||||||
|
|
||||||
nfa_regcomp_start(expr, re_flags);
|
nfa_regcomp_start(expr, re_flags);
|
||||||
|
|
||||||
/* Build postfix form of the regexp. Needed to build the NFA
|
// Build postfix form of the regexp. Needed to build the NFA
|
||||||
* (and count its size). */
|
// (and count its size).
|
||||||
postfix = re2post();
|
postfix = re2post();
|
||||||
if (postfix == NULL) {
|
if (postfix == NULL) {
|
||||||
// TODO(vim): only give this error for debugging?
|
|
||||||
if (post_ptr >= post_end) {
|
|
||||||
IEMSGN("Internal error: estimated max number "
|
|
||||||
"of states insufficient: %" PRId64,
|
|
||||||
post_end - post_start);
|
|
||||||
}
|
|
||||||
goto fail; // Cascaded (syntax?) error
|
goto fail; // Cascaded (syntax?) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -580,3 +580,8 @@ func Test_large_hex_chars2()
|
|||||||
endtry
|
endtry
|
||||||
set re&
|
set re&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_one_error_msg()
|
||||||
|
" This was also giving an internal error
|
||||||
|
call assert_fails('call search(" \\((\\v[[=P=]]){185}+ ")', 'E871:')
|
||||||
|
endfunc
|
||||||
|
Reference in New Issue
Block a user