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.
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index df5be11..9029460 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -3585,12 +3585,15 @@
} /* 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 8d0f535..d30d76d 100644
--- a/src/testdir/test64.in
+++ b/src/testdir/test64.in
@@ -372,6 +372,12 @@
:.+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 @@
<T="">Ta 5</Title>
<T="">Ac 7</Title>
+Multiline:
+abc
+def
+ghi
+xjk
+lmn
+
Results of test64:
diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok
index 40b02cd..c6733ca 100644
--- a/src/testdir/test64.ok
+++ b/src/testdir/test64.ok
@@ -705,3 +705,4 @@
<T="5">Ta 5</Title>
<T="7">Ac 7</Title>
+ghi
diff --git a/src/version.c b/src/version.c
index a44b1e2..51d86af 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1026,
+/**/
1025,
/**/
1024,