mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
updated for version 7.2.407
Problem: When using an expression in ":s" backslashes in the result are dropped. (Sergey Goldgaber, Christian Brabandt) Solution: Double backslashes.
This commit is contained in:
parent
70c49c1af4
commit
06975a4a98
15
src/regexp.c
15
src/regexp.c
@ -6963,6 +6963,8 @@ vim_regsub_both(source, dest, copy, magic, backslash)
|
|||||||
eval_result = eval_to_string(source + 2, NULL, TRUE);
|
eval_result = eval_to_string(source + 2, NULL, TRUE);
|
||||||
if (eval_result != NULL)
|
if (eval_result != NULL)
|
||||||
{
|
{
|
||||||
|
int had_backslash = FALSE;
|
||||||
|
|
||||||
for (s = eval_result; *s != NUL; mb_ptr_adv(s))
|
for (s = eval_result; *s != NUL; mb_ptr_adv(s))
|
||||||
{
|
{
|
||||||
/* Change NL to CR, so that it becomes a line break.
|
/* Change NL to CR, so that it becomes a line break.
|
||||||
@ -6970,7 +6972,20 @@ vim_regsub_both(source, dest, copy, magic, backslash)
|
|||||||
if (*s == NL)
|
if (*s == NL)
|
||||||
*s = CAR;
|
*s = CAR;
|
||||||
else if (*s == '\\' && s[1] != NUL)
|
else if (*s == '\\' && s[1] != NUL)
|
||||||
|
{
|
||||||
++s;
|
++s;
|
||||||
|
had_backslash = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (had_backslash && backslash)
|
||||||
|
{
|
||||||
|
/* Backslashes will be consumed, need to double them. */
|
||||||
|
s = vim_strsave_escaped(eval_result, (char_u *)"\\");
|
||||||
|
if (s != NULL)
|
||||||
|
{
|
||||||
|
vim_free(eval_result);
|
||||||
|
eval_result = s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dst += STRLEN(eval_result);
|
dst += STRLEN(eval_result);
|
||||||
|
@ -681,6 +681,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 */
|
||||||
|
/**/
|
||||||
|
407,
|
||||||
/**/
|
/**/
|
||||||
406,
|
406,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user