Blame SOURCES/7.4.037

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.037
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.037
22c937
Problem:    Using "\ze" in a sub-pattern does not result in the end of the
22c937
	    match to be set. (Axel Bender)
22c937
Solution:   Copy the end of match position when a recursive match was
22c937
	    successful.
22c937
Files:	    src/regexp_nfa.c, src/testdir/test64.in, src/testdir/test64.ok
22c937
22c937
22c937
*** ../vim-7.4.036/src/regexp_nfa.c	2013-09-25 16:41:50.000000000 +0200
22c937
--- src/regexp_nfa.c	2013-09-25 18:09:59.000000000 +0200
22c937
***************
22c937
*** 3822,3827 ****
22c937
--- 3822,3828 ----
22c937
  static void clear_sub __ARGS((regsub_T *sub));
22c937
  static void copy_sub __ARGS((regsub_T *to, regsub_T *from));
22c937
  static void copy_sub_off __ARGS((regsub_T *to, regsub_T *from));
22c937
+ static void copy_ze_off __ARGS((regsub_T *to, regsub_T *from));
22c937
  static int sub_equal __ARGS((regsub_T *sub1, regsub_T *sub2));
22c937
  static int match_backref __ARGS((regsub_T *sub, int subidx, int *bytelen));
22c937
  static int has_state_with_pos __ARGS((nfa_list_T *l, nfa_state_T *state, regsubs_T *subs, nfa_pim_T *pim));
22c937
***************
22c937
*** 3909,3914 ****
22c937
--- 3910,3938 ----
22c937
  }
22c937
  
22c937
  /*
22c937
+  * Like copy_sub() but only do the end of the main match if \ze is present.
22c937
+  */
22c937
+     static void
22c937
+ copy_ze_off(to, from)
22c937
+     regsub_T	*to;
22c937
+     regsub_T	*from;
22c937
+ {
22c937
+     if (nfa_has_zend)
22c937
+     {
22c937
+ 	if (REG_MULTI)
22c937
+ 	{
22c937
+ 	    if (from->list.multi[0].end.lnum >= 0)
22c937
+ 		to->list.multi[0].end = from->list.multi[0].end;
22c937
+ 	}
22c937
+ 	else
22c937
+ 	{
22c937
+ 	    if (from->list.line[0].end != NULL)
22c937
+ 		to->list.line[0].end = from->list.line[0].end;
22c937
+ 	}
22c937
+     }
22c937
+ }
22c937
+ 
22c937
+ /*
22c937
   * Return TRUE if "sub1" and "sub2" have the same start positions.
22c937
   */
22c937
      static int
22c937
***************
22c937
*** 5308,5313 ****
22c937
--- 5332,5338 ----
22c937
   * When "nfa_endp" is not NULL it is a required end-of-match position.
22c937
   *
22c937
   * Return TRUE if there is a match, FALSE otherwise.
22c937
+  * When there is a match "submatch" contains the positions.
22c937
   * Note: Caller must ensure that: start != NULL.
22c937
   */
22c937
      static int
22c937
***************
22c937
*** 5633,5638 ****
22c937
--- 5658,5666 ----
22c937
  			    if (nfa_has_zsubexpr)
22c937
  				copy_sub_off(&t->subs.synt, &m->synt);
22c937
  #endif
22c937
+ 			    /* If the pattern has \ze and it matched in the
22c937
+ 			     * sub pattern, use it. */
22c937
+ 			    copy_ze_off(&t->subs.norm, &m->norm);
22c937
  
22c937
  			    /* t->state->out1 is the corresponding
22c937
  			     * END_INVISIBLE node; Add its out to the current
22c937
*** ../vim-7.4.036/src/testdir/test64.in	2013-09-25 16:41:50.000000000 +0200
22c937
--- src/testdir/test64.in	2013-09-25 18:09:16.000000000 +0200
22c937
***************
22c937
*** 425,430 ****
22c937
--- 425,431 ----
22c937
  :"
22c937
  :" complicated look-behind match
22c937
  :call add(tl, [2, '\(r\@<=\|\w\@
22c937
+ :call add(tl, [2, '^[a-z]\+\ze \&\(asdf\)\@
22c937
  :"
22c937
  :""""" \@>
22c937
  :call add(tl, [2, '\(a*\)\@>a', 'aaaa'])
22c937
*** ../vim-7.4.036/src/testdir/test64.ok	2013-09-25 16:41:50.000000000 +0200
22c937
--- src/testdir/test64.ok	2013-09-25 18:10:05.000000000 +0200
22c937
***************
22c937
*** 983,988 ****
22c937
--- 983,991 ----
22c937
  OK 0 - \(r\@<=\|\w\@
22c937
  OK 1 - \(r\@<=\|\w\@
22c937
  OK 2 - \(r\@<=\|\w\@
22c937
+ OK 0 - ^[a-z]\+\ze \&\(asdf\)\@
22c937
+ OK 1 - ^[a-z]\+\ze \&\(asdf\)\@
22c937
+ OK 2 - ^[a-z]\+\ze \&\(asdf\)\@
22c937
  OK 0 - \(a*\)\@>a
22c937
  OK 1 - \(a*\)\@>a
22c937
  OK 2 - \(a*\)\@>a
22c937
*** ../vim-7.4.036/src/version.c	2013-09-25 16:41:50.000000000 +0200
22c937
--- src/version.c	2013-09-25 18:14:36.000000000 +0200
22c937
***************
22c937
*** 740,741 ****
22c937
--- 740,743 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     37,
22c937
  /**/
22c937
22c937
-- 
22c937
MAN:     You don't frighten us, English pig-dog!  Go and boil your bottoms,
22c937
         son of a silly person.  I blow my nose on you, so-called Arthur-king,
22c937
         you and your silly English K...kaniggets.
22c937
   He puts hands to his ears and blows a raspberry.
22c937
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///