4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Win32: ":edit foo ~ foo" expands "~".
12 Solution: Change the call to expand_env().
13 Files: src/ex_docmd.c, src/misc1.c, src/proto/misc1.pro, src/option.c
16 *** ../vim-7.1.122/src/ex_docmd.c Sun Aug 19 22:42:27 2007
17 --- src/ex_docmd.c Wed Sep 26 20:29:36 2007
20 || vim_strchr(eap->arg, '~') != NULL)
22 expand_env_esc(eap->arg, NameBuff, MAXPATHL,
24 has_wildcards = mch_has_wildcard(NameBuff);
28 || vim_strchr(eap->arg, '~') != NULL)
30 expand_env_esc(eap->arg, NameBuff, MAXPATHL,
32 has_wildcards = mch_has_wildcard(NameBuff);
35 *** ../vim-7.1.122/src/misc1.c Tue Aug 14 22:15:53 2007
36 --- src/misc1.c Tue Sep 25 17:30:01 2007
42 * Expand environment variable with path name.
43 * "~/" is also expanded, using $HOME. For Unix "~user/" is expanded.
44 ! * Skips over "\ ", "\~" and "\$".
45 * If anything fails no expansion is done and dst equals src.
52 + * Call expand_env() and store the result in an allocated string.
53 + * This is not very memory efficient, this expects the result to be freed
57 + expand_env_save(src)
60 + return expand_env_save_opt(src, FALSE);
64 + * Idem, but when "one" is TRUE handle the string as one file name, only
65 + * expand "~" at the start.
68 + expand_env_save_opt(src, one)
74 + p = alloc(MAXPATHL);
76 + expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL);
81 * Expand environment variable with path name.
82 * "~/" is also expanded, using $HOME. For Unix "~user/" is expanded.
83 ! * Skips over "\ ", "\~" and "\$" (not for Win32 though).
84 * If anything fails no expansion is done and dst equals src.
89 char_u *dst; /* where to put the result */
90 int dstlen; /* maximum length of the result */
92 ! expand_env_esc(src, dst, dstlen, FALSE, NULL);
96 ! expand_env_esc(srcp, dst, dstlen, esc, startstr)
97 char_u *srcp; /* input string e.g. "$HOME/vim.hlp" */
98 char_u *dst; /* where to put the result */
99 int dstlen; /* maximum length of the result */
100 int esc; /* escape spaces in expanded variables */
101 char_u *startstr; /* start again after this (can be NULL) */
105 char_u *dst; /* where to put the result */
106 int dstlen; /* maximum length of the result */
108 ! expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL);
112 ! expand_env_esc(srcp, dst, dstlen, esc, one, startstr)
113 char_u *srcp; /* input string e.g. "$HOME/vim.hlp" */
114 char_u *dst; /* where to put the result */
115 int dstlen; /* maximum length of the result */
116 int esc; /* escape spaces in expanded variables */
117 + int one; /* "srcp" is one file name */
118 char_u *startstr; /* start again after this (can be NULL) */
126 * Recognize the start of a new name, for '~'.
127 + * Don't do this when "one" is TRUE, to avoid expanding "~" in
128 + * ":edit foo ~ foo".
131 if (src[0] == '\\' && src[1] != NUL)
137 ! else if (src[0] == ' ' || src[0] == ',')
145 ! else if ((src[0] == ' ' || src[0] == ',') && !one)
154 - * Call expand_env() and store the result in an allocated string.
155 - * This is not very memory efficient, this expects the result to be freed
159 - expand_env_save(src)
164 - p = alloc(MAXPATHL);
166 - expand_env(src, p, MAXPATHL);
171 * Our portable version of setenv.
178 if (vim_strpbrk(p, (char_u *)"$~") != NULL)
180 ! p = expand_env_save(p);
186 if (vim_strpbrk(p, (char_u *)"$~") != NULL)
188 ! p = expand_env_save_opt(p, TRUE);
192 *** ../vim-7.1.122/src/proto/misc1.pro Sat May 5 20:15:33 2007
193 --- src/proto/misc1.pro Tue Sep 25 17:22:36 2007
196 void vim_beep __ARGS((void));
197 void init_homedir __ARGS((void));
198 void free_homedir __ARGS((void));
199 void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
200 ! void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, char_u *startstr));
201 char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
202 - char_u *expand_env_save __ARGS((char_u *src));
203 void vim_setenv __ARGS((char_u *name, char_u *val));
204 char_u *get_env_name __ARGS((expand_T *xp, int idx));
205 void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
207 void vim_beep __ARGS((void));
208 void init_homedir __ARGS((void));
209 void free_homedir __ARGS((void));
210 + char_u *expand_env_save __ARGS((char_u *src));
211 + char_u *expand_env_save_opt __ARGS((char_u *src, int one));
212 void expand_env __ARGS((char_u *src, char_u *dst, int dstlen));
213 ! void expand_env_esc __ARGS((char_u *srcp, char_u *dst, int dstlen, int esc, int one, char_u *startstr));
214 char_u *vim_getenv __ARGS((char_u *name, int *mustfree));
215 void vim_setenv __ARGS((char_u *name, char_u *val));
216 char_u *get_env_name __ARGS((expand_T *xp, int idx));
217 void home_replace __ARGS((buf_T *buf, char_u *src, char_u *dst, int dstlen, int one));
218 *** ../vim-7.1.122/src/option.c Tue Sep 25 14:50:19 2007
219 --- src/option.c Tue Sep 25 17:20:05 2007
222 * For 'spellsuggest' expand after "file:".
224 expand_env_esc(val, NameBuff, MAXPATHL,
225 ! (char_u **)options[opt_idx].var == &p_tags,
227 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
230 * For 'spellsuggest' expand after "file:".
232 expand_env_esc(val, NameBuff, MAXPATHL,
233 ! (char_u **)options[opt_idx].var == &p_tags, FALSE,
235 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
237 *** ../vim-7.1.122/src/version.c Tue Sep 25 22:13:14 2007
238 --- src/version.c Wed Sep 26 22:30:59 2007
242 { /* Add new patch number below this line */
248 So when I saw the post to comp.editors, I rushed over to the FTP site to
249 grab it. So I yank apart the tarball, light x candles, where x= the
250 vim version multiplied by the md5sum of the source divided by the MAC of
251 my NIC (8A3FA78155A8A1D346C3C4A), put on black robes, dim the lights,
252 wave a dead chicken over the hard drive, and summon the power of GNU GCC
253 with the magic words "make config ; make!".
254 [Jason Spence, compiling Vim 5.0]
256 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
257 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
258 \\\ download, build and distribute -- http://www.A-A-P.org ///
259 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///