Karsten Hopp 79b02e
To: vim-dev@vim.org
Karsten Hopp 79b02e
Subject: Patch 7.2.407
Karsten Hopp 79b02e
Fcc: outbox
Karsten Hopp 79b02e
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 79b02e
Mime-Version: 1.0
Karsten Hopp 79b02e
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 79b02e
Content-Transfer-Encoding: 8bit
Karsten Hopp 79b02e
------------
Karsten Hopp 79b02e
Karsten Hopp 79b02e
Patch 7.2.407
Karsten Hopp 79b02e
Problem:    When using an expression in ":s" backslashes in the result are
Karsten Hopp 79b02e
	    dropped. (Sergey Goldgaber, Christian Brabandt)
Karsten Hopp 79b02e
Solution:   Double backslashes.
Karsten Hopp 79b02e
Files:	    src/regexp.c
Karsten Hopp 79b02e
Karsten Hopp 79b02e
Karsten Hopp 79b02e
*** ../vim-7.2.406/src/regexp.c	2009-11-26 20:41:19.000000000 +0100
Karsten Hopp 79b02e
--- src/regexp.c	2010-03-23 16:22:35.000000000 +0100
Karsten Hopp 79b02e
***************
Karsten Hopp 79b02e
*** 6963,6968 ****
Karsten Hopp 79b02e
--- 6963,6970 ----
Karsten Hopp 79b02e
  	    eval_result = eval_to_string(source + 2, NULL, TRUE);
Karsten Hopp 79b02e
  	    if (eval_result != NULL)
Karsten Hopp 79b02e
  	    {
Karsten Hopp 79b02e
+ 		int had_backslash = FALSE;
Karsten Hopp 79b02e
+ 
Karsten Hopp 79b02e
  		for (s = eval_result; *s != NUL; mb_ptr_adv(s))
Karsten Hopp 79b02e
  		{
Karsten Hopp 79b02e
  		    /* Change NL to CR, so that it becomes a line break.
Karsten Hopp 79b02e
***************
Karsten Hopp 79b02e
*** 6970,6976 ****
Karsten Hopp 79b02e
--- 6972,6991 ----
Karsten Hopp 79b02e
  		    if (*s == NL)
Karsten Hopp 79b02e
  			*s = CAR;
Karsten Hopp 79b02e
  		    else if (*s == '\\' && s[1] != NUL)
Karsten Hopp 79b02e
+ 		    {
Karsten Hopp 79b02e
  			++s;
Karsten Hopp 79b02e
+ 			had_backslash = TRUE;
Karsten Hopp 79b02e
+ 		    }
Karsten Hopp 79b02e
+ 		}
Karsten Hopp 79b02e
+ 		if (had_backslash && backslash)
Karsten Hopp 79b02e
+ 		{
Karsten Hopp 79b02e
+ 		    /* Backslashes will be consumed, need to double them. */
Karsten Hopp 79b02e
+ 		    s = vim_strsave_escaped(eval_result, (char_u *)"\\");
Karsten Hopp 79b02e
+ 		    if (s != NULL)
Karsten Hopp 79b02e
+ 		    {
Karsten Hopp 79b02e
+ 			vim_free(eval_result);
Karsten Hopp 79b02e
+ 			eval_result = s;
Karsten Hopp 79b02e
+ 		    }
Karsten Hopp 79b02e
  		}
Karsten Hopp 79b02e
  
Karsten Hopp 79b02e
  		dst += STRLEN(eval_result);
Karsten Hopp 79b02e
*** ../vim-7.2.406/src/version.c	2010-03-23 15:36:29.000000000 +0100
Karsten Hopp 79b02e
--- src/version.c	2010-03-23 16:26:22.000000000 +0100
Karsten Hopp 79b02e
***************
Karsten Hopp 79b02e
*** 683,684 ****
Karsten Hopp 79b02e
--- 683,686 ----
Karsten Hopp 79b02e
  {   /* Add new patch number below this line */
Karsten Hopp 79b02e
+ /**/
Karsten Hopp 79b02e
+     407,
Karsten Hopp 79b02e
  /**/
Karsten Hopp 79b02e
Karsten Hopp 79b02e
-- 
Karsten Hopp 79b02e
Sorry, no fortune today.
Karsten Hopp 79b02e
Karsten Hopp 79b02e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 79b02e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 79b02e
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 79b02e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///