Karsten Hopp 68414b
To: vim-dev@vim.org
Karsten Hopp 68414b
Subject: patch 7.0.224
Karsten Hopp 68414b
Fcc: outbox
Karsten Hopp 68414b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 68414b
Mime-Version: 1.0
Karsten Hopp 68414b
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 68414b
Content-Transfer-Encoding: 8bit
Karsten Hopp 68414b
------------
Karsten Hopp 68414b
Karsten Hopp 68414b
Patch 7.0.224
Karsten Hopp 68414b
Problem:    When expanding "##" spaces are escaped twice.  (Pavol Juhas)
Karsten Hopp 68414b
Solution:   Don't escape the spaces that separate arguments.
Karsten Hopp 68414b
Files:	    src/eval.c, src/ex_docmd.c, src/proto/ex_docmd.pro
Karsten Hopp 68414b
Karsten Hopp 68414b
Karsten Hopp 68414b
*** ../vim-7.0.223/src/eval.c	Tue Mar 27 10:20:59 2007
Karsten Hopp 68414b
--- src/eval.c	Tue Mar 27 16:47:56 2007
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 8924,8930 ****
Karsten Hopp 68414b
      if (*s == '%' || *s == '#' || *s == '<')
Karsten Hopp 68414b
      {
Karsten Hopp 68414b
  	++emsg_off;
Karsten Hopp 68414b
! 	rettv->vval.v_string = eval_vars(s, &len, NULL, &errormsg, s);
Karsten Hopp 68414b
  	--emsg_off;
Karsten Hopp 68414b
      }
Karsten Hopp 68414b
      else
Karsten Hopp 68414b
--- 8924,8930 ----
Karsten Hopp 68414b
      if (*s == '%' || *s == '#' || *s == '<')
Karsten Hopp 68414b
      {
Karsten Hopp 68414b
  	++emsg_off;
Karsten Hopp 68414b
! 	rettv->vval.v_string = eval_vars(s, s, &len, NULL, &errormsg, NULL);
Karsten Hopp 68414b
  	--emsg_off;
Karsten Hopp 68414b
      }
Karsten Hopp 68414b
      else
Karsten Hopp 68414b
*** ../vim-7.0.223/src/ex_docmd.c	Sun Mar 11 15:53:27 2007
Karsten Hopp 68414b
--- src/ex_docmd.c	Tue Mar 27 16:49:06 2007
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 4176,4181 ****
Karsten Hopp 68414b
--- 4177,4183 ----
Karsten Hopp 68414b
      int		srclen;
Karsten Hopp 68414b
      char_u	*p;
Karsten Hopp 68414b
      int		n;
Karsten Hopp 68414b
+     int		escaped;
Karsten Hopp 68414b
  
Karsten Hopp 68414b
  #ifdef FEAT_QUICKFIX
Karsten Hopp 68414b
      /* Skip a regexp pattern for ":vimgrep[add] pat file..." */
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 4216,4222 ****
Karsten Hopp 68414b
  	/*
Karsten Hopp 68414b
  	 * Try to find a match at this position.
Karsten Hopp 68414b
  	 */
Karsten Hopp 68414b
! 	repl = eval_vars(p, &srclen, &(eap->do_ecmd_lnum), errormsgp, eap->arg);
Karsten Hopp 68414b
  	if (*errormsgp != NULL)		/* error detected */
Karsten Hopp 68414b
  	    return FAIL;
Karsten Hopp 68414b
  	if (repl == NULL)		/* no match found */
Karsten Hopp 68414b
--- 4218,4225 ----
Karsten Hopp 68414b
  	/*
Karsten Hopp 68414b
  	 * Try to find a match at this position.
Karsten Hopp 68414b
  	 */
Karsten Hopp 68414b
! 	repl = eval_vars(p, eap->arg, &srclen, &(eap->do_ecmd_lnum),
Karsten Hopp 68414b
! 							 errormsgp, &escaped);
Karsten Hopp 68414b
  	if (*errormsgp != NULL)		/* error detected */
Karsten Hopp 68414b
  	    return FAIL;
Karsten Hopp 68414b
  	if (repl == NULL)		/* no match found */
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 4235,4245 ****
Karsten Hopp 68414b
  	    vim_free(l);
Karsten Hopp 68414b
  	}
Karsten Hopp 68414b
  
Karsten Hopp 68414b
! 	/* Need to escape white space et al. with a backslash.  Don't do this
Karsten Hopp 68414b
! 	 * for shell commands (may have to use quotes instead).  Don't do this
Karsten Hopp 68414b
! 	 * for non-unix systems when there is a single argument (spaces don't
Karsten Hopp 68414b
! 	 * separate arguments then). */
Karsten Hopp 68414b
  	if (!eap->usefilter
Karsten Hopp 68414b
  		&& eap->cmdidx != CMD_bang
Karsten Hopp 68414b
  		&& eap->cmdidx != CMD_make
Karsten Hopp 68414b
  		&& eap->cmdidx != CMD_lmake
Karsten Hopp 68414b
--- 4238,4252 ----
Karsten Hopp 68414b
  	    vim_free(l);
Karsten Hopp 68414b
  	}
Karsten Hopp 68414b
  
Karsten Hopp 68414b
! 	/* Need to escape white space et al. with a backslash.
Karsten Hopp 68414b
! 	 * Don't do this for:
Karsten Hopp 68414b
! 	 * - replacement that already has been escaped: "##"
Karsten Hopp 68414b
! 	 * - shell commands (may have to use quotes instead).
Karsten Hopp 68414b
! 	 * - non-unix systems when there is a single argument (spaces don't
Karsten Hopp 68414b
! 	 *   separate arguments then).
Karsten Hopp 68414b
! 	 */
Karsten Hopp 68414b
  	if (!eap->usefilter
Karsten Hopp 68414b
+ 		&& !escaped
Karsten Hopp 68414b
  		&& eap->cmdidx != CMD_bang
Karsten Hopp 68414b
  		&& eap->cmdidx != CMD_make
Karsten Hopp 68414b
  		&& eap->cmdidx != CMD_lmake
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 9280,9291 ****
Karsten Hopp 68414b
   * number of characters to skip.
Karsten Hopp 68414b
   */
Karsten Hopp 68414b
      char_u *
Karsten Hopp 68414b
! eval_vars(src, usedlen, lnump, errormsg, srcstart)
Karsten Hopp 68414b
      char_u	*src;		/* pointer into commandline */
Karsten Hopp 68414b
      int		*usedlen;	/* characters after src that are used */
Karsten Hopp 68414b
      linenr_T	*lnump;		/* line number for :e command, or NULL */
Karsten Hopp 68414b
      char_u	**errormsg;	/* pointer to error message */
Karsten Hopp 68414b
!     char_u	*srcstart;	/* beginning of valid memory for src */
Karsten Hopp 68414b
  {
Karsten Hopp 68414b
      int		i;
Karsten Hopp 68414b
      char_u	*s;
Karsten Hopp 68414b
--- 9289,9302 ----
Karsten Hopp 68414b
   * number of characters to skip.
Karsten Hopp 68414b
   */
Karsten Hopp 68414b
      char_u *
Karsten Hopp 68414b
! eval_vars(src, srcstart, usedlen, lnump, errormsg, escaped)
Karsten Hopp 68414b
      char_u	*src;		/* pointer into commandline */
Karsten Hopp 68414b
+     char_u	*srcstart;	/* beginning of valid memory for src */
Karsten Hopp 68414b
      int		*usedlen;	/* characters after src that are used */
Karsten Hopp 68414b
      linenr_T	*lnump;		/* line number for :e command, or NULL */
Karsten Hopp 68414b
      char_u	**errormsg;	/* pointer to error message */
Karsten Hopp 68414b
!     int		*escaped;	/* return value has escaped white space (can
Karsten Hopp 68414b
! 				 * be NULL) */
Karsten Hopp 68414b
  {
Karsten Hopp 68414b
      int		i;
Karsten Hopp 68414b
      char_u	*s;
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 9332,9337 ****
Karsten Hopp 68414b
--- 9343,9350 ----
Karsten Hopp 68414b
  #endif
Karsten Hopp 68414b
  
Karsten Hopp 68414b
      *errormsg = NULL;
Karsten Hopp 68414b
+     if (escaped != NULL)
Karsten Hopp 68414b
+ 	*escaped = FALSE;
Karsten Hopp 68414b
  
Karsten Hopp 68414b
      /*
Karsten Hopp 68414b
       * Check if there is something to do.
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 9407,9412 ****
Karsten Hopp 68414b
--- 9420,9427 ----
Karsten Hopp 68414b
  		    result = arg_all();
Karsten Hopp 68414b
  		    resultbuf = result;
Karsten Hopp 68414b
  		    *usedlen = 2;
Karsten Hopp 68414b
+ 		    if (escaped != NULL)
Karsten Hopp 68414b
+ 			*escaped = TRUE;
Karsten Hopp 68414b
  #ifdef FEAT_MODIFY_FNAME
Karsten Hopp 68414b
  		    skip_mod = TRUE;
Karsten Hopp 68414b
  #endif
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 9627,9633 ****
Karsten Hopp 68414b
  	else
Karsten Hopp 68414b
  	{
Karsten Hopp 68414b
  	    /* replace "<sfile>" with the sourced file name, and do ":" stuff */
Karsten Hopp 68414b
! 	    repl = eval_vars(p, &srclen, NULL, &errormsg, result);
Karsten Hopp 68414b
  	    if (errormsg != NULL)
Karsten Hopp 68414b
  	    {
Karsten Hopp 68414b
  		if (*errormsg)
Karsten Hopp 68414b
--- 9642,9648 ----
Karsten Hopp 68414b
  	else
Karsten Hopp 68414b
  	{
Karsten Hopp 68414b
  	    /* replace "<sfile>" with the sourced file name, and do ":" stuff */
Karsten Hopp 68414b
! 	    repl = eval_vars(p, result, &srclen, NULL, &errormsg, NULL);
Karsten Hopp 68414b
  	    if (errormsg != NULL)
Karsten Hopp 68414b
  	    {
Karsten Hopp 68414b
  		if (*errormsg)
Karsten Hopp 68414b
*** ../vim-7.0.223/src/proto/ex_docmd.pro	Fri Mar 24 23:02:09 2006
Karsten Hopp 68414b
--- src/proto/ex_docmd.pro	Tue Mar 27 16:50:04 2007
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 44,50 ****
Karsten Hopp 68414b
  extern FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode));
Karsten Hopp 68414b
  extern void update_topline_cursor __ARGS((void));
Karsten Hopp 68414b
  extern void exec_normal_cmd __ARGS((char_u *cmd, int remap, int silent));
Karsten Hopp 68414b
! extern char_u *eval_vars __ARGS((char_u *src, int *usedlen, linenr_T *lnump, char_u **errormsg, char_u *srcstart));
Karsten Hopp 68414b
  extern char_u *expand_sfile __ARGS((char_u *arg));
Karsten Hopp 68414b
  extern int put_eol __ARGS((FILE *fd));
Karsten Hopp 68414b
  extern int put_line __ARGS((FILE *fd, char *s));
Karsten Hopp 68414b
--- 44,50 ----
Karsten Hopp 68414b
  extern FILE *open_exfile __ARGS((char_u *fname, int forceit, char *mode));
Karsten Hopp 68414b
  extern void update_topline_cursor __ARGS((void));
Karsten Hopp 68414b
  extern void exec_normal_cmd __ARGS((char_u *cmd, int remap, int silent));
Karsten Hopp 68414b
! extern char_u *eval_vars __ARGS((char_u *src, char_u *srcstart, int *usedlen, linenr_T *lnump, char_u **errormsg, int *escaped));
Karsten Hopp 68414b
  extern char_u *expand_sfile __ARGS((char_u *arg));
Karsten Hopp 68414b
  extern int put_eol __ARGS((FILE *fd));
Karsten Hopp 68414b
  extern int put_line __ARGS((FILE *fd, char *s));
Karsten Hopp 68414b
*** ../vim-7.0.223/src/version.c	Tue Mar 27 12:43:30 2007
Karsten Hopp 68414b
--- src/version.c	Tue Mar 27 16:55:21 2007
Karsten Hopp 68414b
***************
Karsten Hopp 68414b
*** 668,669 ****
Karsten Hopp 68414b
--- 668,671 ----
Karsten Hopp 68414b
  {   /* Add new patch number below this line */
Karsten Hopp 68414b
+ /**/
Karsten Hopp 68414b
+     224,
Karsten Hopp 68414b
  /**/
Karsten Hopp 68414b
Karsten Hopp 68414b
-- 
Karsten Hopp 68414b
"Software is like sex... it's better when it's free."
Karsten Hopp 68414b
		-- Linus Torvalds, initiator of the free Linux OS
Karsten Hopp 68414b
Makes me wonder what FSF stands for...?
Karsten Hopp 68414b
Karsten Hopp 68414b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 68414b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 68414b
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 68414b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///