# HG changeset patch # User Bram Moolenaar # Date 1370182030 -7200 # Node ID 08fbb1ce1bc56e3884c5d35106df31a9cae1f954 # Parent 36da87ebfdfe698f41eac9d800610306b84502ec updated for version 7.3.1093 Problem: New regexp engine: When a sub expression is empty \1 skips a character. Solution: Make \1 try the current position when the match is emtpy. diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c --- a/src/regexp_nfa.c +++ b/src/regexp_nfa.c @@ -4435,11 +4435,10 @@ nfa_regmatch(start, submatch, m, endp) { if (bytelen == 0) { - /* empty match always works, add NFA_SKIP with zero to - * be used next */ - addstate_here(thislist, t->state->out, &t->subs, + /* empty match always works, output of NFA_SKIP to be + * used next */ + addstate_here(thislist, t->state->out->out, &t->subs, &listidx); - thislist->t[listidx + 1].count = 0; } else if (bytelen <= clen) { diff --git a/src/testdir/test64.in b/src/testdir/test64.in --- a/src/testdir/test64.in +++ b/src/testdir/test64.in @@ -361,6 +361,7 @@ STARTTEST :call add(tl, [2, '\(\i\+\) \1', ' abc abc', 'abc abc', 'abc']) :call add(tl, [2, '\(\i\+\) \1', 'xgoo goox', 'goo goo', 'goo']) :call add(tl, [2, '\(a\)\(b\)\(c\)\(dd\)\(e\)\(f\)\(g\)\(h\)\(i\)\1\2\3\4\5\6\7\8\9', 'xabcddefghiabcddefghix', 'abcddefghiabcddefghi', 'a', 'b', 'c', 'dd', 'e', 'f', 'g', 'h', 'i']) +:call add(tl, [2, '\(\d*\)a \1b', ' a b ', 'a b', '']) :" :"""" Look-behind with limit :call add(tl, [2, '<\@<=span.', 'xxspanxx