diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-03-23 16:27:22 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-03-23 16:27:22 +0100 |
commit | 06975a4a98b4ae6ec3e1a18f4ccdf8704bf921cc (patch) | |
tree | b8e95398363f15bb543a563702b0e3f13fd3e682 /src/regexp.c | |
parent | 70c49c1af4e2250210bf0528a6763be181a98c46 (diff) | |
download | vim-06975a4a98b4ae6ec3e1a18f4ccdf8704bf921cc.zip |
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.
Diffstat (limited to 'src/regexp.c')
-rw-r--r-- | src/regexp.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/regexp.c b/src/regexp.c index 037222e00..216bf3a18 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -6963,6 +6963,8 @@ vim_regsub_both(source, dest, copy, magic, backslash) eval_result = eval_to_string(source + 2, NULL, TRUE); if (eval_result != NULL) { + int had_backslash = FALSE; + for (s = eval_result; *s != NUL; mb_ptr_adv(s)) { /* 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) *s = CAR; else if (*s == '\\' && s[1] != NUL) + { ++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); |