lkundrak / rpms / vim

Forked from rpms/vim 4 years ago
Clone
3a67c11
To: vim_dev@googlegroups.com
3a67c11
Subject: Patch 7.4.045
3a67c11
Fcc: outbox
3a67c11
From: Bram Moolenaar <Bram@moolenaar.net>
3a67c11
Mime-Version: 1.0
3a67c11
Content-Type: text/plain; charset=UTF-8
3a67c11
Content-Transfer-Encoding: 8bit
3a67c11
------------
3a67c11
3a67c11
Patch 7.4.045
3a67c11
Problem:    substitute() does not work properly when the pattern starts with
3a67c11
	    "\ze".
3a67c11
Solution:   Detect an empty match. (Christian Brabandt)
3a67c11
Files:	    src/eval.c, src/testdir/test80.in, src/testdir/test80.ok
3a67c11
3a67c11
3a67c11
*** ../vim-7.4.044/src/eval.c	2013-09-25 21:00:24.000000000 +0200
3a67c11
--- src/eval.c	2013-09-29 21:03:22.000000000 +0200
3a67c11
***************
3a67c11
*** 24301,24306 ****
3a67c11
--- 24301,24307 ----
3a67c11
      garray_T	ga;
3a67c11
      char_u	*ret;
3a67c11
      char_u	*save_cpo;
3a67c11
+     int		zero_width;
3a67c11
  
3a67c11
      /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
3a67c11
      save_cpo = p_cpo;
3a67c11
***************
3a67c11
*** 24339,24358 ****
3a67c11
  	    (void)vim_regsub(&regmatch, sub, (char_u *)ga.ga_data
3a67c11
  					  + ga.ga_len + i, TRUE, TRUE, FALSE);
3a67c11
  	    ga.ga_len += i + sublen - 1;
3a67c11
! 	    /* avoid getting stuck on a match with an empty string */
3a67c11
! 	    if (tail == regmatch.endp[0])
3a67c11
  	    {
3a67c11
! 		if (*tail == NUL)
3a67c11
! 		    break;
3a67c11
  		*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
3a67c11
  		++ga.ga_len;
3a67c11
  	    }
3a67c11
- 	    else
3a67c11
- 	    {
3a67c11
- 		tail = regmatch.endp[0];
3a67c11
- 		if (*tail == NUL)
3a67c11
- 		    break;
3a67c11
- 	    }
3a67c11
  	    if (!do_all)
3a67c11
  		break;
3a67c11
  	}
3a67c11
--- 24340,24356 ----
3a67c11
  	    (void)vim_regsub(&regmatch, sub, (char_u *)ga.ga_data
3a67c11
  					  + ga.ga_len + i, TRUE, TRUE, FALSE);
3a67c11
  	    ga.ga_len += i + sublen - 1;
3a67c11
! 	    zero_width = (tail == regmatch.endp[0]
3a67c11
! 				    || regmatch.startp[0] == regmatch.endp[0]);
3a67c11
! 	    tail = regmatch.endp[0];
3a67c11
! 	    if (*tail == NUL)
3a67c11
! 		break;
3a67c11
! 	    if (zero_width)
3a67c11
  	    {
3a67c11
! 		/* avoid getting stuck on a match with an empty string */
3a67c11
  		*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
3a67c11
  		++ga.ga_len;
3a67c11
  	    }
3a67c11
  	    if (!do_all)
3a67c11
  		break;
3a67c11
  	}
3a67c11
*** ../vim-7.4.044/src/testdir/test80.in	2013-03-19 17:30:51.000000000 +0100
3a67c11
--- src/testdir/test80.in	2013-09-29 20:59:00.000000000 +0200
3a67c11
***************
3a67c11
*** 142,147 ****
3a67c11
--- 142,149 ----
3a67c11
  :$put =\"\n\nTEST_7:\"
3a67c11
  :$put =substitute('A?
A', 'A.', '\=submatch(0)', '')
3a67c11
  :$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '')
3a67c11
+ :$put =substitute('-bb', '\zeb', 'a', 'g')
3a67c11
+ :$put =substitute('-bb', '\ze', 'c', 'g')
3a67c11
  /^TEST_8
3a67c11
  ENDTEST
3a67c11
  
3a67c11
*** ../vim-7.4.044/src/testdir/test80.ok	2013-03-19 17:31:45.000000000 +0100
3a67c11
--- src/testdir/test80.ok	2013-09-29 20:59:35.000000000 +0200
3a67c11
***************
3a67c11
*** 103,108 ****
3a67c11
--- 103,110 ----
3a67c11
  A
A
3a67c11
  B
3a67c11
  B
3a67c11
+ -abab
3a67c11
+ c-cbcbc
3a67c11
  
3a67c11
  
3a67c11
  TEST_8:
3a67c11
*** ../vim-7.4.044/src/version.c	2013-09-29 19:05:17.000000000 +0200
3a67c11
--- src/version.c	2013-09-29 21:04:50.000000000 +0200
3a67c11
***************
3a67c11
*** 740,741 ****
3a67c11
--- 740,743 ----
3a67c11
  {   /* Add new patch number below this line */
3a67c11
+ /**/
3a67c11
+     45,
3a67c11
  /**/
3a67c11
3a67c11
-- 
3a67c11
Just think of all the things we haven't thought of yet.
3a67c11
3a67c11
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3a67c11
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3a67c11
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3a67c11
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///