Mercurial > vim
diff src/regexp.c @ 6533:bdc8e71633e4 v7.4.593
updated for version 7.4.593
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.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 27 Jan 2015 12:59:55 +0100 |
parents | 230b52b9d35e |
children | eefee03a37fe |
line wrap: on
line diff
--- a/src/regexp.c +++ b/src/regexp.c @@ -8081,7 +8081,8 @@ vim_regcomp(expr_arg, re_flags) * First try the NFA engine, unless backtracking was requested. */ if (regexp_engine != BACKTRACKING_ENGINE) - prog = nfa_regengine.regcomp(expr, re_flags); + prog = nfa_regengine.regcomp(expr, + re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0)); else prog = bt_regengine.regcomp(expr, re_flags); @@ -8105,16 +8106,14 @@ vim_regcomp(expr_arg, re_flags) #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. - * + * 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); - regexp_engine == BACKTRACKING_ENGINE; } - */ } if (prog != NULL)