mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
updated for version 7.4.045
Problem: substitute() does not work properly when the pattern starts with "\ze". Solution: Detect an empty match. (Christian Brabandt)
This commit is contained in:
18
src/eval.c
18
src/eval.c
@@ -24301,6 +24301,7 @@ do_string_sub(str, pat, sub, flags)
|
|||||||
garray_T ga;
|
garray_T ga;
|
||||||
char_u *ret;
|
char_u *ret;
|
||||||
char_u *save_cpo;
|
char_u *save_cpo;
|
||||||
|
int zero_width;
|
||||||
|
|
||||||
/* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
|
/* Make 'cpoptions' empty, so that the 'l' flag doesn't work here */
|
||||||
save_cpo = p_cpo;
|
save_cpo = p_cpo;
|
||||||
@@ -24339,20 +24340,17 @@ do_string_sub(str, pat, sub, flags)
|
|||||||
(void)vim_regsub(®match, sub, (char_u *)ga.ga_data
|
(void)vim_regsub(®match, sub, (char_u *)ga.ga_data
|
||||||
+ ga.ga_len + i, TRUE, TRUE, FALSE);
|
+ ga.ga_len + i, TRUE, TRUE, FALSE);
|
||||||
ga.ga_len += i + sublen - 1;
|
ga.ga_len += i + sublen - 1;
|
||||||
/* avoid getting stuck on a match with an empty string */
|
zero_width = (tail == regmatch.endp[0]
|
||||||
if (tail == regmatch.endp[0])
|
|| regmatch.startp[0] == regmatch.endp[0]);
|
||||||
|
tail = regmatch.endp[0];
|
||||||
|
if (*tail == NUL)
|
||||||
|
break;
|
||||||
|
if (zero_width)
|
||||||
{
|
{
|
||||||
if (*tail == NUL)
|
/* avoid getting stuck on a match with an empty string */
|
||||||
break;
|
|
||||||
*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
|
*((char_u *)ga.ga_data + ga.ga_len) = *tail++;
|
||||||
++ga.ga_len;
|
++ga.ga_len;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
tail = regmatch.endp[0];
|
|
||||||
if (*tail == NUL)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!do_all)
|
if (!do_all)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -142,6 +142,8 @@ STARTTEST
|
|||||||
:$put =substitute('C', 'C', 'c', '')
|
:$put =substitute('C', 'C', 'c', '')
|
||||||
:$put =substitute('D', 'D', '%', '')
|
:$put =substitute('D', 'D', '%', '')
|
||||||
/^TEST_7
|
/^TEST_7
|
||||||
|
ENDTEST
|
||||||
|
|
||||||
TEST_7:
|
TEST_7:
|
||||||
|
|
||||||
STARTTEST
|
STARTTEST
|
||||||
|
@@ -103,6 +103,8 @@ TEST_7:
|
|||||||
k
|
k
|
||||||
l
|
l
|
||||||
l
|
l
|
||||||
|
|
||||||
|
|
||||||
TEST_5:
|
TEST_5:
|
||||||
A123456789987654321
|
A123456789987654321
|
||||||
|
|
||||||
|
@@ -738,6 +738,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
45,
|
||||||
/**/
|
/**/
|
||||||
44,
|
44,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user