Karsten Hopp f08b45
To: vim_dev@googlegroups.com
Karsten Hopp f08b45
Subject: Patch 7.4.290
Karsten Hopp f08b45
Fcc: outbox
Karsten Hopp f08b45
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f08b45
Mime-Version: 1.0
Karsten Hopp f08b45
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f08b45
Content-Transfer-Encoding: 8bit
Karsten Hopp f08b45
------------
Karsten Hopp f08b45
Karsten Hopp f08b45
Patch 7.4.290
Karsten Hopp f08b45
Problem:    A non-greedy match followed by a branch is too greedy. (Ingo
Karsten Hopp f08b45
	    Karkat)
Karsten Hopp f08b45
Solution:   Add NFA_MATCH when it is already in the state list if the position
Karsten Hopp f08b45
	    differs.
Karsten Hopp f08b45
Files:	    src/testdir/test64.in, src/testdir/test64.ok, src/regexp_nfa.c
Karsten Hopp f08b45
Karsten Hopp f08b45
Karsten Hopp f08b45
*** ../vim-7.4.289/src/testdir/test64.in	2014-05-13 15:56:45.017670668 +0200
Karsten Hopp f08b45
--- src/testdir/test64.in	2014-05-13 16:15:57.213680754 +0200
Karsten Hopp f08b45
***************
Karsten Hopp f08b45
*** 238,244 ****
Karsten Hopp f08b45
  :call add(tl, [2, '\vx(.{-,8})yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz','ayxa','xayzxayz'])
Karsten Hopp f08b45
  :call add(tl, [2, '\vx(.*)yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz', 'ayxayzxayzxa',''])
Karsten Hopp f08b45
  :call add(tl, [2, '\v(a{1,2}){-2,3}','aaaaaaa','aaaa','aa'])
Karsten Hopp f08b45
! :call add(tl, [2, '\v(a{-1,3})+','aa','aa','a'])
Karsten Hopp f08b45
  :"
Karsten Hopp f08b45
  :" Test Character classes
Karsten Hopp f08b45
  :call add(tl, [2, '\d\+e\d\d','test 10e23 fd','10e23'])
Karsten Hopp f08b45
--- 238,248 ----
Karsten Hopp f08b45
  :call add(tl, [2, '\vx(.{-,8})yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz','ayxa','xayzxayz'])
Karsten Hopp f08b45
  :call add(tl, [2, '\vx(.*)yz(.*)','xayxayzxayzxayz','xayxayzxayzxayz', 'ayxayzxayzxa',''])
Karsten Hopp f08b45
  :call add(tl, [2, '\v(a{1,2}){-2,3}','aaaaaaa','aaaa','aa'])
Karsten Hopp f08b45
! :call add(tl, [2, '\v(a{-1,3})+', 'aa', 'aa', 'a'])
Karsten Hopp f08b45
! :call add(tl, [2, '^\s\{-}\zs\( x\|x$\)', ' x', ' x', ' x'])
Karsten Hopp f08b45
! :call add(tl, [2, '^\s\{-}\zs\(x\| x$\)', ' x', ' x', ' x'])
Karsten Hopp f08b45
! :call add(tl, [2, '^\s\{-}\ze\(x\| x$\)', ' x', '', ' x'])
Karsten Hopp f08b45
! :call add(tl, [2, '^\(\s\{-}\)\(x\| x$\)', ' x', ' x', '', ' x'])
Karsten Hopp f08b45
  :"
Karsten Hopp f08b45
  :" Test Character classes
Karsten Hopp f08b45
  :call add(tl, [2, '\d\+e\d\d','test 10e23 fd','10e23'])
Karsten Hopp f08b45
***************
Karsten Hopp f08b45
*** 462,476 ****
Karsten Hopp f08b45
  :    try
Karsten Hopp f08b45
  :      let l = matchlist(text, pat)
Karsten Hopp f08b45
  :    catch
Karsten Hopp f08b45
! :      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", caused an exception: \"' . v:exception . '\"'
Karsten Hopp f08b45
  :    endtry
Karsten Hopp f08b45
  :" check the match itself
Karsten Hopp f08b45
  :    if len(l) == 0 && len(t) > matchidx
Karsten Hopp f08b45
! :      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"'
Karsten Hopp f08b45
  :    elseif len(l) > 0 && len(t) == matchidx
Karsten Hopp f08b45
! :      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match'
Karsten Hopp f08b45
  :    elseif len(t) > matchidx && l[0] != t[matchidx]
Karsten Hopp f08b45
! :      $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"'
Karsten Hopp f08b45
  :    else
Karsten Hopp f08b45
  :      $put ='OK ' . engine . ' - ' . pat
Karsten Hopp f08b45
  :    endif
Karsten Hopp f08b45
--- 466,480 ----
Karsten Hopp f08b45
  :    try
Karsten Hopp f08b45
  :      let l = matchlist(text, pat)
Karsten Hopp f08b45
  :    catch
Karsten Hopp f08b45
! :      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", caused an exception: \"' . v:exception . '\"'
Karsten Hopp f08b45
  :    endtry
Karsten Hopp f08b45
  :" check the match itself
Karsten Hopp f08b45
  :    if len(l) == 0 && len(t) > matchidx
Karsten Hopp f08b45
! :      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", did not match, expected: \"' . t[matchidx] . '\"'
Karsten Hopp f08b45
  :    elseif len(l) > 0 && len(t) == matchidx
Karsten Hopp f08b45
! :      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected no match'
Karsten Hopp f08b45
  :    elseif len(t) > matchidx && l[0] != t[matchidx]
Karsten Hopp f08b45
! :      $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", match: \"' . l[0] . '\", expected: \"' . t[matchidx] . '\"'
Karsten Hopp f08b45
  :    else
Karsten Hopp f08b45
  :      $put ='OK ' . engine . ' - ' . pat
Karsten Hopp f08b45
  :    endif
Karsten Hopp f08b45
***************
Karsten Hopp f08b45
*** 483,489 ****
Karsten Hopp f08b45
  :          let e = t[matchidx + i]
Karsten Hopp f08b45
  :        endif
Karsten Hopp f08b45
  :        if l[i] != e
Karsten Hopp f08b45
! :          $put ='ERROR: pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
Karsten Hopp f08b45
  :        endif
Karsten Hopp f08b45
  :      endfor
Karsten Hopp f08b45
  :      unlet i
Karsten Hopp f08b45
--- 487,493 ----
Karsten Hopp f08b45
  :          let e = t[matchidx + i]
Karsten Hopp f08b45
  :        endif
Karsten Hopp f08b45
  :        if l[i] != e
Karsten Hopp f08b45
! :          $put ='ERROR ' . engine . ': pat: \"' . pat . '\", text: \"' . text . '\", submatch ' . i . ': \"' . l[i] . '\", expected: \"' . e . '\"'
Karsten Hopp f08b45
  :        endif
Karsten Hopp f08b45
  :      endfor
Karsten Hopp f08b45
  :      unlet i
Karsten Hopp f08b45
*** ../vim-7.4.289/src/testdir/test64.ok	2014-05-13 15:56:45.017670668 +0200
Karsten Hopp f08b45
--- src/testdir/test64.ok	2014-05-13 16:39:35.077693166 +0200
Karsten Hopp f08b45
***************
Karsten Hopp f08b45
*** 533,538 ****
Karsten Hopp f08b45
--- 533,550 ----
Karsten Hopp f08b45
  OK 0 - \v(a{-1,3})+
Karsten Hopp f08b45
  OK 1 - \v(a{-1,3})+
Karsten Hopp f08b45
  OK 2 - \v(a{-1,3})+
Karsten Hopp f08b45
+ OK 0 - ^\s\{-}\zs\( x\|x$\)
Karsten Hopp f08b45
+ OK 1 - ^\s\{-}\zs\( x\|x$\)
Karsten Hopp f08b45
+ OK 2 - ^\s\{-}\zs\( x\|x$\)
Karsten Hopp f08b45
+ OK 0 - ^\s\{-}\zs\(x\| x$\)
Karsten Hopp f08b45
+ OK 1 - ^\s\{-}\zs\(x\| x$\)
Karsten Hopp f08b45
+ OK 2 - ^\s\{-}\zs\(x\| x$\)
Karsten Hopp f08b45
+ OK 0 - ^\s\{-}\ze\(x\| x$\)
Karsten Hopp f08b45
+ OK 1 - ^\s\{-}\ze\(x\| x$\)
Karsten Hopp f08b45
+ OK 2 - ^\s\{-}\ze\(x\| x$\)
Karsten Hopp f08b45
+ OK 0 - ^\(\s\{-}\)\(x\| x$\)
Karsten Hopp f08b45
+ OK 1 - ^\(\s\{-}\)\(x\| x$\)
Karsten Hopp f08b45
+ OK 2 - ^\(\s\{-}\)\(x\| x$\)
Karsten Hopp f08b45
  OK 0 - \d\+e\d\d
Karsten Hopp f08b45
  OK 1 - \d\+e\d\d
Karsten Hopp f08b45
  OK 2 - \d\+e\d\d
Karsten Hopp f08b45
*** ../vim-7.4.289/src/regexp_nfa.c	2014-05-13 15:56:45.021670668 +0200
Karsten Hopp f08b45
--- src/regexp_nfa.c	2014-05-13 16:37:58.481692320 +0200
Karsten Hopp f08b45
***************
Karsten Hopp f08b45
*** 4324,4331 ****
Karsten Hopp f08b45
  	    {
Karsten Hopp f08b45
  		/* This state is already in the list, don't add it again,
Karsten Hopp f08b45
  		 * unless it is an MOPEN that is used for a backreference or
Karsten Hopp f08b45
! 		 * when there is a PIM. */
Karsten Hopp f08b45
! 		if (!nfa_has_backref && pim == NULL && !l->has_pim)
Karsten Hopp f08b45
  		{
Karsten Hopp f08b45
  skip_add:
Karsten Hopp f08b45
  #ifdef ENABLE_LOG
Karsten Hopp f08b45
--- 4324,4333 ----
Karsten Hopp f08b45
  	    {
Karsten Hopp f08b45
  		/* This state is already in the list, don't add it again,
Karsten Hopp f08b45
  		 * unless it is an MOPEN that is used for a backreference or
Karsten Hopp f08b45
! 		 * when there is a PIM. For NFA_MATCH check the position,
Karsten Hopp f08b45
! 		 * lower position is preferred. */
Karsten Hopp f08b45
! 		if (!nfa_has_backref && pim == NULL && !l->has_pim
Karsten Hopp f08b45
! 						     && state->c != NFA_MATCH)
Karsten Hopp f08b45
  		{
Karsten Hopp f08b45
  skip_add:
Karsten Hopp f08b45
  #ifdef ENABLE_LOG
Karsten Hopp f08b45
*** ../vim-7.4.289/src/version.c	2014-05-13 15:56:45.025670668 +0200
Karsten Hopp f08b45
--- src/version.c	2014-05-13 16:13:33.953679500 +0200
Karsten Hopp f08b45
***************
Karsten Hopp f08b45
*** 736,737 ****
Karsten Hopp f08b45
--- 736,739 ----
Karsten Hopp f08b45
  {   /* Add new patch number below this line */
Karsten Hopp f08b45
+ /**/
Karsten Hopp f08b45
+     290,
Karsten Hopp f08b45
  /**/
Karsten Hopp f08b45
Karsten Hopp f08b45
-- 
Karsten Hopp f08b45
Although the scythe isn't pre-eminent among the weapons of war, anyone who
Karsten Hopp f08b45
has been on the wrong end of, say, a peasants' revolt will know that in
Karsten Hopp f08b45
skilled hands it is fearsome.
Karsten Hopp f08b45
					-- (Terry Pratchett, Mort)
Karsten Hopp f08b45
Karsten Hopp f08b45
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f08b45
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f08b45
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f08b45
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///