diff options
-rw-r--r-- | src/nvim/eval.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test69.in | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test69.ok | 4 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
4 files changed, 16 insertions, 3 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index af41893035..80f7a65d45 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -18996,8 +18996,10 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags) if (regmatch.startp[0] == regmatch.endp[0]) { 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; + int i = MB_PTR2LEN(tail); + 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]; diff --git a/src/nvim/testdir/test69.in b/src/nvim/testdir/test69.in index 75317b4954..674dc32812 100644 --- a/src/nvim/testdir/test69.in +++ b/src/nvim/testdir/test69.in @@ -180,6 +180,13 @@ 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 ENDTEST diff --git a/src/nvim/testdir/test69.ok b/src/nvim/testdir/test69.ok index 41cd9d02c3..af8befb0c7 100644 --- a/src/nvim/testdir/test69.ok +++ b/src/nvim/testdir/test69.ok @@ -160,3 +160,7 @@ byteidxcomp [0, 1, 3, 4, -1] [0, 1, 2, 4, 5, -1] + +substitute +a1a2a3a + diff --git a/src/nvim/version.c b/src/nvim/version.c index dd39070558..3311b78f49 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -226,7 +226,7 @@ static int included_patches[] = { //326, //325, //324, - //323, + 323, //322, //321, //320, |