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