Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
6532:357f273b9cbd | 6533:bdc8e71633e4 |
---|---|
8079 | 8079 |
8080 /* | 8080 /* |
8081 * First try the NFA engine, unless backtracking was requested. | 8081 * First try the NFA engine, unless backtracking was requested. |
8082 */ | 8082 */ |
8083 if (regexp_engine != BACKTRACKING_ENGINE) | 8083 if (regexp_engine != BACKTRACKING_ENGINE) |
8084 prog = nfa_regengine.regcomp(expr, re_flags); | 8084 prog = nfa_regengine.regcomp(expr, |
8085 re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0)); | |
8085 else | 8086 else |
8086 prog = bt_regengine.regcomp(expr, re_flags); | 8087 prog = bt_regengine.regcomp(expr, re_flags); |
8087 | 8088 |
8088 /* Check for error compiling regexp with initial engine. */ | 8089 /* Check for error compiling regexp with initial engine. */ |
8089 if (prog == NULL) | 8090 if (prog == NULL) |
8103 BT_REGEXP_DEBUG_LOG_NAME); | 8104 BT_REGEXP_DEBUG_LOG_NAME); |
8104 } | 8105 } |
8105 #endif | 8106 #endif |
8106 /* | 8107 /* |
8107 * If the NFA engine failed, try the backtracking engine. | 8108 * If the NFA engine failed, try the backtracking engine. |
8108 * Disabled for now, both engines fail on the same patterns. | 8109 * The NFA engine also fails for patterns that it can't handle well |
8109 * Re-enable when regcomp() fails when the pattern would work better | 8110 * but are still valid patterns, thus a retry should work. |
8110 * with the other engine. | 8111 */ |
8111 * | |
8112 if (regexp_engine == AUTOMATIC_ENGINE) | 8112 if (regexp_engine == AUTOMATIC_ENGINE) |
8113 { | 8113 { |
8114 regexp_engine = BACKTRACKING_ENGINE; | |
8114 prog = bt_regengine.regcomp(expr, re_flags); | 8115 prog = bt_regengine.regcomp(expr, re_flags); |
8115 regexp_engine == BACKTRACKING_ENGINE; | |
8116 } | 8116 } |
8117 */ | |
8118 } | 8117 } |
8119 | 8118 |
8120 if (prog != NULL) | 8119 if (prog != NULL) |
8121 { | 8120 { |
8122 /* Store the info needed to call regcomp() again when the engine turns | 8121 /* Store the info needed to call regcomp() again when the engine turns |