]>
Commit | Line | Data |
---|---|---|
25f687b8 AM |
1 | To: vim-dev@vim.org |
2 | Subject: patch 7.1.123 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.1.123 | |
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 | |
14 | ||
15 | ||
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 | |
18 | *************** | |
19 | *** 4403,4409 **** | |
20 | || vim_strchr(eap->arg, '~') != NULL) | |
21 | { | |
22 | expand_env_esc(eap->arg, NameBuff, MAXPATHL, | |
23 | ! TRUE, NULL); | |
24 | has_wildcards = mch_has_wildcard(NameBuff); | |
25 | p = NameBuff; | |
26 | } | |
27 | --- 4402,4408 ---- | |
28 | || vim_strchr(eap->arg, '~') != NULL) | |
29 | { | |
30 | expand_env_esc(eap->arg, NameBuff, MAXPATHL, | |
31 | ! TRUE, TRUE, NULL); | |
32 | has_wildcards = mch_has_wildcard(NameBuff); | |
33 | p = NameBuff; | |
34 | } | |
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 | |
37 | *************** | |
38 | *** 3506,3514 **** | |
39 | #endif | |
40 | ||
41 | /* | |
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. | |
46 | */ | |
47 | void | |
48 | --- 3506,3543 ---- | |
49 | #endif | |
50 | ||
51 | /* | |
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 | |
54 | + * again soon. | |
55 | + */ | |
56 | + char_u * | |
57 | + expand_env_save(src) | |
58 | + char_u *src; | |
59 | + { | |
60 | + return expand_env_save_opt(src, FALSE); | |
61 | + } | |
62 | + | |
63 | + /* | |
64 | + * Idem, but when "one" is TRUE handle the string as one file name, only | |
65 | + * expand "~" at the start. | |
66 | + */ | |
67 | + char_u * | |
68 | + expand_env_save_opt(src, one) | |
69 | + char_u *src; | |
70 | + int one; | |
71 | + { | |
72 | + char_u *p; | |
73 | + | |
74 | + p = alloc(MAXPATHL); | |
75 | + if (p != NULL) | |
76 | + expand_env_esc(src, p, MAXPATHL, FALSE, one, NULL); | |
77 | + return p; | |
78 | + } | |
79 | + | |
80 | + /* | |
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. | |
85 | */ | |
86 | void | |
87 | *************** | |
88 | *** 3517,3531 **** | |
89 | char_u *dst; /* where to put the result */ | |
90 | int dstlen; /* maximum length of the result */ | |
91 | { | |
92 | ! expand_env_esc(src, dst, dstlen, FALSE, NULL); | |
93 | } | |
94 | ||
95 | void | |
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) */ | |
102 | { | |
103 | char_u *src; | |
104 | --- 3546,3561 ---- | |
105 | char_u *dst; /* where to put the result */ | |
106 | int dstlen; /* maximum length of the result */ | |
107 | { | |
108 | ! expand_env_esc(src, dst, dstlen, FALSE, FALSE, NULL); | |
109 | } | |
110 | ||
111 | void | |
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) */ | |
119 | { | |
120 | char_u *src; | |
121 | *************** | |
122 | *** 3766,3771 **** | |
123 | --- 3796,3803 ---- | |
124 | { | |
125 | /* | |
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". | |
129 | */ | |
130 | at_start = FALSE; | |
131 | if (src[0] == '\\' && src[1] != NUL) | |
132 | *************** | |
133 | *** 3773,3779 **** | |
134 | *dst++ = *src++; | |
135 | --dstlen; | |
136 | } | |
137 | ! else if (src[0] == ' ' || src[0] == ',') | |
138 | at_start = TRUE; | |
139 | *dst++ = *src++; | |
140 | --dstlen; | |
141 | --- 3805,3811 ---- | |
142 | *dst++ = *src++; | |
143 | --dstlen; | |
144 | } | |
145 | ! else if ((src[0] == ' ' || src[0] == ',') && !one) | |
146 | at_start = TRUE; | |
147 | *dst++ = *src++; | |
148 | --dstlen; | |
149 | *************** | |
150 | *** 4070,4092 **** | |
151 | } | |
152 | ||
153 | /* | |
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 | |
156 | - * again soon. | |
157 | - */ | |
158 | - char_u * | |
159 | - expand_env_save(src) | |
160 | - char_u *src; | |
161 | - { | |
162 | - char_u *p; | |
163 | - | |
164 | - p = alloc(MAXPATHL); | |
165 | - if (p != NULL) | |
166 | - expand_env(src, p, MAXPATHL); | |
167 | - return p; | |
168 | - } | |
169 | - | |
170 | - /* | |
171 | * Our portable version of setenv. | |
172 | */ | |
173 | void | |
174 | --- 4102,4107 ---- | |
175 | *************** | |
176 | *** 9139,9145 **** | |
177 | */ | |
178 | if (vim_strpbrk(p, (char_u *)"$~") != NULL) | |
179 | { | |
180 | ! p = expand_env_save(p); | |
181 | if (p == NULL) | |
182 | p = pat[i]; | |
183 | #ifdef UNIX | |
184 | --- 9154,9160 ---- | |
185 | */ | |
186 | if (vim_strpbrk(p, (char_u *)"$~") != NULL) | |
187 | { | |
188 | ! p = expand_env_save_opt(p, TRUE); | |
189 | if (p == NULL) | |
190 | p = pat[i]; | |
191 | #ifdef UNIX | |
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 | |
194 | *************** | |
195 | *** 48,57 **** | |
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)); | |
206 | --- 48,58 ---- | |
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 | |
220 | *************** | |
221 | *** 4996,5002 **** | |
222 | * For 'spellsuggest' expand after "file:". | |
223 | */ | |
224 | expand_env_esc(val, NameBuff, MAXPATHL, | |
225 | ! (char_u **)options[opt_idx].var == &p_tags, | |
226 | #ifdef FEAT_SPELL | |
227 | (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : | |
228 | #endif | |
229 | --- 4996,5002 ---- | |
230 | * For 'spellsuggest' expand after "file:". | |
231 | */ | |
232 | expand_env_esc(val, NameBuff, MAXPATHL, | |
233 | ! (char_u **)options[opt_idx].var == &p_tags, FALSE, | |
234 | #ifdef FEAT_SPELL | |
235 | (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" : | |
236 | #endif | |
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 | |
239 | *************** | |
240 | *** 668,669 **** | |
241 | --- 668,671 ---- | |
242 | { /* Add new patch number below this line */ | |
243 | + /**/ | |
244 | + 123, | |
245 | /**/ | |
246 | ||
247 | -- | |
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] | |
255 | ||
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 /// |