Skip to content

Commit ac58a6b

Browse files
committed
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.
1 parent e14e2bd commit ac58a6b

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/regexp_nfa.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4209,10 +4209,11 @@ addstate(l, state, subs_arg, pim, off)
42094209
break;
42104210

42114211
case NFA_MCLOSE:
4212-
if (nfa_has_zend)
4212+
if (nfa_has_zend && (REG_MULTI
4213+
? subs->norm.list.multi[0].end.lnum >= 0
4214+
: subs->norm.list.line[0].end != NULL))
42134215
{
4214-
/* Do not overwrite the position set by \ze. If no \ze
4215-
* encountered end will be set in nfa_regtry(). */
4216+
/* Do not overwrite the position set by \ze. */
42164217
subs = addstate(l, state->out, subs, pim, off);
42174218
break;
42184219
}

src/testdir/test64.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ STARTTEST
328328
:call add(tl, [2, 'abc \zsmatch\ze abc', 'abc abc abc match abc abc', 'match'])
329329
:call add(tl, [2, '\v(a \zsif .*){2}', 'a if then a if last', 'if last', 'a if last'])
330330
:call add(tl, [2, '\>\zs.', 'aword. ', '.'])
331+
:call add(tl, [2, '\s\+\ze\[/\|\s\zs\s\+', 'is [a t', ' '])
331332
:"
332333
:"""" Tests for \@= and \& features
333334
:call add(tl, [2, 'abc\@=', 'abc', 'ab'])

src/testdir/test64.ok

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,9 @@ OK 2 - \v(a \zsif .*){2}
752752
OK 0 - \>\zs.
753753
OK 1 - \>\zs.
754754
OK 2 - \>\zs.
755+
OK 0 - \s\+\ze\[/\|\s\zs\s\+
756+
OK 1 - \s\+\ze\[/\|\s\zs\s\+
757+
OK 2 - \s\+\ze\[/\|\s\zs\s\+
755758
OK 0 - abc\@=
756759
OK 1 - abc\@=
757760
OK 2 - abc\@=

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
21,
741743
/**/
742744
20,
743745
/**/

0 commit comments

Comments
 (0)