diff options
author | Bram Moolenaar <bram@vim.org> | 2013-09-05 21:15:44 +0200 |
---|---|---|
committer | Bram Moolenaar <bram@vim.org> | 2013-09-05 21:15:44 +0200 |
commit | 9f793db2d4d5144ec20011d143ab39b93afad352 (patch) | |
tree | fa946078d0632710ff645401ae6508ece2a81377 | |
parent | 679af6e8c620d6548e7686f13fc5b0b8fd2ab1c5 (diff) | |
download | vim-9f793db2d4d5144ec20011d143ab39b93afad352.tar.gz |
Problem: NFA regexp: Using \ze in one branch which doesn't match may cause
end of another branch to be wrong. (William Fugh)
Solution: Set end position if it wasn't set yet.
-rw-r--r-- | src/regexp_nfa.c | 7 | ||||
-rw-r--r-- | src/testdir/test64.in | 1 | ||||
-rw-r--r-- | src/testdir/test64.ok | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 10 insertions, 3 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c index fe1d0258..30aae8dc 100644 --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4209,10 +4209,11 @@ skip_add: break; case NFA_MCLOSE: - if (nfa_has_zend) + if (nfa_has_zend && (REG_MULTI + ? subs->norm.list.multi[0].end.lnum >= 0 + : subs->norm.list.line[0].end != NULL)) { - /* Do not overwrite the position set by \ze. If no \ze - * encountered end will be set in nfa_regtry(). */ + /* Do not overwrite the position set by \ze. */ subs = addstate(l, state->out, subs, pim, off); break; } diff --git a/src/testdir/test64.in b/src/testdir/test64.in index 8f7008c1..e694995c 100644 --- a/src/testdir/test64.in +++ b/src/testdir/test64.in @@ -328,6 +328,7 @@ STARTTEST :call add(tl, [2, 'abc \zsmatch\ze abc', 'abc abc abc match abc abc', 'match']) :call add(tl, [2, '\v(a \zsif .*){2}', 'a if then a if last', 'if last', 'a if last']) :call add(tl, [2, '\>\zs.', 'aword. ', '.']) +:call add(tl, [2, '\s\+\ze\[/\|\s\zs\s\+', 'is [a t', ' ']) :" :"""" Tests for \@= and \& features :call add(tl, [2, 'abc\@=', 'abc', 'ab']) diff --git a/src/testdir/test64.ok b/src/testdir/test64.ok index fa83f91a..3d117b99 100644 --- a/src/testdir/test64.ok +++ b/src/testdir/test64.ok @@ -752,6 +752,9 @@ OK 2 - \v(a \zsif .*){2} OK 0 - \>\zs. OK 1 - \>\zs. OK 2 - \>\zs. +OK 0 - \s\+\ze\[/\|\s\zs\s\+ +OK 1 - \s\+\ze\[/\|\s\zs\s\+ +OK 2 - \s\+\ze\[/\|\s\zs\s\+ OK 0 - abc\@= OK 1 - abc\@= OK 2 - abc\@= diff --git a/src/version.c b/src/version.c index 99c9d222..06bcaa3e 100644 --- a/src/version.c +++ b/src/version.c @@ -739,6 +739,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 21, +/**/ 20, /**/ 19, |