3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.323
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.323
3ef2ca
Problem:    Substitute() with zero width pattern breaks multi-byte character.
3ef2ca
Solution:   Take multi-byte character size into account. (Yukihiro Nakadaira)
3ef2ca
Files:	    src/eval.c src/testdir/test69.in, src/testdir/test69.ok
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.322/src/eval.c	2014-05-28 20:31:37.496292805 +0200
3ef2ca
--- src/eval.c	2014-06-12 18:34:22.928389291 +0200
3ef2ca
***************
3ef2ca
*** 24848,24855 ****
3ef2ca
  		if (zero_width == regmatch.startp[0])
3ef2ca
  		{
3ef2ca
  		    /* avoid getting stuck on a match with an empty string */
3ef2ca
! 		    *((char_u *)ga.ga_data + ga.ga_len) = *tail++;
3ef2ca
! 		    ++ga.ga_len;
3ef2ca
  		    continue;
3ef2ca
  		}
3ef2ca
  		zero_width = regmatch.startp[0];
3ef2ca
--- 24848,24858 ----
3ef2ca
  		if (zero_width == regmatch.startp[0])
3ef2ca
  		{
3ef2ca
  		    /* avoid getting stuck on a match with an empty string */
3ef2ca
! 		    i = MB_PTR2LEN(tail);
3ef2ca
! 		    mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail,
3ef2ca
! 								   (size_t)i);
3ef2ca
! 		    ga.ga_len += i;
3ef2ca
! 		    tail += i;
3ef2ca
  		    continue;
3ef2ca
  		}
3ef2ca
  		zero_width = regmatch.startp[0];
3ef2ca
*** ../vim-7.4.322/src/testdir/test69.in	2014-02-22 23:49:30.268896843 +0100
3ef2ca
--- src/testdir/test69.in	2014-06-12 18:32:43.108385514 +0200
3ef2ca
***************
3ef2ca
*** 180,185 ****
3ef2ca
--- 180,192 ----
3ef2ca
  byteidxcomp
3ef2ca
  
3ef2ca
  STARTTEST
3ef2ca
+ /^substitute
3ef2ca
+ :let y = substitute('123', '\zs', 'a', 'g')    | put =y
3ef2ca
+ ENDTEST
3ef2ca
+ 
3ef2ca
+ substitute
3ef2ca
+ 
3ef2ca
+ STARTTEST
3ef2ca
  :g/^STARTTEST/.,/^ENDTEST/d
3ef2ca
  :1;/^Results/,$wq! test.out
3ef2ca
  ENDTEST
3ef2ca
*** ../vim-7.4.322/src/testdir/test69.ok	2014-02-22 23:49:30.268896843 +0100
3ef2ca
--- src/testdir/test69.ok	2014-06-12 18:32:43.108385514 +0200
3ef2ca
***************
3ef2ca
*** 160,162 ****
3ef2ca
--- 160,166 ----
3ef2ca
  [0, 1, 3, 4, -1]
3ef2ca
  [0, 1, 2, 4, 5, -1]
3ef2ca
  
3ef2ca
+ 
3ef2ca
+ substitute
3ef2ca
+ a1a2a3a
3ef2ca
+ 
3ef2ca
*** ../vim-7.4.322/src/version.c	2014-06-12 18:03:24.940319000 +0200
3ef2ca
--- src/version.c	2014-06-12 18:32:08.356384200 +0200
3ef2ca
***************
3ef2ca
*** 736,737 ****
3ef2ca
--- 736,739 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     323,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
       When danger reared its ugly head,
3ef2ca
       He bravely turned his tail and fled
3ef2ca
       Yes, Brave Sir Robin turned about
3ef2ca
       And gallantly he chickened out
3ef2ca
       Bravely taking to his feet
3ef2ca
       He beat a very brave retreat
3ef2ca
       Bravest of the brave Sir Robin
3ef2ca
       Petrified of being dead
3ef2ca
       Soiled his pants then brave Sir Robin
3ef2ca
       Turned away and fled.
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    ///