jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.158

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