Karsten Hopp 01ba77
To: vim_dev@googlegroups.com
Karsten Hopp 01ba77
Subject: Patch 7.3.1026
Karsten Hopp 01ba77
Fcc: outbox
Karsten Hopp 01ba77
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 01ba77
Mime-Version: 1.0
Karsten Hopp 01ba77
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 01ba77
Content-Transfer-Encoding: 8bit
Karsten Hopp 01ba77
------------
Karsten Hopp 01ba77
Karsten Hopp 01ba77
Patch 7.3.1026
Karsten Hopp 01ba77
Problem:    New regexp: pattern that includs a new-line matches too early.
Karsten Hopp 01ba77
	    (john McGowan)
Karsten Hopp 01ba77
Solution:   Do not start searching in the second line.
Karsten Hopp 01ba77
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
Karsten Hopp 01ba77
Karsten Hopp 01ba77
Karsten Hopp 01ba77
*** ../vim-7.3.1025/src/regexp_nfa.c	2013-05-26 17:45:41.000000000 +0200
Karsten Hopp 01ba77
--- src/regexp_nfa.c	2013-05-26 18:38:01.000000000 +0200
Karsten Hopp 01ba77
***************
Karsten Hopp 01ba77
*** 3585,3596 ****
Karsten Hopp 01ba77
  
Karsten Hopp 01ba77
  	} /* for (thislist = thislist; thislist->state; thislist++) */
Karsten Hopp 01ba77
  
Karsten Hopp 01ba77
! 	/* The first found match is the leftmost one, but there may be a
Karsten Hopp 01ba77
! 	 * longer one. Keep running the NFA, but don't start from the
Karsten Hopp 01ba77
! 	 * beginning. Also, do not add the start state in recursive calls of
Karsten Hopp 01ba77
! 	 * nfa_regmatch(), because recursive calls should only start in the
Karsten Hopp 01ba77
! 	 * first position. */
Karsten Hopp 01ba77
! 	if (match == FALSE && start->c == NFA_MOPEN + 0)
Karsten Hopp 01ba77
  	{
Karsten Hopp 01ba77
  #ifdef ENABLE_LOG
Karsten Hopp 01ba77
  	    fprintf(log_fd, "(---) STARTSTATE\n");
Karsten Hopp 01ba77
--- 3585,3599 ----
Karsten Hopp 01ba77
  
Karsten Hopp 01ba77
  	} /* for (thislist = thislist; thislist->state; thislist++) */
Karsten Hopp 01ba77
  
Karsten Hopp 01ba77
! 	/* Look for the start of a match in the current position by adding the
Karsten Hopp 01ba77
! 	 * start state to the list of states.
Karsten Hopp 01ba77
! 	 * The first found match is the leftmost one, thus the order of states
Karsten Hopp 01ba77
! 	 * matters!
Karsten Hopp 01ba77
! 	 * Do not add the start state in recursive calls of nfa_regmatch(),
Karsten Hopp 01ba77
! 	 * because recursive calls should only start in the first position.
Karsten Hopp 01ba77
! 	 * Also don't start a match past the first line. */
Karsten Hopp 01ba77
! 	if (match == FALSE && start->c == NFA_MOPEN + 0
Karsten Hopp 01ba77
! 						 && reglnum == 0 && clen != 0)
Karsten Hopp 01ba77
  	{
Karsten Hopp 01ba77
  #ifdef ENABLE_LOG
Karsten Hopp 01ba77
  	    fprintf(log_fd, "(---) STARTSTATE\n");
Karsten Hopp 01ba77
*** ../vim-7.3.1025/src/testdir/test64.in	2013-05-26 17:45:41.000000000 +0200
Karsten Hopp 01ba77
--- src/testdir/test64.in	2013-05-26 18:34:04.000000000 +0200
Karsten Hopp 01ba77
***************
Karsten Hopp 01ba77
*** 372,377 ****
Karsten Hopp 01ba77
--- 372,383 ----
Karsten Hopp 01ba77
  :.+1,.+2yank
Karsten Hopp 01ba77
  Go?p:"
Karsten Hopp 01ba77
  :"
Karsten Hopp 01ba77
+ :" Check a pattern with a line break matches in the right position.
Karsten Hopp 01ba77
+ /^Multiline
Karsten Hopp 01ba77
+ /\S.*\nx
Karsten Hopp 01ba77
+ :.yank
Karsten Hopp 01ba77
+ y$Go?p:"
Karsten Hopp 01ba77
+ :"
Karsten Hopp 01ba77
  :"
Karsten Hopp 01ba77
  :/\%#=1^Results/,$wq! test.out
Karsten Hopp 01ba77
  ENDTEST
Karsten Hopp 01ba77
***************
Karsten Hopp 01ba77
*** 383,386 ****
Karsten Hopp 01ba77
--- 389,399 ----
Karsten Hopp 01ba77
  <T="">Ta 5</Title>
Karsten Hopp 01ba77
  <T="">Ac 7</Title>
Karsten Hopp 01ba77
  
Karsten Hopp 01ba77
+ Multiline:
Karsten Hopp 01ba77
+ abc
Karsten Hopp 01ba77
+ def
Karsten Hopp 01ba77
+ ghi
Karsten Hopp 01ba77
+ xjk
Karsten Hopp 01ba77
+ lmn
Karsten Hopp 01ba77
+ 
Karsten Hopp 01ba77
  Results of test64:
Karsten Hopp 01ba77
*** ../vim-7.3.1025/src/testdir/test64.ok	2013-05-26 17:45:41.000000000 +0200
Karsten Hopp 01ba77
--- src/testdir/test64.ok	2013-05-26 18:34:00.000000000 +0200
Karsten Hopp 01ba77
***************
Karsten Hopp 01ba77
*** 705,707 ****
Karsten Hopp 01ba77
--- 705,708 ----
Karsten Hopp 01ba77
  
Karsten Hopp 01ba77
  <T="5">Ta 5</Title>
Karsten Hopp 01ba77
  <T="7">Ac 7</Title>
Karsten Hopp 01ba77
+ ghi
Karsten Hopp 01ba77
*** ../vim-7.3.1025/src/version.c	2013-05-26 17:45:41.000000000 +0200
Karsten Hopp 01ba77
--- src/version.c	2013-05-26 18:35:52.000000000 +0200
Karsten Hopp 01ba77
***************
Karsten Hopp 01ba77
*** 730,731 ****
Karsten Hopp 01ba77
--- 730,733 ----
Karsten Hopp 01ba77
  {   /* Add new patch number below this line */
Karsten Hopp 01ba77
+ /**/
Karsten Hopp 01ba77
+     1026,
Karsten Hopp 01ba77
  /**/
Karsten Hopp 01ba77
Karsten Hopp 01ba77
-- 
Karsten Hopp 01ba77
For society, it's probably a good thing that engineers value function over
Karsten Hopp 01ba77
appearance.  For example, you wouldn't want engineers to build nuclear power
Karsten Hopp 01ba77
plants that only _look_ like they would keep all the radiation inside.
Karsten Hopp 01ba77
				(Scott Adams - The Dilbert principle)
Karsten Hopp 01ba77
Karsten Hopp 01ba77
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 01ba77
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 01ba77
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 01ba77
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///