diff options
author | Bram Moolenaar <Bram@vim.org> | 2011-06-19 04:32:15 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2011-06-19 04:32:15 +0200 |
commit | 978287b8f811d384f32fc9b85063f41e2e08f5e2 (patch) | |
tree | 789a566320017ba542ed9a5d7a402e2f8cceb0da /src/regexp.c | |
parent | 5f8949656acb8b2a850d59f685865938862e4f6d (diff) | |
download | vim-git-978287b8f811d384f32fc9b85063f41e2e08f5e2.tar.gz |
updated for version 7.3.225v7.3.225
Problem: Using "\n" in a substitute inside ":s" does not result in a line
break.
Solution: Change behavior inside vim_regexec_nl(). Add tests. (Motoya
Kurotsu)
Diffstat (limited to 'src/regexp.c')
-rw-r--r-- | src/regexp.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/regexp.c b/src/regexp.c index 57ea73696..a09ab6194 100644 --- a/src/regexp.c +++ b/src/regexp.c @@ -6872,6 +6872,7 @@ static regmatch_T *submatch_match; static regmmatch_T *submatch_mmatch; static linenr_T submatch_firstlnum; static linenr_T submatch_maxline; +static int submatch_line_lbr; #endif #if defined(FEAT_MODIFY_FNAME) || defined(FEAT_EVAL) || defined(PROTO) @@ -6998,6 +6999,7 @@ vim_regsub_both(source, dest, copy, magic, backslash) submatch_mmatch = reg_mmatch; submatch_firstlnum = reg_firstlnum; submatch_maxline = reg_maxline; + submatch_line_lbr = reg_line_lbr; save_reg_win = reg_win; save_ireg_ic = ireg_ic; can_f_submatch = TRUE; @@ -7009,9 +7011,10 @@ vim_regsub_both(source, dest, copy, magic, backslash) 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, + * unless called from vim_regexec_nl(). * Skip over a backslashed character. */ - if (*s == NL) + if (*s == NL && !submatch_line_lbr) *s = CAR; else if (*s == '\\' && s[1] != NUL) { @@ -7020,8 +7023,9 @@ vim_regsub_both(source, dest, copy, magic, backslash) * :s/abc\\\ndef/\="aaa\\\nbbb"/ on text: * abc\ * def + * Not when called from vim_regexec_nl(). */ - if (*s == NL) + if (*s == NL && !submatch_line_lbr) *s = CAR; had_backslash = TRUE; } @@ -7044,6 +7048,7 @@ vim_regsub_both(source, dest, copy, magic, backslash) reg_mmatch = submatch_mmatch; reg_firstlnum = submatch_firstlnum; reg_maxline = submatch_maxline; + reg_line_lbr = submatch_line_lbr; reg_win = save_reg_win; ireg_ic = save_ireg_ic; can_f_submatch = FALSE; |