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