Karsten Hopp 55c600
To: vim_dev@googlegroups.com
Karsten Hopp 55c600
Subject: Patch 7.3.1078
Karsten Hopp 55c600
Fcc: outbox
Karsten Hopp 55c600
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 55c600
Mime-Version: 1.0
Karsten Hopp 55c600
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 55c600
Content-Transfer-Encoding: 8bit
Karsten Hopp 55c600
------------
Karsten Hopp 55c600
Karsten Hopp 55c600
Patch 7.3.1078
Karsten Hopp 55c600
Problem:    New regexp engine: \@! doesn't work.
Karsten Hopp 55c600
Solution:   Implement the negated version of \@=.
Karsten Hopp 55c600
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
Karsten Hopp 55c600
Karsten Hopp 55c600
Karsten Hopp 55c600
*** ../vim-7.3.1077/src/regexp_nfa.c	2013-05-30 21:42:09.000000000 +0200
Karsten Hopp 55c600
--- src/regexp_nfa.c	2013-05-30 22:39:40.000000000 +0200
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 1390,1395 ****
Karsten Hopp 55c600
--- 1390,1398 ----
Karsten Hopp 55c600
  		case '=':
Karsten Hopp 55c600
  		    EMIT(NFA_PREV_ATOM_NO_WIDTH);
Karsten Hopp 55c600
  		    break;
Karsten Hopp 55c600
+ 		case '!':
Karsten Hopp 55c600
+ 		    EMIT(NFA_PREV_ATOM_NO_WIDTH_NEG);
Karsten Hopp 55c600
+ 		    break;
Karsten Hopp 55c600
  		case '0':
Karsten Hopp 55c600
  		case '1':
Karsten Hopp 55c600
  		case '2':
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 1400,1406 ****
Karsten Hopp 55c600
  		case '7':
Karsten Hopp 55c600
  		case '8':
Karsten Hopp 55c600
  		case '9':
Karsten Hopp 55c600
- 		case '!':
Karsten Hopp 55c600
  		case '<':
Karsten Hopp 55c600
  		case '>':
Karsten Hopp 55c600
  		    /* Not supported yet */
Karsten Hopp 55c600
--- 1403,1408 ----
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 2373,2379 ****
Karsten Hopp 55c600
--- 2375,2383 ----
Karsten Hopp 55c600
  	    break;
Karsten Hopp 55c600
  
Karsten Hopp 55c600
  	case NFA_PREV_ATOM_NO_WIDTH:
Karsten Hopp 55c600
+ 	case NFA_PREV_ATOM_NO_WIDTH_NEG:
Karsten Hopp 55c600
  	    /* The \@= operator: match the preceding atom with zero width.
Karsten Hopp 55c600
+ 	     * The \@! operator: no match for the preceding atom.
Karsten Hopp 55c600
  	     * Surrounds the preceding atom with START_INVISIBLE and
Karsten Hopp 55c600
  	     * END_INVISIBLE, similarly to MOPEN. */
Karsten Hopp 55c600
  
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 2391,2396 ****
Karsten Hopp 55c600
--- 2395,2406 ----
Karsten Hopp 55c600
  	    s = new_state(NFA_START_INVISIBLE, e.start, s1);
Karsten Hopp 55c600
  	    if (s == NULL)
Karsten Hopp 55c600
  		goto theend;
Karsten Hopp 55c600
+ 	    if (*p == NFA_PREV_ATOM_NO_WIDTH_NEG)
Karsten Hopp 55c600
+ 	    {
Karsten Hopp 55c600
+ 		s->negated = TRUE;
Karsten Hopp 55c600
+ 		s1->negated = TRUE;
Karsten Hopp 55c600
+ 	    }
Karsten Hopp 55c600
+ 
Karsten Hopp 55c600
  	    PUSH(frag(s, list1(&s1->out)));
Karsten Hopp 55c600
  	    break;
Karsten Hopp 55c600
  
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 3541,3548 ****
Karsten Hopp 55c600
  		    addstate_here(thislist, t->state->out, &t->sub, &listidx);
Karsten Hopp 55c600
  		else
Karsten Hopp 55c600
  		{
Karsten Hopp 55c600
! 		    /* TODO: only copy positions in use. */
Karsten Hopp 55c600
! 		    *m = t->sub;
Karsten Hopp 55c600
  		    nfa_match = TRUE;
Karsten Hopp 55c600
  		}
Karsten Hopp 55c600
  		break;
Karsten Hopp 55c600
--- 3551,3560 ----
Karsten Hopp 55c600
  		    addstate_here(thislist, t->state->out, &t->sub, &listidx);
Karsten Hopp 55c600
  		else
Karsten Hopp 55c600
  		{
Karsten Hopp 55c600
! 		    /* do not set submatches for \@! */
Karsten Hopp 55c600
! 		    if (!t->state->negated)
Karsten Hopp 55c600
! 			/* TODO: only copy positions in use. */
Karsten Hopp 55c600
! 			*m = t->sub;
Karsten Hopp 55c600
  		    nfa_match = TRUE;
Karsten Hopp 55c600
  		}
Karsten Hopp 55c600
  		break;
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 3593,3599 ****
Karsten Hopp 55c600
  		    log_fd = stderr;
Karsten Hopp 55c600
  		}
Karsten Hopp 55c600
  #endif
Karsten Hopp 55c600
! 		if (result == TRUE)
Karsten Hopp 55c600
  		{
Karsten Hopp 55c600
  		    int j;
Karsten Hopp 55c600
  
Karsten Hopp 55c600
--- 3605,3612 ----
Karsten Hopp 55c600
  		    log_fd = stderr;
Karsten Hopp 55c600
  		}
Karsten Hopp 55c600
  #endif
Karsten Hopp 55c600
! 		/* for \@! it is a match when result is FALSE */
Karsten Hopp 55c600
! 		if (result != t->state->negated)
Karsten Hopp 55c600
  		{
Karsten Hopp 55c600
  		    int j;
Karsten Hopp 55c600
  
Karsten Hopp 55c600
*** ../vim-7.3.1077/src/testdir/test64.in	2013-05-30 21:42:09.000000000 +0200
Karsten Hopp 55c600
--- src/testdir/test64.in	2013-05-30 22:41:38.000000000 +0200
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 303,315 ****
Karsten Hopp 55c600
  :" will never match
Karsten Hopp 55c600
  :call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
Karsten Hopp 55c600
  :call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
Karsten Hopp 55c600
- :" no match
Karsten Hopp 55c600
  :call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
Karsten Hopp 55c600
  :call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
Karsten Hopp 55c600
- :" no match
Karsten Hopp 55c600
  :call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
Karsten Hopp 55c600
  :call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
Karsten Hopp 55c600
  :call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
Karsten Hopp 55c600
  :"
Karsten Hopp 55c600
  :"""" Combining different tests and features
Karsten Hopp 55c600
  :call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
Karsten Hopp 55c600
--- 303,322 ----
Karsten Hopp 55c600
  :" will never match
Karsten Hopp 55c600
  :call add(tl, [2, 'abcd\@=e', 'any text in here ... '])
Karsten Hopp 55c600
  :call add(tl, [2, '\v(abc)@=..', 'xabcd', 'ab', 'abc'])
Karsten Hopp 55c600
  :call add(tl, [2, '\(.*John\)\@=.*Bob', 'here is John, and here is B'])
Karsten Hopp 55c600
  :call add(tl, [2, '\(John.*\)\@=.*Bob', 'John is Bobs friend', 'John is Bob', 'John is Bobs friend'])
Karsten Hopp 55c600
  :call add(tl, [2, '.*John\&.*Bob', 'here is John, and here is B'])
Karsten Hopp 55c600
  :call add(tl, [2, '.*John\&.*Bob', 'John is Bobs friend', 'John is Bob'])
Karsten Hopp 55c600
  :call add(tl, [2, '\v(test1)@=.*yep', 'this is a test1, yep it is', 'test1, yep', 'test1'])
Karsten Hopp 55c600
+ :call add(tl, [2, 'foo\(bar\)\@!', 'foobar'])
Karsten Hopp 55c600
+ :call add(tl, [2, 'foo\(bar\)\@!', 'foo bar', 'foo'])
Karsten Hopp 55c600
+ :call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if then else'])
Karsten Hopp 55c600
+ :call add(tl, [2, 'if \(\(then\)\@!.\)*$', ' if else ', 'if else ', ' '])
Karsten Hopp 55c600
+ :call add(tl, [2, '\(foo\)\@!bar', 'foobar', 'bar'])
Karsten Hopp 55c600
+ :call add(tl, [2, '\(foo\)\@!...bar', 'foobar'])
Karsten Hopp 55c600
+ :call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' bar foo '])
Karsten Hopp 55c600
+ :call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo bar '])
Karsten Hopp 55c600
+ :call add(tl, [2, '^\%(.*bar\)\@!.*\zsfoo', ' foo xxx ', 'foo'])
Karsten Hopp 55c600
  :"
Karsten Hopp 55c600
  :"""" Combining different tests and features
Karsten Hopp 55c600
  :call add(tl, [2, '[[:alpha:]]\{-2,6}', '787abcdiuhsasiuhb4', 'ab'])
Karsten Hopp 55c600
*** ../vim-7.3.1077/src/testdir/test64.ok	2013-05-30 21:42:09.000000000 +0200
Karsten Hopp 55c600
--- src/testdir/test64.ok	2013-05-30 22:42:02.000000000 +0200
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 678,683 ****
Karsten Hopp 55c600
--- 678,710 ----
Karsten Hopp 55c600
  OK 0 - \v(test1)@=.*yep
Karsten Hopp 55c600
  OK 1 - \v(test1)@=.*yep
Karsten Hopp 55c600
  OK 2 - \v(test1)@=.*yep
Karsten Hopp 55c600
+ OK 0 - foo\(bar\)\@!
Karsten Hopp 55c600
+ OK 1 - foo\(bar\)\@!
Karsten Hopp 55c600
+ OK 2 - foo\(bar\)\@!
Karsten Hopp 55c600
+ OK 0 - foo\(bar\)\@!
Karsten Hopp 55c600
+ OK 1 - foo\(bar\)\@!
Karsten Hopp 55c600
+ OK 2 - foo\(bar\)\@!
Karsten Hopp 55c600
+ OK 0 - if \(\(then\)\@!.\)*$
Karsten Hopp 55c600
+ OK 1 - if \(\(then\)\@!.\)*$
Karsten Hopp 55c600
+ OK 2 - if \(\(then\)\@!.\)*$
Karsten Hopp 55c600
+ OK 0 - if \(\(then\)\@!.\)*$
Karsten Hopp 55c600
+ OK 1 - if \(\(then\)\@!.\)*$
Karsten Hopp 55c600
+ OK 2 - if \(\(then\)\@!.\)*$
Karsten Hopp 55c600
+ OK 0 - \(foo\)\@!bar
Karsten Hopp 55c600
+ OK 1 - \(foo\)\@!bar
Karsten Hopp 55c600
+ OK 2 - \(foo\)\@!bar
Karsten Hopp 55c600
+ OK 0 - \(foo\)\@!...bar
Karsten Hopp 55c600
+ OK 1 - \(foo\)\@!...bar
Karsten Hopp 55c600
+ OK 2 - \(foo\)\@!...bar
Karsten Hopp 55c600
+ OK 0 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 1 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 2 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 0 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 1 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 2 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 0 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 1 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
+ OK 2 - ^\%(.*bar\)\@!.*\zsfoo
Karsten Hopp 55c600
  OK 0 - [[:alpha:]]\{-2,6}
Karsten Hopp 55c600
  OK 1 - [[:alpha:]]\{-2,6}
Karsten Hopp 55c600
  OK 2 - [[:alpha:]]\{-2,6}
Karsten Hopp 55c600
*** ../vim-7.3.1077/src/version.c	2013-05-30 22:06:28.000000000 +0200
Karsten Hopp 55c600
--- src/version.c	2013-05-30 22:42:59.000000000 +0200
Karsten Hopp 55c600
***************
Karsten Hopp 55c600
*** 730,731 ****
Karsten Hopp 55c600
--- 730,733 ----
Karsten Hopp 55c600
  {   /* Add new patch number below this line */
Karsten Hopp 55c600
+ /**/
Karsten Hopp 55c600
+     1078,
Karsten Hopp 55c600
  /**/
Karsten Hopp 55c600
Karsten Hopp 55c600
-- 
Karsten Hopp 55c600
The startling truth finally became apparent, and it was this: Numbers
Karsten Hopp 55c600
written on restaurant checks within the confines of restaurants do not follow
Karsten Hopp 55c600
the same mathematical laws as numbers written on any other pieces of paper in
Karsten Hopp 55c600
any other parts of the Universe.  This single statement took the scientific
Karsten Hopp 55c600
world by storm.  So many mathematical conferences got held in such good
Karsten Hopp 55c600
restaurants that many of the finest minds of a generation died of obesity and
Karsten Hopp 55c600
heart failure, and the science of mathematics was put back by years.
Karsten Hopp 55c600
		-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
Karsten Hopp 55c600
Karsten Hopp 55c600
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 55c600
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 55c600
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 55c600
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///