|
|
3ef2ca |
To: vim_dev@googlegroups.com
|
|
|
3ef2ca |
Subject: Patch 7.4.158
|
|
|
3ef2ca |
Fcc: outbox
|
|
|
3ef2ca |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
3ef2ca |
Mime-Version: 1.0
|
|
|
3ef2ca |
Content-Type: text/plain; charset=UTF-8
|
|
|
3ef2ca |
Content-Transfer-Encoding: 8bit
|
|
|
3ef2ca |
------------
|
|
|
3ef2ca |
|
|
|
3ef2ca |
Patch 7.4.158 (after 7.4.045)
|
|
|
3ef2ca |
Problem: Pattern containing \zs is not handled correctly by substitute().
|
|
|
3ef2ca |
Solution: Change how an empty match is skipped. (Yukihiro Nakadaira)
|
|
|
3ef2ca |
Files: src/eval.c, src/testdir/test80.in, src/testdir/test80.ok
|
|
|
3ef2ca |
|
|
|
3ef2ca |
|
|
|
3ef2ca |
*** ../vim-7.4.157/src/eval.c 2014-01-14 19:44:30.000000000 +0100
|
|
|
3ef2ca |
--- src/eval.c 2014-01-23 19:25:23.199796533 +0100
|
|
|
3ef2ca |
***************
|
|
|
3ef2ca |
*** 24365,24371 ****
|
|
|
3ef2ca |
garray_T ga;
|
|
|
3ef2ca |
char_u *ret;
|
|
|
3ef2ca |
char_u *save_cpo;
|
|
|
3ef2ca |
! int zero_width;
|
|
|
3ef2ca |
|
|
|
3ef2ca |
/* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
|
|
|
3ef2ca |
save_cpo = p_cpo;
|
|
|
3ef2ca |
--- 24365,24371 ----
|
|
|
3ef2ca |
garray_T ga;
|
|
|
3ef2ca |
char_u *ret;
|
|
|
3ef2ca |
char_u *save_cpo;
|
|
|
3ef2ca |
! char_u *zero_width = NULL;
|
|
|
3ef2ca |
|
|
|
3ef2ca |
/* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
|
|
|
3ef2ca |
save_cpo = p_cpo;
|
|
|
3ef2ca |
***************
|
|
|
3ef2ca |
*** 24382,24387 ****
|
|
|
3ef2ca |
--- 24382,24400 ----
|
|
|
3ef2ca |
tail = str;
|
|
|
3ef2ca |
while (vim_regexec_nl(®match, str, (colnr_T)(tail - str)))
|
|
|
3ef2ca |
{
|
|
|
3ef2ca |
+ /* Skip empty match except for first match. */
|
|
|
3ef2ca |
+ if (regmatch.startp[0] == regmatch.endp[0])
|
|
|
3ef2ca |
+ {
|
|
|
3ef2ca |
+ if (zero_width == regmatch.startp[0])
|
|
|
3ef2ca |
+ {
|
|
|
3ef2ca |
+ /* avoid getting stuck on a match with an empty string */
|
|
|
3ef2ca |
+ *((char_u *)ga.ga_data + ga.ga_len) = *tail++;
|
|
|
3ef2ca |
+ ++ga.ga_len;
|
|
|
3ef2ca |
+ continue;
|
|
|
3ef2ca |
+ }
|
|
|
3ef2ca |
+ zero_width = regmatch.startp[0];
|
|
|
3ef2ca |
+ }
|
|
|
3ef2ca |
+
|
|
|
3ef2ca |
/*
|
|
|
3ef2ca |
* Get some space for a temporary buffer to do the substitution
|
|
|
3ef2ca |
* into. It will contain:
|
|
|
3ef2ca |
***************
|
|
|
3ef2ca |
*** 24404,24420 ****
|
|
|
3ef2ca |
(void)vim_regsub(®match, sub, (char_u *)ga.ga_data
|
|
|
3ef2ca |
+ ga.ga_len + i, TRUE, TRUE, FALSE);
|
|
|
3ef2ca |
ga.ga_len += i + sublen - 1;
|
|
|
3ef2ca |
- zero_width = (tail == regmatch.endp[0]
|
|
|
3ef2ca |
- || regmatch.startp[0] == regmatch.endp[0]);
|
|
|
3ef2ca |
tail = regmatch.endp[0];
|
|
|
3ef2ca |
if (*tail == NUL)
|
|
|
3ef2ca |
break;
|
|
|
3ef2ca |
- if (zero_width)
|
|
|
3ef2ca |
- {
|
|
|
3ef2ca |
- /* avoid getting stuck on a match with an empty string */
|
|
|
3ef2ca |
- *((char_u *)ga.ga_data + ga.ga_len) = *tail++;
|
|
|
3ef2ca |
- ++ga.ga_len;
|
|
|
3ef2ca |
- }
|
|
|
3ef2ca |
if (!do_all)
|
|
|
3ef2ca |
break;
|
|
|
3ef2ca |
}
|
|
|
3ef2ca |
--- 24417,24425 ----
|
|
|
3ef2ca |
*** ../vim-7.4.157/src/testdir/test80.in 2013-09-29 21:11:00.000000000 +0200
|
|
|
3ef2ca |
--- src/testdir/test80.in 2014-01-23 19:24:30.487795084 +0100
|
|
|
3ef2ca |
***************
|
|
|
3ef2ca |
*** 176,181 ****
|
|
|
3ef2ca |
--- 176,198 ----
|
|
|
3ef2ca |
TEST_10:
|
|
|
3ef2ca |
|
|
|
3ef2ca |
STARTTEST
|
|
|
3ef2ca |
+ :set magic&
|
|
|
3ef2ca |
+ :set cpo&
|
|
|
3ef2ca |
+ :$put =\"\n\nTEST_10:\"
|
|
|
3ef2ca |
+ :let y = substitute('123', '\zs', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ :let y = substitute('123', '\zs.', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ :let y = substitute('123', '.\zs', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ :let y = substitute('123', '\ze', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ :let y = substitute('123', '\ze.', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ :let y = substitute('123', '.\ze', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ :let y = substitute('123', '1\|\ze', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ :let y = substitute('123', '1\zs\|[23]', 'a', 'g') | $put =y
|
|
|
3ef2ca |
+ /^TEST_11
|
|
|
3ef2ca |
+ ENDTEST
|
|
|
3ef2ca |
+
|
|
|
3ef2ca |
+ TEST_11:
|
|
|
3ef2ca |
+
|
|
|
3ef2ca |
+ STARTTEST
|
|
|
3ef2ca |
:/^Results/,$wq! test.out
|
|
|
3ef2ca |
ENDTEST
|
|
|
3ef2ca |
|
|
|
3ef2ca |
*** ../vim-7.4.157/src/testdir/test80.ok 2013-09-29 21:11:00.000000000 +0200
|
|
|
3ef2ca |
--- src/testdir/test80.ok 2014-01-23 19:24:35.691795227 +0100
|
|
|
3ef2ca |
***************
|
|
|
3ef2ca |
*** 115,117 ****
|
|
|
3ef2ca |
--- 115,128 ----
|
|
|
3ef2ca |
|
|
|
3ef2ca |
TEST_9:
|
|
|
3ef2ca |
XXx
|
|
|
3ef2ca |
+
|
|
|
3ef2ca |
+
|
|
|
3ef2ca |
+ TEST_10:
|
|
|
3ef2ca |
+ a1a2a3a
|
|
|
3ef2ca |
+ aaa
|
|
|
3ef2ca |
+ 1a2a3a
|
|
|
3ef2ca |
+ a1a2a3a
|
|
|
3ef2ca |
+ a1a2a3
|
|
|
3ef2ca |
+ aaa
|
|
|
3ef2ca |
+ aa2a3a
|
|
|
3ef2ca |
+ 1aaa
|
|
|
3ef2ca |
*** ../vim-7.4.157/src/version.c 2014-01-23 18:12:44.695676751 +0100
|
|
|
3ef2ca |
--- src/version.c 2014-01-23 19:27:21.611799787 +0100
|
|
|
3ef2ca |
***************
|
|
|
3ef2ca |
*** 740,741 ****
|
|
|
3ef2ca |
--- 740,743 ----
|
|
|
3ef2ca |
{ /* Add new patch number below this line */
|
|
|
3ef2ca |
+ /**/
|
|
|
3ef2ca |
+ 158,
|
|
|
3ef2ca |
/**/
|
|
|
3ef2ca |
|
|
|
3ef2ca |
--
|
|
|
3ef2ca |
$ echo pizza > /dev/oven
|
|
|
3ef2ca |
|
|
|
3ef2ca |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
3ef2ca |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
3ef2ca |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
3ef2ca |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|