lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
d44f374
To: vim_dev@googlegroups.com
d44f374
Subject: Patch 7.4.158
d44f374
Fcc: outbox
d44f374
From: Bram Moolenaar <Bram@moolenaar.net>
d44f374
Mime-Version: 1.0
d44f374
Content-Type: text/plain; charset=UTF-8
d44f374
Content-Transfer-Encoding: 8bit
d44f374
------------
d44f374
d44f374
Patch 7.4.158 (after 7.4.045)
d44f374
Problem:    Pattern containing \zs is not handled correctly by substitute().
d44f374
Solution:   Change how an empty match is skipped. (Yukihiro Nakadaira)
d44f374
Files:	    src/eval.c, src/testdir/test80.in, src/testdir/test80.ok
d44f374
d44f374
d44f374
*** ../vim-7.4.157/src/eval.c	2014-01-14 19:44:30.000000000 +0100
d44f374
--- src/eval.c	2014-01-23 19:25:23.199796533 +0100
d44f374
***************
d44f374
*** 24365,24371 ****
d44f374
      garray_T	ga;
d44f374
      char_u	*ret;
d44f374
      char_u	*save_cpo;
d44f374
!     int		zero_width;
d44f374
  
d44f374
      /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
d44f374
      save_cpo = p_cpo;
d44f374
--- 24365,24371 ----
d44f374
      garray_T	ga;
d44f374
      char_u	*ret;
d44f374
      char_u	*save_cpo;
d44f374
!     char_u	*zero_width = NULL;
d44f374
  
d44f374
      /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
d44f374
      save_cpo = p_cpo;
d44f374
***************
d44f374
*** 24382,24387 ****
d44f374
--- 24382,24400 ----
d44f374
  	tail = str;
d44f374
  	while (vim_regexec_nl(&regmatch, str, (colnr_T)(tail - str)))
d44f374
  	{
d44f374
+ 	    /* Skip empty match except for first match. */
d44f374
+ 	    if (regmatch.startp[0] == regmatch.endp[0])
d44f374
+ 	    {
d44f374
+ 		if (zero_width == regmatch.startp[0])
d44f374
+ 		{
d44f374
+ 		    /* avoid getting stuck on a match with an empty string */
d44f374
+ 		    *((char_u *)ga.ga_data + ga.ga_len) = *tail++;
d44f374
+ 		    ++ga.ga_len;
d44f374
+ 		    continue;
d44f374
+ 		}
d44f374
+ 		zero_width = regmatch.startp[0];
d44f374
+ 	    }
d44f374
+ 
d44f374
  	    /*
d44f374
  	     * Get some space for a temporary buffer to do the substitution
d44f374
  	     * into.  It will contain:
d44f374
***************
d44f374
*** 24404,24420 ****
d44f374
  	    (void)vim_regsub(&regmatch, sub, (char_u *)ga.ga_data
d44f374
  					  + ga.ga_len + i, TRUE, TRUE, FALSE);
d44f374
  	    ga.ga_len += i + sublen - 1;
d44f374
- 	    zero_width = (tail == regmatch.endp[0]
d44f374
- 				    || regmatch.startp[0] == regmatch.endp[0]);
d44f374
  	    tail = regmatch.endp[0];
d44f374
  	    if (*tail == NUL)
d44f374
  		break;
d44f374
- 	    if (zero_width)
d44f374
- 	    {
d44f374
- 		/* avoid getting stuck on a match with an empty string */
d44f374
- 		*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
d44f374
- 		++ga.ga_len;
d44f374
- 	    }
d44f374
  	    if (!do_all)
d44f374
  		break;
d44f374
  	}
d44f374
--- 24417,24425 ----
d44f374
*** ../vim-7.4.157/src/testdir/test80.in	2013-09-29 21:11:00.000000000 +0200
d44f374
--- src/testdir/test80.in	2014-01-23 19:24:30.487795084 +0100
d44f374
***************
d44f374
*** 176,181 ****
d44f374
--- 176,198 ----
d44f374
  TEST_10:
d44f374
  
d44f374
  STARTTEST
d44f374
+ :set magic&
d44f374
+ :set cpo&
d44f374
+ :$put =\"\n\nTEST_10:\"
d44f374
+ :let y = substitute('123', '\zs', 'a', 'g')             | $put =y
d44f374
+ :let y = substitute('123', '\zs.', 'a', 'g')            | $put =y
d44f374
+ :let y = substitute('123', '.\zs', 'a', 'g')            | $put =y
d44f374
+ :let y = substitute('123', '\ze', 'a', 'g')             | $put =y
d44f374
+ :let y = substitute('123', '\ze.', 'a', 'g')            | $put =y
d44f374
+ :let y = substitute('123', '.\ze', 'a', 'g')            | $put =y
d44f374
+ :let y = substitute('123', '1\|\ze', 'a', 'g')          | $put =y
d44f374
+ :let y = substitute('123', '1\zs\|[23]', 'a', 'g')      | $put =y
d44f374
+ /^TEST_11
d44f374
+ ENDTEST
d44f374
+ 
d44f374
+ TEST_11:
d44f374
+ 
d44f374
+ STARTTEST
d44f374
  :/^Results/,$wq! test.out
d44f374
  ENDTEST
d44f374
  
d44f374
*** ../vim-7.4.157/src/testdir/test80.ok	2013-09-29 21:11:00.000000000 +0200
d44f374
--- src/testdir/test80.ok	2014-01-23 19:24:35.691795227 +0100
d44f374
***************
d44f374
*** 115,117 ****
d44f374
--- 115,128 ----
d44f374
  
d44f374
  TEST_9:
d44f374
  XXx
d44f374
+ 
d44f374
+ 
d44f374
+ TEST_10:
d44f374
+ a1a2a3a
d44f374
+ aaa
d44f374
+ 1a2a3a
d44f374
+ a1a2a3a
d44f374
+ a1a2a3
d44f374
+ aaa
d44f374
+ aa2a3a
d44f374
+ 1aaa
d44f374
*** ../vim-7.4.157/src/version.c	2014-01-23 18:12:44.695676751 +0100
d44f374
--- src/version.c	2014-01-23 19:27:21.611799787 +0100
d44f374
***************
d44f374
*** 740,741 ****
d44f374
--- 740,743 ----
d44f374
  {   /* Add new patch number below this line */
d44f374
+ /**/
d44f374
+     158,
d44f374
  /**/
d44f374
d44f374
-- 
d44f374
$ echo pizza > /dev/oven
d44f374
d44f374
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
d44f374
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
d44f374
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
d44f374
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///