Karsten Hopp 529c0b
To: vim-dev@vim.org
Karsten Hopp 529c0b
Subject: patch 7.1.123
Karsten Hopp 529c0b
Fcc: outbox
Karsten Hopp 529c0b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 529c0b
Mime-Version: 1.0
Karsten Hopp 529c0b
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 529c0b
Content-Transfer-Encoding: 8bit
Karsten Hopp 529c0b
------------
Karsten Hopp 529c0b
Karsten Hopp 529c0b
Patch 7.1.123
Karsten Hopp 529c0b
Problem:    Win32: ":edit foo ~ foo" expands "~".
Karsten Hopp 529c0b
Solution:   Change the call to expand_env().
Karsten Hopp 529c0b
Files:	    src/ex_docmd.c, src/misc1.c, src/proto/misc1.pro, src/option.c
Karsten Hopp 529c0b
Karsten Hopp 529c0b
Karsten Hopp 529c0b
*** ../vim-7.1.122/src/ex_docmd.c	Sun Aug 19 22:42:27 2007
Karsten Hopp 529c0b
--- src/ex_docmd.c	Wed Sep 26 20:29:36 2007
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 4403,4409 ****
Karsten Hopp 529c0b
  			    || vim_strchr(eap->arg, '~') != NULL)
Karsten Hopp 529c0b
  		    {
Karsten Hopp 529c0b
  			expand_env_esc(eap->arg, NameBuff, MAXPATHL,
Karsten Hopp 529c0b
! 								 TRUE, NULL);
Karsten Hopp 529c0b
  			has_wildcards = mch_has_wildcard(NameBuff);
Karsten Hopp 529c0b
  			p = NameBuff;
Karsten Hopp 529c0b
  		    }
Karsten Hopp 529c0b
--- 4402,4408 ----
Karsten Hopp 529c0b
  			    || vim_strchr(eap->arg, '~') != NULL)
Karsten Hopp 529c0b
  		    {
Karsten Hopp 529c0b
  			expand_env_esc(eap->arg, NameBuff, MAXPATHL,
Karsten Hopp 529c0b
! 							    TRUE, TRUE, NULL);
Karsten Hopp 529c0b
  			has_wildcards = mch_has_wildcard(NameBuff);
Karsten Hopp 529c0b
  			p = NameBuff;
Karsten Hopp 529c0b
  		    }
Karsten Hopp 529c0b
*** ../vim-7.1.122/src/misc1.c	Tue Aug 14 22:15:53 2007
Karsten Hopp 529c0b
--- src/misc1.c	Tue Sep 25 17:30:01 2007
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 3506,3514 ****
Karsten Hopp 529c0b
  #endif
Karsten Hopp 529c0b
  
Karsten Hopp 529c0b
  /*
Karsten Hopp 529c0b
   * Expand environment variable with path name.
Karsten Hopp 529c0b
   * "~/" is also expanded, using $HOME.	For Unix "~user/" is expanded.
Karsten Hopp 529c0b
!  * Skips over "\ ", "\~" and "\$".
Karsten Hopp 529c0b
   * If anything fails no expansion is done and dst equals src.
Karsten Hopp 529c0b
   */
Karsten Hopp 529c0b
      void
Karsten Hopp 529c0b
--- 3506,3543 ----
Karsten Hopp 529c0b
  #endif
Karsten Hopp 529c0b
  
Karsten Hopp 529c0b
  /*
Karsten Hopp 529c0b
+  * Call expand_env() and store the result in an allocated string.
Karsten Hopp 529c0b
+  * This is not very memory efficient, this expects the result to be freed
Karsten Hopp 529c0b
+  * again soon.
Karsten Hopp 529c0b
+  */
Karsten Hopp 529c0b
+     char_u *
Karsten Hopp 529c0b
+ expand_env_save(src)
Karsten Hopp 529c0b
+     char_u	*src;
Karsten Hopp 529c0b
+ {
Karsten Hopp 529c0b
+     return expand_env_save_opt(src, FALSE);
Karsten Hopp 529c0b
+ }
Karsten Hopp 529c0b
+ 
Karsten Hopp 529c0b
+ /*
Karsten Hopp 529c0b
+  * Idem, but when "one" is TRUE handle the string as one file name, only
Karsten Hopp 529c0b
+  * expand "~" at the start.
Karsten Hopp 529c0b
+  */
Karsten Hopp 529c0b
+     char_u *
Karsten Hopp 529c0b
+ expand_env_save_opt(src, one)
Karsten Hopp 529c0b
+     char_u	*src;
Karsten Hopp 529c0b
+     int		one;
Karsten Hopp 529c0b
+ {
Karsten Hopp 529c0b
+     char_u	*p;
Karsten Hopp 529c0b
+ 
Karsten Hopp 529c0b
+     p = alloc(MAXPATHL);
Karsten Hopp 529c0b
+     if (p != NULL)
Karsten Hopp 529c0b
+ 	expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL);
Karsten Hopp 529c0b
+     return p;
Karsten Hopp 529c0b
+ }
Karsten Hopp 529c0b
+ 
Karsten Hopp 529c0b
+ /*
Karsten Hopp 529c0b
   * Expand environment variable with path name.
Karsten Hopp 529c0b
   * "~/" is also expanded, using $HOME.	For Unix "~user/" is expanded.
Karsten Hopp 529c0b
!  * Skips over "\ ", "\~" and "\$" (not for Win32 though).
Karsten Hopp 529c0b
   * If anything fails no expansion is done and dst equals src.
Karsten Hopp 529c0b
   */
Karsten Hopp 529c0b
      void
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 3517,3531 ****
Karsten Hopp 529c0b
      char_u	*dst;		/* where to put the result */
Karsten Hopp 529c0b
      int		dstlen;		/* maximum length of the result */
Karsten Hopp 529c0b
  {
Karsten Hopp 529c0b
!     expand_env_esc(src, dst, dstlen, FALSE, NULL);
Karsten Hopp 529c0b
  }
Karsten Hopp 529c0b
  
Karsten Hopp 529c0b
      void
Karsten Hopp 529c0b
! expand_env_esc(srcp, dst, dstlen, esc, startstr)
Karsten Hopp 529c0b
      char_u	*srcp;		/* input string e.g. "$HOME/vim.hlp" */
Karsten Hopp 529c0b
      char_u	*dst;		/* where to put the result */
Karsten Hopp 529c0b
      int		dstlen;		/* maximum length of the result */
Karsten Hopp 529c0b
      int		esc;		/* escape spaces in expanded variables */
Karsten Hopp 529c0b
      char_u	*startstr;	/* start again after this (can be NULL) */
Karsten Hopp 529c0b
  {
Karsten Hopp 529c0b
      char_u	*src;
Karsten Hopp 529c0b
--- 3546,3561 ----
Karsten Hopp 529c0b
      char_u	*dst;		/* where to put the result */
Karsten Hopp 529c0b
      int		dstlen;		/* maximum length of the result */
Karsten Hopp 529c0b
  {
Karsten Hopp 529c0b
!     expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL);
Karsten Hopp 529c0b
  }
Karsten Hopp 529c0b
  
Karsten Hopp 529c0b
      void
Karsten Hopp 529c0b
! expand_env_esc(srcp, dst, dstlen, esc, one, startstr)
Karsten Hopp 529c0b
      char_u	*srcp;		/* input string e.g. "$HOME/vim.hlp" */
Karsten Hopp 529c0b
      char_u	*dst;		/* where to put the result */
Karsten Hopp 529c0b
      int		dstlen;		/* maximum length of the result */
Karsten Hopp 529c0b
      int		esc;		/* escape spaces in expanded variables */
Karsten Hopp 529c0b
+     int		one;		/* "srcp" is one file name */
Karsten Hopp 529c0b
      char_u	*startstr;	/* start again after this (can be NULL) */
Karsten Hopp 529c0b
  {
Karsten Hopp 529c0b
      char_u	*src;
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 3766,3771 ****
Karsten Hopp 529c0b
--- 3796,3803 ----
Karsten Hopp 529c0b
  	{
Karsten Hopp 529c0b
  	    /*
Karsten Hopp 529c0b
  	     * Recognize the start of a new name, for '~'.
Karsten Hopp 529c0b
+ 	     * Don't do this when "one" is TRUE, to avoid expanding "~" in
Karsten Hopp 529c0b
+ 	     * ":edit foo ~ foo".
Karsten Hopp 529c0b
  	     */
Karsten Hopp 529c0b
  	    at_start = FALSE;
Karsten Hopp 529c0b
  	    if (src[0] == '\\' && src[1] != NUL)
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 3773,3779 ****
Karsten Hopp 529c0b
  		*dst++ = *src++;
Karsten Hopp 529c0b
  		--dstlen;
Karsten Hopp 529c0b
  	    }
Karsten Hopp 529c0b
! 	    else if (src[0] == ' ' || src[0] == ',')
Karsten Hopp 529c0b
  		at_start = TRUE;
Karsten Hopp 529c0b
  	    *dst++ = *src++;
Karsten Hopp 529c0b
  	    --dstlen;
Karsten Hopp 529c0b
--- 3805,3811 ----
Karsten Hopp 529c0b
  		*dst++ = *src++;
Karsten Hopp 529c0b
  		--dstlen;
Karsten Hopp 529c0b
  	    }
Karsten Hopp 529c0b
! 	    else if ((src[0] == ' ' || src[0] == ',') && !one)
Karsten Hopp 529c0b
  		at_start = TRUE;
Karsten Hopp 529c0b
  	    *dst++ = *src++;
Karsten Hopp 529c0b
  	    --dstlen;
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 4070,4092 ****
Karsten Hopp 529c0b
  }
Karsten Hopp 529c0b
  
Karsten Hopp 529c0b
  /*
Karsten Hopp 529c0b
-  * Call expand_env() and store the result in an allocated string.
Karsten Hopp 529c0b
-  * This is not very memory efficient, this expects the result to be freed
Karsten Hopp 529c0b
-  * again soon.
Karsten Hopp 529c0b
-  */
Karsten Hopp 529c0b
-     char_u *
Karsten Hopp 529c0b
- expand_env_save(src)
Karsten Hopp 529c0b
-     char_u	*src;
Karsten Hopp 529c0b
- {
Karsten Hopp 529c0b
-     char_u	*p;
Karsten Hopp 529c0b
- 
Karsten Hopp 529c0b
-     p = alloc(MAXPATHL);
Karsten Hopp 529c0b
-     if (p != NULL)
Karsten Hopp 529c0b
- 	expand_env(src, p, MAXPATHL);
Karsten Hopp 529c0b
-     return p;
Karsten Hopp 529c0b
- }
Karsten Hopp 529c0b
- 
Karsten Hopp 529c0b
- /*
Karsten Hopp 529c0b
   * Our portable version of setenv.
Karsten Hopp 529c0b
   */
Karsten Hopp 529c0b
      void
Karsten Hopp 529c0b
--- 4102,4107 ----
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 9139,9145 ****
Karsten Hopp 529c0b
  	     */
Karsten Hopp 529c0b
  	    if (vim_strpbrk(p, (char_u *)"$~") != NULL)
Karsten Hopp 529c0b
  	    {
Karsten Hopp 529c0b
! 		p = expand_env_save(p);
Karsten Hopp 529c0b
  		if (p == NULL)
Karsten Hopp 529c0b
  		    p = pat[i];
Karsten Hopp 529c0b
  #ifdef UNIX
Karsten Hopp 529c0b
--- 9154,9160 ----
Karsten Hopp 529c0b
  	     */
Karsten Hopp 529c0b
  	    if (vim_strpbrk(p, (char_u *)"$~") != NULL)
Karsten Hopp 529c0b
  	    {
Karsten Hopp 529c0b
! 		p = expand_env_save_opt(p, TRUE);
Karsten Hopp 529c0b
  		if (p == NULL)
Karsten Hopp 529c0b
  		    p = pat[i];
Karsten Hopp 529c0b
  #ifdef UNIX
Karsten Hopp 529c0b
*** ../vim-7.1.122/src/proto/misc1.pro	Sat May  5 20:15:33 2007
Karsten Hopp 529c0b
--- src/proto/misc1.pro	Tue Sep 25 17:22:36 2007
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 48,57 ****
Karsten Hopp 529c0b
  void vim_beep __ARGS((void));
Karsten Hopp 529c0b
  void init_homedir __ARGS((void));
Karsten Hopp 529c0b
  void free_homedir __ARGS((void));
Karsten Hopp 529c0b
  void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
Karsten Hopp 529c0b
! void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
Karsten Hopp 529c0b
  char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
Karsten Hopp 529c0b
- char_u *expand_env_save __ARGS((char_u *src));
Karsten Hopp 529c0b
  void vim_setenv __ARGS((char_u *name, char_u *val));
Karsten Hopp 529c0b
  char_u *get_env_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 529c0b
  void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
Karsten Hopp 529c0b
--- 48,58 ----
Karsten Hopp 529c0b
  void vim_beep __ARGS((void));
Karsten Hopp 529c0b
  void init_homedir __ARGS((void));
Karsten Hopp 529c0b
  void free_homedir __ARGS((void));
Karsten Hopp 529c0b
+ char_u *expand_env_save __ARGS((char_u *src));
Karsten Hopp 529c0b
+ char_u *expand_env_save_opt __ARGS((char_u *src, int one));
Karsten Hopp 529c0b
  void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
Karsten Hopp 529c0b
! void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, int one, char_u *startstr));
Karsten Hopp 529c0b
  char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
Karsten Hopp 529c0b
  void vim_setenv __ARGS((char_u *name, char_u *val));
Karsten Hopp 529c0b
  char_u *get_env_name __ARGS((expand_T *xp, int idx));
Karsten Hopp 529c0b
  void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
Karsten Hopp 529c0b
*** ../vim-7.1.122/src/option.c	Tue Sep 25 14:50:19 2007
Karsten Hopp 529c0b
--- src/option.c	Tue Sep 25 17:20:05 2007
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 4996,5002 ****
Karsten Hopp 529c0b
       * For 'spellsuggest' expand after "file:".
Karsten Hopp 529c0b
       */
Karsten Hopp 529c0b
      expand_env_esc(val, NameBuff, MAXPATHL,
Karsten Hopp 529c0b
! 	    (char_u **)options[opt_idx].var == &p_tags,
Karsten Hopp 529c0b
  #ifdef FEAT_SPELL
Karsten Hopp 529c0b
  	    (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
Karsten Hopp 529c0b
  #endif
Karsten Hopp 529c0b
--- 4996,5002 ----
Karsten Hopp 529c0b
       * For 'spellsuggest' expand after "file:".
Karsten Hopp 529c0b
       */
Karsten Hopp 529c0b
      expand_env_esc(val, NameBuff, MAXPATHL,
Karsten Hopp 529c0b
! 	    (char_u **)options[opt_idx].var == &p_tags, FALSE,
Karsten Hopp 529c0b
  #ifdef FEAT_SPELL
Karsten Hopp 529c0b
  	    (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
Karsten Hopp 529c0b
  #endif
Karsten Hopp 529c0b
*** ../vim-7.1.122/src/version.c	Tue Sep 25 22:13:14 2007
Karsten Hopp 529c0b
--- src/version.c	Wed Sep 26 22:30:59 2007
Karsten Hopp 529c0b
***************
Karsten Hopp 529c0b
*** 668,669 ****
Karsten Hopp 529c0b
--- 668,671 ----
Karsten Hopp 529c0b
  {   /* Add new patch number below this line */
Karsten Hopp 529c0b
+ /**/
Karsten Hopp 529c0b
+     123,
Karsten Hopp 529c0b
  /**/
Karsten Hopp 529c0b
Karsten Hopp 529c0b
-- 
Karsten Hopp 529c0b
So when I saw the post to comp.editors, I rushed over to the FTP site to
Karsten Hopp 529c0b
grab it.  So I yank apart the tarball, light x candles, where x= the
Karsten Hopp 529c0b
vim version multiplied by the md5sum of the source divided by the MAC of
Karsten Hopp 529c0b
my NIC (8A3FA78155A8A1D346C3C4A), put on black robes, dim the lights,
Karsten Hopp 529c0b
wave a dead chicken over the hard drive, and summon the power of GNU GCC
Karsten Hopp 529c0b
with the magic words "make config ; make!".
Karsten Hopp 529c0b
		[Jason Spence, compiling Vim 5.0]
Karsten Hopp 529c0b
Karsten Hopp 529c0b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 529c0b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 529c0b
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 529c0b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///