Mercurial > vim
diff src/regexp_nfa.c @ 4557:888c12c899e5 v7.3.1026
updated for version 7.3.1026
Problem: New regexp: pattern that includs a new-line matches too early.
(john McGowan)
Solution: Do not start searching in the second line.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 26 May 2013 18:40:14 +0200 |
parents | b2946c06d1b6 |
children | 04086e297563 |
line wrap: on
line diff
--- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -3585,12 +3585,15 @@ nfa_regmatch(start, submatch, m) } /* for (thislist = thislist; thislist->state; thislist++) */ - /* The first found match is the leftmost one, but there may be a - * longer one. Keep running the NFA, but don't start from the - * beginning. Also, do not add the start state in recursive calls of - * nfa_regmatch(), because recursive calls should only start in the - * first position. */ - if (match == FALSE && start->c == NFA_MOPEN + 0) + /* Look for the start of a match in the current position by adding the + * start state to the list of states. + * The first found match is the leftmost one, thus the order of states + * matters! + * Do not add the start state in recursive calls of nfa_regmatch(), + * because recursive calls should only start in the first position. + * Also don't start a match past the first line. */ + if (match == FALSE && start->c == NFA_MOPEN + 0 + && reglnum == 0 && clen != 0) { #ifdef ENABLE_LOG fprintf(log_fd, "(---) STARTSTATE\n");