diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-28 19:26:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-28 19:26:19 +0800 |
commit | 081eb72a80afd83398465382171765bdeaf6dba5 (patch) | |
tree | 9e4f10f979e9889b8bd59d3e9ddf3664c8ef09be | |
parent | 0dd3798dbb3fdc058b69262bf2deb56917e701fd (diff) | |
download | rneovim-081eb72a80afd83398465382171765bdeaf6dba5.tar.gz rneovim-081eb72a80afd83398465382171765bdeaf6dba5.tar.bz2 rneovim-081eb72a80afd83398465382171765bdeaf6dba5.zip |
refactor(regexp_nfa.c): match where Vim calls fopen() (#18778)
-rw-r--r-- | src/nvim/regexp_nfa.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index d867b5db95..1e8204085c 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -5948,30 +5948,24 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm int add_off = 0; int toplevel = start->c == NFA_MOPEN; regsubs_T *r; -#ifdef NFA_REGEXP_DEBUG_LOG - FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); - - if (debug == NULL) { - semsg("(NFA) COULD NOT OPEN %s!", NFA_REGEXP_DEBUG_LOG); - return false; - } -#endif // Some patterns may take a long time to match, especially when using // recursive_regmatch(). Allow interrupting them with CTRL-C. fast_breakcheck(); if (got_int) { -#ifdef NFA_REGEXP_DEBUG_LOG - fclose(debug); -#endif return false; } if (nfa_did_time_out()) { -#ifdef NFA_REGEXP_DEBUG_LOG - fclose(debug); -#endif return false; } +#ifdef NFA_REGEXP_DEBUG_LOG + FILE *debug = fopen(NFA_REGEXP_DEBUG_LOG, "a"); + + if (debug == NULL) { + semsg("(NFA) COULD NOT OPEN %s!", NFA_REGEXP_DEBUG_LOG); + return false; + } +#endif nfa_match = false; // Allocate memory for the lists of nodes. |