1
0
forked from aniani/vim

updated for version 7.4.021

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.
This commit is contained in:
Bram Moolenaar
2013-09-05 21:15:44 +02:00
parent 78c93e4b6a
commit 9be4481892
4 changed files with 10 additions and 3 deletions

View File

@@ -4209,10 +4209,11 @@ skip_add:
break; break;
case NFA_MCLOSE: 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 /* Do not overwrite the position set by \ze. */
* encountered end will be set in nfa_regtry(). */
subs = addstate(l, state->out, subs, pim, off); subs = addstate(l, state->out, subs, pim, off);
break; break;
} }

View File

@@ -328,6 +328,7 @@ STARTTEST
:call add(tl, [2, 'abc \zsmatch\ze abc', 'abc abc abc match abc abc', 'match']) :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, '\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, '\>\zs.', 'aword. ', '.'])
:call add(tl, [2, '\s\+\ze\[/\|\s\zs\s\+', 'is [a t', ' '])
:" :"
:"""" Tests for \@= and \& features :"""" Tests for \@= and \& features
:call add(tl, [2, 'abc\@=', 'abc', 'ab']) :call add(tl, [2, 'abc\@=', 'abc', 'ab'])

View File

@@ -752,6 +752,9 @@ OK 2 - \v(a \zsif .*){2}
OK 0 - \>\zs. OK 0 - \>\zs.
OK 1 - \>\zs. OK 1 - \>\zs.
OK 2 - \>\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 0 - abc\@=
OK 1 - abc\@= OK 1 - abc\@=
OK 2 - abc\@= OK 2 - abc\@=

View File

@@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
21,
/**/ /**/
20, 20,
/**/ /**/