073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.323
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.323
073263
Problem:    Substitute() with zero width pattern breaks multi-byte character.
073263
Solution:   Take multi-byte character size into account. (Yukihiro Nakadaira)
073263
Files:	    src/eval.c src/testdir/test69.in, src/testdir/test69.ok
073263
073263
073263
*** ../vim-7.4.322/src/eval.c	2014-05-28 20:31:37.496292805 +0200
073263
--- src/eval.c	2014-06-12 18:34:22.928389291 +0200
073263
***************
073263
*** 24848,24855 ****
073263
  		if (zero_width == regmatch.startp[0])
073263
  		{
073263
  		    /* avoid getting stuck on a match with an empty string */
073263
! 		    *((char_u *)ga.ga_data + ga.ga_len) = *tail++;
073263
! 		    ++ga.ga_len;
073263
  		    continue;
073263
  		}
073263
  		zero_width = regmatch.startp[0];
073263
--- 24848,24858 ----
073263
  		if (zero_width == regmatch.startp[0])
073263
  		{
073263
  		    /* avoid getting stuck on a match with an empty string */
073263
! 		    i = MB_PTR2LEN(tail);
073263
! 		    mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail,
073263
! 								   (size_t)i);
073263
! 		    ga.ga_len += i;
073263
! 		    tail += i;
073263
  		    continue;
073263
  		}
073263
  		zero_width = regmatch.startp[0];
073263
*** ../vim-7.4.322/src/testdir/test69.in	2014-02-22 23:49:30.268896843 +0100
073263
--- src/testdir/test69.in	2014-06-12 18:32:43.108385514 +0200
073263
***************
073263
*** 180,185 ****
073263
--- 180,192 ----
073263
  byteidxcomp
073263
  
073263
  STARTTEST
073263
+ /^substitute
073263
+ :let y = substitute('123', '\zs', 'a', 'g')    | put =y
073263
+ ENDTEST
073263
+ 
073263
+ substitute
073263
+ 
073263
+ STARTTEST
073263
  :g/^STARTTEST/.,/^ENDTEST/d
073263
  :1;/^Results/,$wq! test.out
073263
  ENDTEST
073263
*** ../vim-7.4.322/src/testdir/test69.ok	2014-02-22 23:49:30.268896843 +0100
073263
--- src/testdir/test69.ok	2014-06-12 18:32:43.108385514 +0200
073263
***************
073263
*** 160,162 ****
073263
--- 160,166 ----
073263
  [0, 1, 3, 4, -1]
073263
  [0, 1, 2, 4, 5, -1]
073263
  
073263
+ 
073263
+ substitute
073263
+ a1a2a3a
073263
+ 
073263
*** ../vim-7.4.322/src/version.c	2014-06-12 18:03:24.940319000 +0200
073263
--- src/version.c	2014-06-12 18:32:08.356384200 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     323,
073263
  /**/
073263
073263
-- 
073263
       When danger reared its ugly head,
073263
       He bravely turned his tail and fled
073263
       Yes, Brave Sir Robin turned about
073263
       And gallantly he chickened out
073263
       Bravely taking to his feet
073263
       He beat a very brave retreat
073263
       Bravest of the brave Sir Robin
073263
       Petrified of being dead
073263
       Soiled his pants then brave Sir Robin
073263
       Turned away and fled.
073263
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///