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