diff options
author | David Bürgin <676c7473@gmail.com> | 2015-05-14 15:41:15 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-06-13 21:38:39 -0400 |
commit | f04bc91c2ff50e5b85ec3b5838f52d0019640616 (patch) | |
tree | c2df3952cda0d780db08644fe43a008bb0884604 /src/nvim/regexp.c | |
parent | 80d61fb87be5ef96b1a28dc88699ade4aa7c83df (diff) | |
download | rneovim-f04bc91c2ff50e5b85ec3b5838f52d0019640616.tar.gz rneovim-f04bc91c2ff50e5b85ec3b5838f52d0019640616.tar.bz2 rneovim-f04bc91c2ff50e5b85ec3b5838f52d0019640616.zip |
vim-patch:7.4.593 #2657
Problem: Crash when searching for "x\{0,90000}". (Dominique Pelle)
Solution: Bail out from the NFA engine when the max limit is much higher
than the min limit.
https://github.com/vim/vim/commit/v7-4-593
See https://groups.google.com/d/msg/vim_dev/c7owwoseba8/ZETgSNZ6p10J
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r-- | src/nvim/regexp.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 3e287e590b..dddd347822 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -6984,10 +6984,12 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags) /* * First try the NFA engine, unless backtracking was requested. */ - if (regexp_engine != BACKTRACKING_ENGINE) - prog = nfa_regengine.regcomp(expr, re_flags); - else + if (regexp_engine != BACKTRACKING_ENGINE) { + prog = nfa_regengine.regcomp(expr, + re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0)); + } else { prog = bt_regengine.regcomp(expr, re_flags); + } // Check for error compiling regexp with initial engine. if (prog == NULL) { @@ -7003,15 +7005,13 @@ regprog_T *vim_regcomp(char_u *expr_arg, int re_flags) BT_REGEXP_DEBUG_LOG_NAME); } #endif - // If the NFA engine failed, try the backtracking engine. - // Disabled for now, both engines fail on the same patterns. - // Re-enable when regcomp() fails when the pattern would work better - // with the other engine. - // - // if (regexp_engine == AUTOMATIC_ENGINE) { - // prog = bt_regengine.regcomp(expr, re_flags); - // regexp_engine = BACKTRACKING_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 + // patterns, thus a retry should work. + if (regexp_engine == AUTOMATIC_ENGINE) { + regexp_engine = BACKTRACKING_ENGINE; + prog = bt_regengine.regcomp(expr, re_flags); + } } if (prog != NULL) { |