forked from aniani/vim
updated for version 7.4.323
Problem: Substitute() with zero width pattern breaks multi-byte character. Solution: Take multi-byte character size into account. (Yukihiro Nakadaira)
This commit is contained in:
@@ -24848,8 +24848,11 @@ do_string_sub(str, pat, sub, flags)
|
|||||||
if (zero_width == regmatch.startp[0])
|
if (zero_width == regmatch.startp[0])
|
||||||
{
|
{
|
||||||
/* avoid getting stuck on a match with an empty string */
|
/* avoid getting stuck on a match with an empty string */
|
||||||
*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
|
i = MB_PTR2LEN(tail);
|
||||||
++ga.ga_len;
|
mch_memmove((char_u *)ga.ga_data + ga.ga_len, tail,
|
||||||
|
(size_t)i);
|
||||||
|
ga.ga_len += i;
|
||||||
|
tail += i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
zero_width = regmatch.startp[0];
|
zero_width = regmatch.startp[0];
|
||||||
|
@@ -179,6 +179,13 @@ ENDTEST
|
|||||||
byteidx
|
byteidx
|
||||||
byteidxcomp
|
byteidxcomp
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
/^substitute
|
||||||
|
:let y = substitute('123', '\zs', 'a', 'g') | put =y
|
||||||
|
ENDTEST
|
||||||
|
|
||||||
|
substitute
|
||||||
|
|
||||||
STARTTEST
|
STARTTEST
|
||||||
:g/^STARTTEST/.,/^ENDTEST/d
|
:g/^STARTTEST/.,/^ENDTEST/d
|
||||||
:1;/^Results/,$wq! test.out
|
:1;/^Results/,$wq! test.out
|
||||||
|
@@ -160,3 +160,7 @@ byteidxcomp
|
|||||||
[0, 1, 3, 4, -1]
|
[0, 1, 3, 4, -1]
|
||||||
[0, 1, 2, 4, 5, -1]
|
[0, 1, 2, 4, 5, -1]
|
||||||
|
|
||||||
|
|
||||||
|
substitute
|
||||||
|
a1a2a3a
|
||||||
|
|
||||||
|
@@ -734,6 +734,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
323,
|
||||||
/**/
|
/**/
|
||||||
322,
|
322,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user