lkundrak / rpms / vim

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