summaryrefslogtreecommitdiffstats
path: root/src/regexp.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-02-22 17:29:43 +0100
committerBram Moolenaar <Bram@vim.org>2019-02-22 17:29:43 +0100
commitcd62512c5595fa1f7a7f2c6ec1a90ea6bde3ad50 (patch)
tree75b5518db2533b2735474d126cdae88ec25e50b0 /src/regexp.c
parent72e83c1ae535e2ebc35b114d34d0a811eb62b068 (diff)
patch 8.1.0973: pattern with syntax error gives threee error messagesv8.1.0973
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.
Diffstat (limited to 'src/regexp.c')
-rw-r--r--src/regexp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/regexp.c b/src/regexp.c
index e37c065079..5c06ada1b7 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -7969,6 +7969,7 @@ vim_regcomp(char_u *expr_arg, int re_flags)
{
regprog_T *prog = NULL;
char_u *expr = expr_arg;
+ int save_called_emsg;
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.
*/
+ save_called_emsg = called_emsg;
+ called_emsg = FALSE;
if (regexp_engine != BACKTRACKING_ENGINE)
prog = nfa_regengine.regcomp(expr,
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.
* The NFA engine also fails for patterns that it can't handle well
* 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;
prog = bt_regengine.regcomp(expr, re_flags);
}
}
+ called_emsg |= save_called_emsg;
if (prog != NULL)
{