summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-07-12 22:42:33 +0200
committerBram Moolenaar <Bram@vim.org>2010-07-12 22:42:33 +0200
commit0c56c60a0f99a5d16e34b9b92e25e4f3531440b8 (patch)
tree642fe7ce3ce0500d292a914240cb7359529a0050
parent4d770fb56635162a9a7a0a7cdfc48627bb25faec (diff)
downloadvim-git-0c56c60a0f99a5d16e34b9b92e25e4f3531440b8.tar.gz
Fix: Composing characters in :s substitute text were dropped.
-rw-r--r--src/regexp.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/regexp.c b/src/regexp.c
index ae1b03a11..480f4cc69 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -7140,10 +7140,26 @@ vim_regsub_both(source, dest, copy, magic, backslash)
#ifdef FEAT_MBYTE
if (has_mbyte)
{
- src += mb_ptr2len(src - 1) - 1;
+ int totlen = mb_ptr2len(src - 1);
+
if (copy)
mb_char2bytes(cc, dst);
dst += mb_char2len(cc) - 1;
+ if (enc_utf8)
+ {
+ int clen = utf_ptr2len(src - 1);
+
+ /* If the character length is shorter than "totlen", there
+ * are composing characters; copy them as-is. */
+ if (clen < totlen)
+ {
+ if (copy)
+ mch_memmove(dst + 1, src - 1 + clen,
+ (size_t)(totlen - clen));
+ dst += totlen - clen;
+ }
+ }
+ src += totlen - 1;
}
else
#endif