summaryrefslogtreecommitdiff
path: root/src/eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-06-12 18:39:22 +0200
committerBram Moolenaar <Bram@vim.org>2014-06-12 18:39:22 +0200
commit8e7048ca4b699bbdb8452c0f8c642bfd66cc7bf4 (patch)
treec53e7f1de5f3c0bb3ab1c0ef29811feb08ecf174 /src/eval.c
parente639eb44e9ca063f682f064095aa98fc781f5df1 (diff)
downloadvim-8e7048ca4b699bbdb8452c0f8c642bfd66cc7bf4.zip
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)
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c
index 51ec0b8b9..728b7d1e2 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -24848,8 +24848,11 @@ do_string_sub(str, pat, sub, flags)
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;
+ 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];