jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.037

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