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