To: vim_dev@googlegroups.com
Subject: Patch 7.3.1026
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.1026
Problem:    New regexp: pattern that includs a new-line matches too early.
	    (john McGowan)
Solution:   Do not start searching in the second line.
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok


*** ../vim-7.3.1025/src/regexp_nfa.c	2013-05-26 17:45:41.000000000 +0200
--- src/regexp_nfa.c	2013-05-26 18:38:01.000000000 +0200
***************
*** 3585,3596 ****
  
  	} /* for (thislist = thislist; thislist->state; thislist++) */
  
! 	/* The first found match is the leftmost one, but there may be a
! 	 * longer one. Keep running the NFA, but don't start from the
! 	 * beginning. Also, do not add the start state in recursive calls of
! 	 * nfa_regmatch(), because recursive calls should only start in the
! 	 * first position. */
! 	if (match == FALSE && start->c == NFA_MOPEN + 0)
  	{
  #ifdef ENABLE_LOG
  	    fprintf(log_fd, "(---) STARTSTATE\n");
--- 3585,3599 ----
  
  	} /* for (thislist = thislist; thislist->state; thislist++) */
  
! 	/* Look for the start of a match in the current position by adding the
! 	 * start state to the list of states.
! 	 * The first found match is the leftmost one, thus the order of states
! 	 * matters!
! 	 * Do not add the start state in recursive calls of nfa_regmatch(),
! 	 * because recursive calls should only start in the first position.
! 	 * Also don't start a match past the first line. */
! 	if (match == FALSE && start->c == NFA_MOPEN + 0
! 						 && reglnum == 0 && clen != 0)
  	{
  #ifdef ENABLE_LOG
  	    fprintf(log_fd, "(---) STARTSTATE\n");
*** ../vim-7.3.1025/src/testdir/test64.in	2013-05-26 17:45:41.000000000 +0200
--- src/testdir/test64.in	2013-05-26 18:34:04.000000000 +0200
***************
*** 372,377 ****
--- 372,383 ----
  :.+1,.+2yank
  Gop:"
  :"
+ :" Check a pattern with a line break matches in the right position.
+ /^Multiline
+ /\S.*\nx
+ :.yank
+ y$Gop:"
+ :"
  :"
  :/\%#=1^Results/,$wq! test.out
  ENDTEST
***************
*** 383,386 ****
--- 389,399 ----
  <T="">Ta 5</Title>
  <T="">Ac 7</Title>
  
+ Multiline:
+ abc
+ def
+ ghi
+ xjk
+ lmn
+ 
  Results of test64:
*** ../vim-7.3.1025/src/testdir/test64.ok	2013-05-26 17:45:41.000000000 +0200
--- src/testdir/test64.ok	2013-05-26 18:34:00.000000000 +0200
***************
*** 705,707 ****
--- 705,708 ----
  
  <T="5">Ta 5</Title>
  <T="7">Ac 7</Title>
+ ghi
*** ../vim-7.3.1025/src/version.c	2013-05-26 17:45:41.000000000 +0200
--- src/version.c	2013-05-26 18:35:52.000000000 +0200
***************
*** 730,731 ****
--- 730,733 ----
  {   /* Add new patch number below this line */
+ /**/
+     1026,
  /**/

-- 
For society, it's probably a good thing that engineers value function over
appearance.  For example, you wouldn't want engineers to build nuclear power
plants that only _look_ like they would keep all the radiation inside.
				(Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
