| To: vim_dev@googlegroups.com |
| Subject: Patch 7.4.045 |
| 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.045 |
| Problem: substitute() does not work properly when the pattern starts with |
| "\ze". |
| Solution: Detect an empty match. (Christian Brabandt) |
| Files: src/eval.c, src/testdir/test80.in, src/testdir/test80.ok |
| |
| |
| |
| |
| |
| *** 24301,24306 **** |
| --- 24301,24307 ---- |
| garray_T ga; |
| char_u *ret; |
| char_u *save_cpo; |
| + int zero_width; |
| |
| /* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */ |
| save_cpo = p_cpo; |
| |
| *** 24339,24358 **** |
| (void)vim_regsub(®match, sub, (char_u *)ga.ga_data |
| + ga.ga_len + i, TRUE, TRUE, FALSE); |
| ga.ga_len += i + sublen - 1; |
| ! /* avoid getting stuck on a match with an empty string */ |
| ! if (tail == regmatch.endp[0]) |
| { |
| ! if (*tail == NUL) |
| ! break; |
| *((char_u *)ga.ga_data + ga.ga_len) = *tail++; |
| ++ga.ga_len; |
| } |
| - else |
| - { |
| - tail = regmatch.endp[0]; |
| - if (*tail == NUL) |
| - break; |
| - } |
| if (!do_all) |
| break; |
| } |
| --- 24340,24356 ---- |
| (void)vim_regsub(®match, sub, (char_u *)ga.ga_data |
| + ga.ga_len + i, TRUE, TRUE, FALSE); |
| ga.ga_len += i + sublen - 1; |
| ! zero_width = (tail == regmatch.endp[0] |
| ! || regmatch.startp[0] == regmatch.endp[0]); |
| ! tail = regmatch.endp[0]; |
| ! if (*tail == NUL) |
| ! break; |
| ! if (zero_width) |
| { |
| ! /* avoid getting stuck on a match with an empty string */ |
| *((char_u *)ga.ga_data + ga.ga_len) = *tail++; |
| ++ga.ga_len; |
| } |
| if (!do_all) |
| break; |
| } |
| |
| |
| |
| *** 142,147 **** |
| --- 142,149 ---- |
| :$put =\"\n\nTEST_7:\" |
| :$put =substitute('A |
| A', 'A.', '\=submatch(0)', '') |
| :$put =substitute(\"B\nB\", 'B.', '\=submatch(0)', '') |
| + :$put =substitute('-bb', '\zeb', 'a', 'g') |
| + :$put =substitute('-bb', '\ze', 'c', 'g') |
| /^TEST_8 |
| ENDTEST |
| |
| |
| |
| |
| *** 103,108 **** |
| --- 103,110 ---- |
| A |
| A |
| B |
| B |
| + -abab |
| + c-cbcbc |
| |
| |
| TEST_8: |
| |
| |
| |
| *** 740,741 **** |
| --- 740,743 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 45, |
| /**/ |
| |
| -- |
| Just think of all the things we haven't thought of yet. |
| |
| /// 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 /// |