From e23febdb857c0b0e297128d80bdde12240056653 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 26 May 2013 18:40:14 +0200 Subject: 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. --- src/regexp_nfa.c | 15 +++++++++------ src/testdir/test64.in | 13 +++++++++++++ src/testdir/test64.ok | 1 + src/version.c | 2 ++ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index df5be1100..9029460f8 100644 --- 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"); diff --git a/src/testdir/test64.in b/src/testdir/test64.in index 8d0f53597..d30d76d93 100644 --- a/src/testdir/test64.in +++ b/src/testdir/test64.in @@ -372,6 +372,12 @@ y$Gop:" :.+1,.+2yank Gop:" :" +:" Check a pattern with a line break matches in the right position. +/^Multiline +/\S.*\nx +:.yank +y$Gop:" +:" :" :/\%#=1^Results/,$wq! test.out ENDTEST @@ -383,4 +389,11 @@ Substitute here: Ta 5 Ac 7 +Multiline: +abc +def +ghi +xjk +lmn + Results of test64: diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok index 40b02cdfa..c6733ca3d 100644 --- a/src/testdir/test64.ok +++ b/src/testdir/test64.ok @@ -705,3 +705,4 @@ OK 2 - \Ta 5 Ac 7 +ghi diff --git a/src/version.c b/src/version.c index a44b1e298..51d86af5b 100644 --- a/src/version.c +++ b/src/version.c @@ -728,6 +728,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1026, /**/ 1025, /**/ -- cgit v1.2.1