| To: vim_dev@googlegroups.com |
| Subject: Patch 7.4.323 |
| Fcc: outbox |
| From: Bram Moolenaar <Bram@moolenaar.net> |
| Mime-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| |
| Patch 7.4.323 |
| Problem: Substitute() with zero width pattern breaks multi-byte character. |
| Solution: Take multi-byte character size into account. (Yukihiro Nakadaira) |
| Files: src/eval.c src/testdir/test69.in, src/testdir/test69.ok |
| |
| |
| |
| |
| |
| *** 24848,24855 **** |
| 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; |
| continue; |
| } |
| zero_width = regmatch.startp[0]; |
| --- 24848,24858 ---- |
| if (zero_width == regmatch.startp[0]) |
| { |
| /* avoid getting stuck on a match with an empty string */ |
| ! 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]; |
| |
| |
| |
| *** 180,185 **** |
| --- 180,192 ---- |
| 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 |
| |
| |
| |
| *** 160,162 **** |
| --- 160,166 ---- |
| [0, 1, 3, 4, -1] |
| [0, 1, 2, 4, 5, -1] |
| |
| + |
| + substitute |
| + a1a2a3a |
| + |
| |
| |
| |
| *** 736,737 **** |
| --- 736,739 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 323, |
| /**/ |
| |
| -- |
| When danger reared its ugly head, |
| He bravely turned his tail and fled |
| Yes, Brave Sir Robin turned about |
| And gallantly he chickened out |
| Bravely taking to his feet |
| He beat a very brave retreat |
| Bravest of the brave Sir Robin |
| Petrified of being dead |
| Soiled his pants then brave Sir Robin |
| Turned away and fled. |
| "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD |
| |
| /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ |
| /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
| \\\ an exciting new programming language -- http://www.Zimbu.org /// |
| \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |