updated for version 7.4.289 v7.4.289
authorBram Moolenaar <Bram@vim.org>
Tue, 13 May 2014 13:56:51 +0000 (15:56 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 13 May 2014 13:56:51 +0000 (15:56 +0200)
Problem:    Pattern with repeated backreference does not match with new regexp
            engine. (Urtica Dioica)
Solution:   Also check the end of a submatch when deciding to put a state in
            the state list.

src/regexp_nfa.c
src/testdir/test64.in
src/testdir/test64.ok
src/version.c

index 7cbfe0aee6a7bc660453ec4d03c6ae580e90034b..d855df33bcf95a2595029aea70ee1216b95ea2c7 100644 (file)
@@ -3945,6 +3945,7 @@ copy_ze_off(to, from)
 
 /*
  * Return TRUE if "sub1" and "sub2" have the same start positions.
+ * When using back-references also check the end position.
  */
     static int
 sub_equal(sub1, sub2)
@@ -3976,6 +3977,23 @@ sub_equal(sub1, sub2)
            if (s1 != -1 && sub1->list.multi[i].start.col
                                             != sub2->list.multi[i].start.col)
                return FALSE;
+
+           if (nfa_has_backref)
+           {
+               if (i < sub1->in_use)
+                   s1 = sub1->list.multi[i].end.lnum;
+               else
+                   s1 = -1;
+               if (i < sub2->in_use)
+                   s2 = sub2->list.multi[i].end.lnum;
+               else
+                   s2 = -1;
+               if (s1 != s2)
+                   return FALSE;
+               if (s1 != -1 && sub1->list.multi[i].end.col
+                                              != sub2->list.multi[i].end.col)
+               return FALSE;
+           }
        }
     }
     else
@@ -3992,6 +4010,19 @@ sub_equal(sub1, sub2)
                sp2 = NULL;
            if (sp1 != sp2)
                return FALSE;
+           if (nfa_has_backref)
+           {
+               if (i < sub1->in_use)
+                   sp1 = sub1->list.line[i].end;
+               else
+                   sp1 = NULL;
+               if (i < sub2->in_use)
+                   sp2 = sub2->list.line[i].end;
+               else
+                   sp2 = NULL;
+               if (sp1 != sp2)
+                   return FALSE;
+           }
        }
     }
 
index 29bf0b902b14383a7d837277cddbe6d4106aa85b..e3f5d82a4ddfbae18ab034b7db486ce5b6b763e7 100644 (file)
@@ -407,6 +407,7 @@ STARTTEST
 :call add(tl, [2, '^.*\.\(.*\)/.\+\(\1\)\@<=$', 'foo.bat/foo.bat', 'foo.bat/foo.bat', 'bat', 'bat'])
 :call add(tl, [2, '\\\@<!\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}', '2013-06-27${0}', '${0}', '0'])
 :call add(tl, [2, '^\(a*\)\1$', 'aaaaaaaa', 'aaaaaaaa', 'aaaa'])
+:call add(tl, [2, '^\(a\{-2,}\)\1\+$', 'aaaaaaaaa', 'aaaaaaaaa', 'aaa'])
 :"
 :"""" Look-behind with limit
 :call add(tl, [2, '<\@<=span.', 'xxspanxx<spanyyy', 'spany'])
index a1498ea5d69ea6e7856ede495686e13477b62e83..9fb6c60b9dc0d4561f84717e80af07d3550712f8 100644 (file)
@@ -947,6 +947,9 @@ OK 2 - \\\@<!\${\(\d\+\%(:.\{-}\)\?\\\@<!\)}
 OK 0 - ^\(a*\)\1$
 OK 1 - ^\(a*\)\1$
 OK 2 - ^\(a*\)\1$
+OK 0 - ^\(a\{-2,}\)\1\+$
+OK 1 - ^\(a\{-2,}\)\1\+$
+OK 2 - ^\(a\{-2,}\)\1\+$
 OK 0 - <\@<=span.
 OK 1 - <\@<=span.
 OK 2 - <\@<=span.
index 13c5ec9433ba2816d10068d5d427daaca69a86eb..81ce691f90636824df360faabbbba89c47ac1476 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    289,
 /**/
     288,
 /**/