]> granicus.if.org Git - vim/commitdiff
updated for version 7.2.407 v7.2.407
authorBram Moolenaar <Bram@vim.org>
Tue, 23 Mar 2010 15:27:22 +0000 (16:27 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 23 Mar 2010 15:27:22 +0000 (16:27 +0100)
Problem:    When using an expression in ":s" backslashes in the result are
            dropped. (Sergey Goldgaber, Christian Brabandt)
Solution:   Double backslashes.

src/regexp.c
src/version.c

index 037222e00c5d1b3180d4ea1991cf6e4a33d92adb..216bf3a18e2586046a03d5608e9ad904fbba14b2 100644 (file)
@@ -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);
index 59092b38e0e687cdbb7fe0a37d1452bfaefd5399..c10a627e8fa98e64f36a1ce7bfa648b581043546 100644 (file)
@@ -681,6 +681,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    407,
 /**/
     406,
 /**/