updated for version 7.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)
diff --git a/src/regexp.c b/src/regexp.c
index 57ea736..a09ab61 100644
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -6872,6 +6872,7 @@
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 @@
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 @@
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 @@
* :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 @@
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;