changeset 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 13fff3bf438e
children 8d7f7d198970
files src/regexp_nfa.c src/testdir/test64.in src/testdir/test64.ok src/version.c
diffstat 4 files changed, 25 insertions(+), 6 deletions(-) [+]
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");
--- 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:
 <T="">Ta 5</Title>
 <T="">Ac 7</Title>
 
+Multiline:
+abc
+def
+ghi
+xjk
+lmn
+
 Results of test64:
--- a/src/testdir/test64.ok
+++ b/src/testdir/test64.ok
@@ -705,3 +705,4 @@ 192.168.0.1
 
 <T="5">Ta 5</Title>
 <T="7">Ac 7</Title>
+ghi
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1026,
+/**/
     1025,
 /**/
     1024,