]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.323 v7.4.323
authorBram Moolenaar <Bram@vim.org>
Thu, 12 Jun 2014 16:39:22 +0000 (18:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 12 Jun 2014 16:39:22 +0000 (18:39 +0200)
Problem:    Substitute() with zero width pattern breaks multi-byte character.
Solution:   Take multi-byte character size into account. (Yukihiro Nakadaira)

src/eval.c
src/testdir/test69.in
src/testdir/test69.ok
src/version.c

index 51ec0b8b969ec9e855d9ea93174ca0c47e8c80bb..728b7d1e2afc0a83e38c2250713ed2be156ce831 100644 (file)
@@ -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];
index 75317b4954b87b3d0cfb43f9abd5170a3af1f1c2..2510c122ba687d91ce501658a2d5f3d6ce7f8118 100644 (file)
@@ -179,6 +179,13 @@ ENDTEST
 byteidx
 byteidxcomp
 
+STARTTEST
+/^substitute
+:let y = substitute('123', '\zs', 'a', 'g')    | put =y
+ENDTEST
+
+substitute
+
 STARTTEST
 :g/^STARTTEST/.,/^ENDTEST/d
 :1;/^Results/,$wq! test.out
index 41cd9d02c3252481aee2387dd2c08a5954f7a26f..af8befb0c73a28e0f954ba72815c2d9f7be1606a 100644 (file)
@@ -160,3 +160,7 @@ byteidxcomp
 [0, 1, 3, 4, -1]
 [0, 1, 2, 4, 5, -1]
 
+
+substitute
+a1a2a3a
+
index 5556ed7eece493f5cdc53bad2d28416779d46276..93046ddd54a1f0ee06b6d76b15dc4a85c07e96f0 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    323,
 /**/
     322,
 /**/