summaryrefslogtreecommitdiff
path: root/src/regexp_nfa.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-05-13 15:56:51 +0200
committerBram Moolenaar <Bram@vim.org>2014-05-13 15:56:51 +0200
commitee4825331aeb3f517f8a51d0c21c743655352fb3 (patch)
tree2512c976ac45fa6f6b5ef3d06942ba7356200327 /src/regexp_nfa.c
parentbe578edae30d1292ddbf1f63518175fa45567ab8 (diff)
downloadvim-ee4825331aeb3f517f8a51d0c21c743655352fb3.zip
updated for version 7.4.289
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.
Diffstat (limited to 'src/regexp_nfa.c')
-rw-r--r--src/regexp_nfa.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 7cbfe0aee..d855df33b 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -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;
+ }
}
}