diff options
author | oni-link <knil.ino@gmail.com> | 2014-05-22 12:25:46 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-06-05 18:42:15 -0400 |
commit | 2085acf478725cda653219d2898190df233a15b8 (patch) | |
tree | 2781d3d3bfb0cc282a91de95b534ed64415bd0b1 /src/nvim/regexp_nfa.c | |
parent | 8638578bf3513dac4bdc1a07a2bc8ee3846d716e (diff) | |
download | rneovim-2085acf478725cda653219d2898190df233a15b8.tar.gz rneovim-2085acf478725cda653219d2898190df233a15b8.tar.bz2 rneovim-2085acf478725cda653219d2898190df233a15b8.zip |
vim-patch:7.4.289 #752
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.
https://code.google.com/p/vim/source/detail?r=99374096a76b96d1128f5e6aa1fa92b4ba70fee9
Diffstat (limited to 'src/nvim/regexp_nfa.c')
-rw-r--r-- | src/nvim/regexp_nfa.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 2926206ba7..a4e7f1df13 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -3516,9 +3516,8 @@ static void copy_ze_off(regsub_T *to, regsub_T *from) } } -/* - * Return TRUE if "sub1" and "sub2" have the same start positions. - */ +// Return TRUE if "sub1" and "sub2" have the same start positions. +// When using back-references also check the end position. static int sub_equal(regsub_T *sub1, regsub_T *sub2) { int i; @@ -3544,6 +3543,26 @@ static int sub_equal(regsub_T *sub1, regsub_T *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 { for (i = 0; i < todo; ++i) { @@ -3557,6 +3576,22 @@ static int sub_equal(regsub_T *sub1, regsub_T *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; + } + } } } |