0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.0035: saving and restoring called_emsg is clumsy

Problem:    Saving and restoring called_emsg is clumsy.
Solution:   Count the number of error messages.
This commit is contained in:
Bram Moolenaar
2019-12-23 22:59:18 +01:00
parent 70188f5b23
commit 53989554a4
13 changed files with 32 additions and 51 deletions

View File

@@ -2556,7 +2556,7 @@ vim_regcomp(char_u *expr_arg, int re_flags)
{
regprog_T *prog = NULL;
char_u *expr = expr_arg;
int save_called_emsg;
int called_emsg_before;
regexp_engine = p_re;
@@ -2592,8 +2592,7 @@ vim_regcomp(char_u *expr_arg, int re_flags)
/*
* First try the NFA engine, unless backtracking was requested.
*/
save_called_emsg = called_emsg;
called_emsg = FALSE;
called_emsg_before = called_emsg;
if (regexp_engine != BACKTRACKING_ENGINE)
prog = nfa_regengine.regcomp(expr,
re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0));
@@ -2624,13 +2623,13 @@ vim_regcomp(char_u *expr_arg, int re_flags)
* 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 && !called_emsg)
if (regexp_engine == AUTOMATIC_ENGINE
&& called_emsg == called_emsg_before)
{
regexp_engine = BACKTRACKING_ENGINE;
prog = bt_regengine.regcomp(expr, re_flags);
}
}
called_emsg |= save_called_emsg;
if (prog != NULL)
{