forked from aniani/vim
updated for version 7.3.1078
Problem: New regexp engine: \@! doesn't work. Solution: Implement the negated version of \@=.
This commit is contained in:
@@ -1390,6 +1390,9 @@ nfa_regpiece()
|
|||||||
case '=':
|
case '=':
|
||||||
EMIT(NFA_PREV_ATOM_NO_WIDTH);
|
EMIT(NFA_PREV_ATOM_NO_WIDTH);
|
||||||
break;
|
break;
|
||||||
|
case '!':
|
||||||
|
EMIT(NFA_PREV_ATOM_NO_WIDTH_NEG);
|
||||||
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
@@ -1400,7 +1403,6 @@ nfa_regpiece()
|
|||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
case '!':
|
|
||||||
case '<':
|
case '<':
|
||||||
case '>':
|
case '>':
|
||||||
/* Not supported yet */
|
/* Not supported yet */
|
||||||
@@ -2373,7 +2375,9 @@ post2nfa(postfix, end, nfa_calc_size)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NFA_PREV_ATOM_NO_WIDTH:
|
case NFA_PREV_ATOM_NO_WIDTH:
|
||||||
|
case NFA_PREV_ATOM_NO_WIDTH_NEG:
|
||||||
/* The \@= operator: match the preceding atom with zero width.
|
/* The \@= operator: match the preceding atom with zero width.
|
||||||
|
* The \@! operator: no match for the preceding atom.
|
||||||
* Surrounds the preceding atom with START_INVISIBLE and
|
* Surrounds the preceding atom with START_INVISIBLE and
|
||||||
* END_INVISIBLE, similarly to MOPEN. */
|
* END_INVISIBLE, similarly to MOPEN. */
|
||||||
|
|
||||||
@@ -2391,6 +2395,12 @@ post2nfa(postfix, end, nfa_calc_size)
|
|||||||
s = new_state(NFA_START_INVISIBLE, e.start, s1);
|
s = new_state(NFA_START_INVISIBLE, e.start, s1);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
goto theend;
|
goto theend;
|
||||||
|
if (*p == NFA_PREV_ATOM_NO_WIDTH_NEG)
|
||||||
|
{
|
||||||
|
s->negated = TRUE;
|
||||||
|
s1->negated = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
PUSH(frag(s, list1(&s1->out)));
|
PUSH(frag(s, list1(&s1->out)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -3541,8 +3551,10 @@ nfa_regmatch(start, submatch, m)
|
|||||||
addstate_here(thislist, t->state->out, &t->sub, &listidx);
|
addstate_here(thislist, t->state->out, &t->sub, &listidx);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* TODO: only copy positions in use. */
|
/* do not set submatches for \@! */
|
||||||
*m = t->sub;
|
if (!t->state->negated)
|
||||||
|
/* TODO: only copy positions in use. */
|
||||||
|
*m = t->sub;
|
||||||
nfa_match = TRUE;
|
nfa_match = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3593,7 +3605,8 @@ nfa_regmatch(start, submatch, m)
|
|||||||
log_fd = stderr;
|
log_fd = stderr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (result == TRUE)
|
/* for \@! it is a match when result is FALSE */
|
||||||
|
if (result != t->state->negated)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
|
@@ -303,13 +303,20 @@ STARTTEST
|
|||||||
:" will never match
|
:" will never match
|
||||||
:call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
|
:call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
|
||||||
:call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
|
:call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
|
||||||
:" no match
|
|
||||||
:call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
|
:call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
|
||||||
:call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
|
:call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
|
||||||
:" no match
|
|
||||||
:call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
|
:call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
|
||||||
:call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
|
:call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
|
||||||
:call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
|
:call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
|
||||||
|
:call add(tl, [2, 'foo\(bar\)\@!', 'foobar'])
|
||||||
|
:call add(tl, [2, 'foo\(bar\)\@!', 'foo bar', 'foo'])
|
||||||
|
:call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if then else'])
|
||||||
|
:call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if else ', 'if else ', ' '])
|
||||||
|
:call add(tl, [2, '\(foo\)\@!bar', 'foobar', 'bar'])
|
||||||
|
:call add(tl, [2, '\(foo\)\@!...bar', 'foobar'])
|
||||||
|
:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' bar foo '])
|
||||||
|
:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo bar '])
|
||||||
|
:call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo xxx ', 'foo'])
|
||||||
:"
|
:"
|
||||||
:"""" Combining different tests and features
|
:"""" Combining different tests and features
|
||||||
:call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
|
:call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
|
||||||
|
@@ -678,6 +678,33 @@ OK 2 - .*John\&.*Bob
|
|||||||
OK 0 - \v(test1)@=.*yep
|
OK 0 - \v(test1)@=.*yep
|
||||||
OK 1 - \v(test1)@=.*yep
|
OK 1 - \v(test1)@=.*yep
|
||||||
OK 2 - \v(test1)@=.*yep
|
OK 2 - \v(test1)@=.*yep
|
||||||
|
OK 0 - foo\(bar\)\@!
|
||||||
|
OK 1 - foo\(bar\)\@!
|
||||||
|
OK 2 - foo\(bar\)\@!
|
||||||
|
OK 0 - foo\(bar\)\@!
|
||||||
|
OK 1 - foo\(bar\)\@!
|
||||||
|
OK 2 - foo\(bar\)\@!
|
||||||
|
OK 0 - if \(\(then\)\@!.\)*$
|
||||||
|
OK 1 - if \(\(then\)\@!.\)*$
|
||||||
|
OK 2 - if \(\(then\)\@!.\)*$
|
||||||
|
OK 0 - if \(\(then\)\@!.\)*$
|
||||||
|
OK 1 - if \(\(then\)\@!.\)*$
|
||||||
|
OK 2 - if \(\(then\)\@!.\)*$
|
||||||
|
OK 0 - \(foo\)\@!bar
|
||||||
|
OK 1 - \(foo\)\@!bar
|
||||||
|
OK 2 - \(foo\)\@!bar
|
||||||
|
OK 0 - \(foo\)\@!...bar
|
||||||
|
OK 1 - \(foo\)\@!...bar
|
||||||
|
OK 2 - \(foo\)\@!...bar
|
||||||
|
OK 0 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 1 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 2 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 0 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 1 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 2 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 0 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 1 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
|
OK 2 - ^\%(.*bar\)\@!.*\zsfoo
|
||||||
OK 0 - [[:alpha:]]\{-2,6}
|
OK 0 - [[:alpha:]]\{-2,6}
|
||||||
OK 1 - [[:alpha:]]\{-2,6}
|
OK 1 - [[:alpha:]]\{-2,6}
|
||||||
OK 2 - [[:alpha:]]\{-2,6}
|
OK 2 - [[:alpha:]]\{-2,6}
|
||||||
|
@@ -728,6 +728,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 */
|
||||||
|
/**/
|
||||||
|
1078,
|
||||||
/**/
|
/**/
|
||||||
1077,
|
1077,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user