]>
Commit | Line | Data |
---|---|---|
04f0bc09 AF |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.063 | |
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 6.2.063 | |
11 | Problem: When using custom completion end up with no matches. | |
12 | Solution: Make cmd_numfiles and cmd_files local to completion to avoid that | |
13 | they are overwritten when ExpandOne() is called recursively by | |
14 | f_glob(). | |
15 | Files: src/eval.c, src/ex_docmd.c, src/ex_getln.c, src/proto/ex_getln.pro, | |
16 | src/misc1.c, src/structs.h, src/tag.c | |
17 | ||
18 | ||
19 | *** ../vim-6.2.062/src/eval.c Sun Jul 27 15:01:56 2003 | |
20 | --- src/eval.c Thu Jul 31 19:47:34 2003 | |
21 | *************** | |
22 | *** 3933,3941 **** | |
23 | * for 'suffixes' and 'wildignore' */ | |
24 | if (argvars[1].var_type != VAR_UNKNOWN && get_var_number(&argvars[1])) | |
25 | flags |= WILD_KEEP_ALL; | |
26 | xpc.xp_context = EXPAND_FILES; | |
27 | - xpc.xp_backslash = XP_BS_NONE; | |
28 | retvar->var_val.var_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL); | |
29 | } | |
30 | } | |
31 | ||
32 | --- 3935,3944 ---- | |
33 | * for 'suffixes' and 'wildignore' */ | |
34 | if (argvars[1].var_type != VAR_UNKNOWN && get_var_number(&argvars[1])) | |
35 | flags |= WILD_KEEP_ALL; | |
36 | + ExpandInit(&xpc); | |
37 | xpc.xp_context = EXPAND_FILES; | |
38 | retvar->var_val.var_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL); | |
39 | + ExpandCleanup(&xpc); | |
40 | } | |
41 | } | |
42 | ||
43 | *************** | |
44 | *** 4543,4553 **** | |
45 | { | |
46 | expand_T xpc; | |
47 | ||
48 | xpc.xp_context = EXPAND_FILES; | |
49 | - xpc.xp_backslash = XP_BS_NONE; | |
50 | retvar->var_type = VAR_STRING; | |
51 | retvar->var_val.var_string = ExpandOne(&xpc, get_var_string(&argvars[0]), | |
52 | NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL); | |
53 | } | |
54 | ||
55 | /* | |
56 | --- 4546,4557 ---- | |
57 | { | |
58 | expand_T xpc; | |
59 | ||
60 | + ExpandInit(&xpc); | |
61 | xpc.xp_context = EXPAND_FILES; | |
62 | retvar->var_type = VAR_STRING; | |
63 | retvar->var_val.var_string = ExpandOne(&xpc, get_var_string(&argvars[0]), | |
64 | NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL); | |
65 | + ExpandCleanup(&xpc); | |
66 | } | |
67 | ||
68 | /* | |
69 | *** ../vim-6.2.062/src/ex_docmd.c Sun Jul 27 14:35:27 2003 | |
70 | --- src/ex_docmd.c Sat Jul 26 18:36:31 2003 | |
71 | *************** | |
72 | *** 3694,3704 **** | |
73 | { | |
74 | expand_T xpc; | |
75 | ||
76 | xpc.xp_context = EXPAND_FILES; | |
77 | ! xpc.xp_backslash = XP_BS_NONE; | |
78 | ! if ((p = ExpandOne(&xpc, eap->arg, NULL, | |
79 | WILD_LIST_NOTFOUND|WILD_ADD_SLASH, | |
80 | ! WILD_EXPAND_FREE)) == NULL) | |
81 | return FAIL; | |
82 | } | |
83 | if (p != NULL) | |
84 | --- 3694,3706 ---- | |
85 | { | |
86 | expand_T xpc; | |
87 | ||
88 | + ExpandInit(&xpc); | |
89 | xpc.xp_context = EXPAND_FILES; | |
90 | ! p = ExpandOne(&xpc, eap->arg, NULL, | |
91 | WILD_LIST_NOTFOUND|WILD_ADD_SLASH, | |
92 | ! WILD_EXPAND_FREE); | |
93 | ! ExpandCleanup(&xpc); | |
94 | ! if (p == NULL) | |
95 | return FAIL; | |
96 | } | |
97 | if (p != NULL) | |
98 | *** ../vim-6.2.062/src/ex_getln.c Thu May 29 22:45:46 2003 | |
99 | --- src/ex_getln.c Sat Jul 26 18:57:18 2003 | |
100 | *************** | |
101 | *** 35,43 **** | |
102 | ||
103 | static struct cmdline_info ccline; /* current cmdline_info */ | |
104 | ||
105 | - static int cmd_numfiles = -1; /* number of files found by | |
106 | - file name completion */ | |
107 | - static char_u **cmd_files = NULL; /* list of files */ | |
108 | static int cmd_showtail; /* Only show path tail in lists ? */ | |
109 | ||
110 | ||
111 | --- 35,40 ---- | |
112 | *************** | |
113 | *** 207,212 **** | |
114 | --- 204,211 ---- | |
115 | ccline.cmdlen = ccline.cmdpos = 0; | |
116 | ccline.cmdbuff[0] = NUL; | |
117 | ||
118 | + ExpandInit(&xpc); | |
119 | + | |
120 | #ifdef FEAT_RIGHTLEFT | |
121 | if (curwin->w_p_rl && *curwin->w_p_rlc == 's' | |
122 | && (firstc == '/' || firstc == '?')) | |
123 | *************** | |
124 | *** 339,345 **** | |
125 | && c != K_PAGEDOWN && c != K_PAGEUP | |
126 | && c != K_KPAGEDOWN && c != K_KPAGEUP | |
127 | && c != K_LEFT && c != K_RIGHT | |
128 | ! && (cmd_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) | |
129 | { | |
130 | vim_free(lookfor); | |
131 | lookfor = NULL; | |
132 | --- 338,344 ---- | |
133 | && c != K_PAGEDOWN && c != K_PAGEUP | |
134 | && c != K_KPAGEDOWN && c != K_KPAGEUP | |
135 | && c != K_LEFT && c != K_RIGHT | |
136 | ! && (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) | |
137 | { | |
138 | vim_free(lookfor); | |
139 | lookfor = NULL; | |
140 | *************** | |
141 | *** 349,355 **** | |
142 | /* | |
143 | * <S-Tab> works like CTRL-P (unless 'wc' is <S-Tab>). | |
144 | */ | |
145 | ! if (c != p_wc && c == K_S_TAB && cmd_numfiles != -1) | |
146 | c = Ctrl_P; | |
147 | ||
148 | #ifdef FEAT_WILDMENU | |
149 | --- 348,354 ---- | |
150 | /* | |
151 | * <S-Tab> works like CTRL-P (unless 'wc' is <S-Tab>). | |
152 | */ | |
153 | ! if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles != -1) | |
154 | c = Ctrl_P; | |
155 | ||
156 | #ifdef FEAT_WILDMENU | |
157 | *************** | |
158 | *** 371,377 **** | |
159 | #endif | |
160 | ||
161 | /* free expanded names when finished walking through matches */ | |
162 | ! if (cmd_numfiles != -1 | |
163 | && !(c == p_wc && KeyTyped) && c != p_wcm | |
164 | && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A | |
165 | && c != Ctrl_L) | |
166 | --- 370,376 ---- | |
167 | #endif | |
168 | ||
169 | /* free expanded names when finished walking through matches */ | |
170 | ! if (xpc.xp_numfiles != -1 | |
171 | && !(c == p_wc && KeyTyped) && c != p_wcm | |
172 | && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A | |
173 | && c != Ctrl_L) | |
174 | *************** | |
175 | *** 629,638 **** | |
176 | */ | |
177 | if ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm) | |
178 | { | |
179 | ! if (cmd_numfiles > 0) /* typed p_wc at least twice */ | |
180 | { | |
181 | /* if 'wildmode' contains "list" may still need to list */ | |
182 | ! if (cmd_numfiles > 1 | |
183 | && !did_wild_list | |
184 | && (wim_flags[wim_index] & WIM_LIST)) | |
185 | { | |
186 | --- 628,637 ---- | |
187 | */ | |
188 | if ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm) | |
189 | { | |
190 | ! if (xpc.xp_numfiles > 0) /* typed p_wc at least twice */ | |
191 | { | |
192 | /* if 'wildmode' contains "list" may still need to list */ | |
193 | ! if (xpc.xp_numfiles > 1 | |
194 | && !did_wild_list | |
195 | && (wim_flags[wim_index] & WIM_LIST)) | |
196 | { | |
197 | *************** | |
198 | *** 673,679 **** | |
199 | /* when more than one match, and 'wildmode' first contains | |
200 | * "list", or no change and 'wildmode' contains "longest,list", | |
201 | * list all matches */ | |
202 | ! if (res == OK && cmd_numfiles > 1) | |
203 | { | |
204 | /* a "longest" that didn't do anything is skipped (but not | |
205 | * "list:longest") */ | |
206 | --- 672,678 ---- | |
207 | /* when more than one match, and 'wildmode' first contains | |
208 | * "list", or no change and 'wildmode' contains "longest,list", | |
209 | * list all matches */ | |
210 | ! if (res == OK && xpc.xp_numfiles > 1) | |
211 | { | |
212 | /* a "longest" that didn't do anything is skipped (but not | |
213 | * "list:longest") */ | |
214 | *************** | |
215 | *** 713,719 **** | |
216 | vim_beep(); | |
217 | } | |
218 | #ifdef FEAT_WILDMENU | |
219 | ! else if (cmd_numfiles == -1) | |
220 | xpc.xp_context = EXPAND_NOTHING; | |
221 | #endif | |
222 | } | |
223 | --- 712,718 ---- | |
224 | vim_beep(); | |
225 | } | |
226 | #ifdef FEAT_WILDMENU | |
227 | ! else if (xpc.xp_numfiles == -1) | |
228 | xpc.xp_context = EXPAND_NOTHING; | |
229 | #endif | |
230 | } | |
231 | *************** | |
232 | *** 1207,1213 **** | |
233 | ||
234 | case Ctrl_N: /* next match */ | |
235 | case Ctrl_P: /* previous match */ | |
236 | ! if (cmd_numfiles > 0) | |
237 | { | |
238 | if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, 0) | |
239 | == FAIL) | |
240 | --- 1206,1212 ---- | |
241 | ||
242 | case Ctrl_N: /* next match */ | |
243 | case Ctrl_P: /* previous match */ | |
244 | ! if (xpc.xp_numfiles > 0) | |
245 | { | |
246 | if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, 0) | |
247 | == FAIL) | |
248 | *************** | |
249 | *** 1529,1534 **** | |
250 | --- 1528,1535 ---- | |
251 | cmd_fkmap = 0; | |
252 | #endif | |
253 | ||
254 | + ExpandCleanup(&xpc); | |
255 | + | |
256 | #ifdef FEAT_SEARCH_EXTRA | |
257 | if (did_incsearch) | |
258 | { | |
259 | *************** | |
260 | *** 2590,2596 **** | |
261 | int difflen; | |
262 | int v; | |
263 | ||
264 | ! if (cmd_numfiles == -1) | |
265 | { | |
266 | set_expand_context(xp); | |
267 | cmd_showtail = !glob_in_path_prefix(xp); | |
268 | --- 2591,2597 ---- | |
269 | int difflen; | |
270 | int v; | |
271 | ||
272 | ! if (xp->xp_numfiles == -1) | |
273 | { | |
274 | set_expand_context(xp); | |
275 | cmd_showtail = !glob_in_path_prefix(xp); | |
276 | *************** | |
277 | *** 2678,2686 **** | |
278 | if (xp->xp_context == EXPAND_MAPPINGS && p2 == NULL) | |
279 | return FAIL; | |
280 | ||
281 | ! if (cmd_numfiles <= 0 && p2 == NULL) | |
282 | beep_flush(); | |
283 | ! else if (cmd_numfiles == 1) | |
284 | /* free expanded pattern */ | |
285 | (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE); | |
286 | ||
287 | --- 2679,2687 ---- | |
288 | if (xp->xp_context == EXPAND_MAPPINGS && p2 == NULL) | |
289 | return FAIL; | |
290 | ||
291 | ! if (xp->xp_numfiles <= 0 && p2 == NULL) | |
292 | beep_flush(); | |
293 | ! else if (xp->xp_numfiles == 1) | |
294 | /* free expanded pattern */ | |
295 | (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE); | |
296 | ||
297 | *************** | |
298 | *** 2693,2699 **** | |
299 | * Return a pointer to alloced memory containing the new string. | |
300 | * Return NULL for failure. | |
301 | * | |
302 | ! * Results are cached in cmd_files and cmd_numfiles. | |
303 | * | |
304 | * mode = WILD_FREE: just free previously expanded matches | |
305 | * mode = WILD_EXPAND_FREE: normal expansion, do not keep matches | |
306 | --- 2694,2700 ---- | |
307 | * Return a pointer to alloced memory containing the new string. | |
308 | * Return NULL for failure. | |
309 | * | |
310 | ! * Results are cached in xp->xp_files and xp->xp_numfiles. | |
311 | * | |
312 | * mode = WILD_FREE: just free previously expanded matches | |
313 | * mode = WILD_EXPAND_FREE: normal expansion, do not keep matches | |
314 | *************** | |
315 | *** 2734,2745 **** | |
316 | */ | |
317 | if (mode == WILD_NEXT || mode == WILD_PREV) | |
318 | { | |
319 | ! if (cmd_numfiles > 0) | |
320 | { | |
321 | if (mode == WILD_PREV) | |
322 | { | |
323 | if (findex == -1) | |
324 | ! findex = cmd_numfiles; | |
325 | --findex; | |
326 | } | |
327 | else /* mode == WILD_NEXT */ | |
328 | --- 2735,2746 ---- | |
329 | */ | |
330 | if (mode == WILD_NEXT || mode == WILD_PREV) | |
331 | { | |
332 | ! if (xp->xp_numfiles > 0) | |
333 | { | |
334 | if (mode == WILD_PREV) | |
335 | { | |
336 | if (findex == -1) | |
337 | ! findex = xp->xp_numfiles; | |
338 | --findex; | |
339 | } | |
340 | else /* mode == WILD_NEXT */ | |
341 | *************** | |
342 | *** 2752,2762 **** | |
343 | if (findex < 0) | |
344 | { | |
345 | if (orig_save == NULL) | |
346 | ! findex = cmd_numfiles - 1; | |
347 | else | |
348 | findex = -1; | |
349 | } | |
350 | ! if (findex >= cmd_numfiles) | |
351 | { | |
352 | if (orig_save == NULL) | |
353 | findex = 0; | |
354 | --- 2753,2763 ---- | |
355 | if (findex < 0) | |
356 | { | |
357 | if (orig_save == NULL) | |
358 | ! findex = xp->xp_numfiles - 1; | |
359 | else | |
360 | findex = -1; | |
361 | } | |
362 | ! if (findex >= xp->xp_numfiles) | |
363 | { | |
364 | if (orig_save == NULL) | |
365 | findex = 0; | |
366 | *************** | |
367 | *** 2765,2786 **** | |
368 | } | |
369 | #ifdef FEAT_WILDMENU | |
370 | if (p_wmnu) | |
371 | ! win_redr_status_matches(xp, cmd_numfiles, cmd_files, findex, | |
372 | ! cmd_showtail); | |
373 | #endif | |
374 | if (findex == -1) | |
375 | return vim_strsave(orig_save); | |
376 | ! return vim_strsave(cmd_files[findex]); | |
377 | } | |
378 | else | |
379 | return NULL; | |
380 | } | |
381 | ||
382 | /* free old names */ | |
383 | ! if (cmd_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) | |
384 | { | |
385 | ! FreeWild(cmd_numfiles, cmd_files); | |
386 | ! cmd_numfiles = -1; | |
387 | vim_free(orig_save); | |
388 | orig_save = NULL; | |
389 | } | |
390 | --- 2766,2787 ---- | |
391 | } | |
392 | #ifdef FEAT_WILDMENU | |
393 | if (p_wmnu) | |
394 | ! win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, | |
395 | ! findex, cmd_showtail); | |
396 | #endif | |
397 | if (findex == -1) | |
398 | return vim_strsave(orig_save); | |
399 | ! return vim_strsave(xp->xp_files[findex]); | |
400 | } | |
401 | else | |
402 | return NULL; | |
403 | } | |
404 | ||
405 | /* free old names */ | |
406 | ! if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) | |
407 | { | |
408 | ! FreeWild(xp->xp_numfiles, xp->xp_files); | |
409 | ! xp->xp_numfiles = -1; | |
410 | vim_free(orig_save); | |
411 | orig_save = NULL; | |
412 | } | |
413 | *************** | |
414 | *** 2789,2795 **** | |
415 | if (mode == WILD_FREE) /* only release file name */ | |
416 | return NULL; | |
417 | ||
418 | ! if (cmd_numfiles == -1) | |
419 | { | |
420 | vim_free(orig_save); | |
421 | orig_save = orig; | |
422 | --- 2790,2796 ---- | |
423 | if (mode == WILD_FREE) /* only release file name */ | |
424 | return NULL; | |
425 | ||
426 | ! if (xp->xp_numfiles == -1) | |
427 | { | |
428 | vim_free(orig_save); | |
429 | orig_save = orig; | |
430 | *************** | |
431 | *** 2797,2803 **** | |
432 | /* | |
433 | * Do the expansion. | |
434 | */ | |
435 | ! if (ExpandFromContext(xp, str, &cmd_numfiles, &cmd_files, | |
436 | options) == FAIL) | |
437 | { | |
438 | #ifdef FNAME_ILLEGAL | |
439 | --- 2798,2804 ---- | |
440 | /* | |
441 | * Do the expansion. | |
442 | */ | |
443 | ! if (ExpandFromContext(xp, str, &xp->xp_numfiles, &xp->xp_files, | |
444 | options) == FAIL) | |
445 | { | |
446 | #ifdef FNAME_ILLEGAL | |
447 | *************** | |
448 | *** 2809,2815 **** | |
449 | EMSG2(_(e_nomatch2), str); | |
450 | #endif | |
451 | } | |
452 | ! else if (cmd_numfiles == 0) | |
453 | { | |
454 | if (!(options & WILD_SILENT)) | |
455 | EMSG2(_(e_nomatch2), str); | |
456 | --- 2810,2816 ---- | |
457 | EMSG2(_(e_nomatch2), str); | |
458 | #endif | |
459 | } | |
460 | ! else if (xp->xp_numfiles == 0) | |
461 | { | |
462 | if (!(options & WILD_SILENT)) | |
463 | EMSG2(_(e_nomatch2), str); | |
464 | *************** | |
465 | *** 2817,2836 **** | |
466 | else | |
467 | { | |
468 | /* Escape the matches for use on the command line. */ | |
469 | ! ExpandEscape(xp, str, cmd_numfiles, cmd_files, options); | |
470 | ||
471 | /* | |
472 | * Check for matching suffixes in file names. | |
473 | */ | |
474 | if (mode != WILD_ALL && mode != WILD_LONGEST) | |
475 | { | |
476 | ! if (cmd_numfiles) | |
477 | ! non_suf_match = cmd_numfiles; | |
478 | else | |
479 | non_suf_match = 1; | |
480 | if ((xp->xp_context == EXPAND_FILES | |
481 | || xp->xp_context == EXPAND_DIRECTORIES) | |
482 | ! && cmd_numfiles > 1) | |
483 | { | |
484 | /* | |
485 | * More than one match; check suffix. | |
486 | --- 2818,2837 ---- | |
487 | else | |
488 | { | |
489 | /* Escape the matches for use on the command line. */ | |
490 | ! ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options); | |
491 | ||
492 | /* | |
493 | * Check for matching suffixes in file names. | |
494 | */ | |
495 | if (mode != WILD_ALL && mode != WILD_LONGEST) | |
496 | { | |
497 | ! if (xp->xp_numfiles) | |
498 | ! non_suf_match = xp->xp_numfiles; | |
499 | else | |
500 | non_suf_match = 1; | |
501 | if ((xp->xp_context == EXPAND_FILES | |
502 | || xp->xp_context == EXPAND_DIRECTORIES) | |
503 | ! && xp->xp_numfiles > 1) | |
504 | { | |
505 | /* | |
506 | * More than one match; check suffix. | |
507 | *************** | |
508 | *** 2839,2845 **** | |
509 | */ | |
510 | non_suf_match = 0; | |
511 | for (i = 0; i < 2; ++i) | |
512 | ! if (match_suffix(cmd_files[i])) | |
513 | ++non_suf_match; | |
514 | } | |
515 | if (non_suf_match != 1) | |
516 | --- 2840,2846 ---- | |
517 | */ | |
518 | non_suf_match = 0; | |
519 | for (i = 0; i < 2; ++i) | |
520 | ! if (match_suffix(xp->xp_files[i])) | |
521 | ++non_suf_match; | |
522 | } | |
523 | if (non_suf_match != 1) | |
524 | *************** | |
525 | *** 2855,2887 **** | |
526 | beep_flush(); | |
527 | } | |
528 | if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) | |
529 | ! ss = vim_strsave(cmd_files[0]); | |
530 | } | |
531 | } | |
532 | } | |
533 | ||
534 | /* Find longest common part */ | |
535 | ! if (mode == WILD_LONGEST && cmd_numfiles > 0) | |
536 | { | |
537 | ! for (len = 0; cmd_files[0][len]; ++len) | |
538 | { | |
539 | ! for (i = 0; i < cmd_numfiles; ++i) | |
540 | { | |
541 | #ifdef CASE_INSENSITIVE_FILENAME | |
542 | if (xp->xp_context == EXPAND_DIRECTORIES | |
543 | || xp->xp_context == EXPAND_FILES | |
544 | || xp->xp_context == EXPAND_BUFFERS) | |
545 | { | |
546 | ! if (TOLOWER_LOC(cmd_files[i][len]) != | |
547 | ! TOLOWER_LOC(cmd_files[0][len])) | |
548 | break; | |
549 | } | |
550 | else | |
551 | #endif | |
552 | ! if (cmd_files[i][len] != cmd_files[0][len]) | |
553 | break; | |
554 | } | |
555 | ! if (i < cmd_numfiles) | |
556 | { | |
557 | if (!(options & WILD_NO_BEEP)) | |
558 | vim_beep(); | |
559 | --- 2856,2888 ---- | |
560 | beep_flush(); | |
561 | } | |
562 | if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE)) | |
563 | ! ss = vim_strsave(xp->xp_files[0]); | |
564 | } | |
565 | } | |
566 | } | |
567 | ||
568 | /* Find longest common part */ | |
569 | ! if (mode == WILD_LONGEST && xp->xp_numfiles > 0) | |
570 | { | |
571 | ! for (len = 0; xp->xp_files[0][len]; ++len) | |
572 | { | |
573 | ! for (i = 0; i < xp->xp_numfiles; ++i) | |
574 | { | |
575 | #ifdef CASE_INSENSITIVE_FILENAME | |
576 | if (xp->xp_context == EXPAND_DIRECTORIES | |
577 | || xp->xp_context == EXPAND_FILES | |
578 | || xp->xp_context == EXPAND_BUFFERS) | |
579 | { | |
580 | ! if (TOLOWER_LOC(xp->xp_files[i][len]) != | |
581 | ! TOLOWER_LOC(xp->xp_files[0][len])) | |
582 | break; | |
583 | } | |
584 | else | |
585 | #endif | |
586 | ! if (xp->xp_files[i][len] != xp->xp_files[0][len]) | |
587 | break; | |
588 | } | |
589 | ! if (i < xp->xp_numfiles) | |
590 | { | |
591 | if (!(options & WILD_NO_BEEP)) | |
592 | vim_beep(); | |
593 | *************** | |
594 | *** 2891,2930 **** | |
595 | ss = alloc((unsigned)len + 1); | |
596 | if (ss) | |
597 | { | |
598 | ! STRNCPY(ss, cmd_files[0], len); | |
599 | ss[len] = NUL; | |
600 | } | |
601 | findex = -1; /* next p_wc gets first one */ | |
602 | } | |
603 | ||
604 | /* Concatenate all matching names */ | |
605 | ! if (mode == WILD_ALL && cmd_numfiles > 0) | |
606 | { | |
607 | len = 0; | |
608 | ! for (i = 0; i < cmd_numfiles; ++i) | |
609 | ! len += (long_u)STRLEN(cmd_files[i]) + 1; | |
610 | ss = lalloc(len, TRUE); | |
611 | if (ss != NULL) | |
612 | { | |
613 | *ss = NUL; | |
614 | ! for (i = 0; i < cmd_numfiles; ++i) | |
615 | { | |
616 | ! STRCAT(ss, cmd_files[i]); | |
617 | ! if (i != cmd_numfiles - 1) | |
618 | STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " "); | |
619 | } | |
620 | } | |
621 | } | |
622 | ||
623 | if (mode == WILD_EXPAND_FREE || mode == WILD_ALL) | |
624 | ! { | |
625 | ! FreeWild(cmd_numfiles, cmd_files); | |
626 | ! cmd_numfiles = -1; | |
627 | ! } | |
628 | ||
629 | return ss; | |
630 | } | |
631 | ||
632 | void | |
633 | ExpandEscape(xp, str, numfiles, files, options) | |
634 | expand_T *xp; | |
635 | --- 2892,2954 ---- | |
636 | ss = alloc((unsigned)len + 1); | |
637 | if (ss) | |
638 | { | |
639 | ! STRNCPY(ss, xp->xp_files[0], len); | |
640 | ss[len] = NUL; | |
641 | } | |
642 | findex = -1; /* next p_wc gets first one */ | |
643 | } | |
644 | ||
645 | /* Concatenate all matching names */ | |
646 | ! if (mode == WILD_ALL && xp->xp_numfiles > 0) | |
647 | { | |
648 | len = 0; | |
649 | ! for (i = 0; i < xp->xp_numfiles; ++i) | |
650 | ! len += (long_u)STRLEN(xp->xp_files[i]) + 1; | |
651 | ss = lalloc(len, TRUE); | |
652 | if (ss != NULL) | |
653 | { | |
654 | *ss = NUL; | |
655 | ! for (i = 0; i < xp->xp_numfiles; ++i) | |
656 | { | |
657 | ! STRCAT(ss, xp->xp_files[i]); | |
658 | ! if (i != xp->xp_numfiles - 1) | |
659 | STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " "); | |
660 | } | |
661 | } | |
662 | } | |
663 | ||
664 | if (mode == WILD_EXPAND_FREE || mode == WILD_ALL) | |
665 | ! ExpandCleanup(xp); | |
666 | ||
667 | return ss; | |
668 | } | |
669 | ||
670 | + /* | |
671 | + * Prepare an expand structure for use. | |
672 | + */ | |
673 | + void | |
674 | + ExpandInit(xp) | |
675 | + expand_T *xp; | |
676 | + { | |
677 | + xp->xp_backslash = XP_BS_NONE; | |
678 | + xp->xp_numfiles = -1; | |
679 | + xp->xp_files = NULL; | |
680 | + } | |
681 | + | |
682 | + /* | |
683 | + * Cleanup an expand structure after use. | |
684 | + */ | |
685 | + void | |
686 | + ExpandCleanup(xp) | |
687 | + expand_T *xp; | |
688 | + { | |
689 | + if (xp->xp_numfiles >= 0) | |
690 | + { | |
691 | + FreeWild(xp->xp_numfiles, xp->xp_files); | |
692 | + xp->xp_numfiles = -1; | |
693 | + } | |
694 | + } | |
695 | + | |
696 | void | |
697 | ExpandEscape(xp, str, numfiles, files, options) | |
698 | expand_T *xp; | |
699 | *************** | |
700 | *** 3078,3084 **** | |
701 | int attr; | |
702 | int showtail; | |
703 | ||
704 | ! if (cmd_numfiles == -1) | |
705 | { | |
706 | set_expand_context(xp); | |
707 | i = expand_cmdline(xp, ccline.cmdbuff, ccline.cmdpos, | |
708 | --- 3102,3108 ---- | |
709 | int attr; | |
710 | int showtail; | |
711 | ||
712 | ! if (xp->xp_numfiles == -1) | |
713 | { | |
714 | set_expand_context(xp); | |
715 | i = expand_cmdline(xp, ccline.cmdbuff, ccline.cmdpos, | |
716 | *************** | |
717 | *** 3090,3097 **** | |
718 | } | |
719 | else | |
720 | { | |
721 | ! num_files = cmd_numfiles; | |
722 | ! files_found = cmd_files; | |
723 | showtail = cmd_showtail; | |
724 | } | |
725 | ||
726 | --- 3114,3121 ---- | |
727 | } | |
728 | else | |
729 | { | |
730 | ! num_files = xp->xp_numfiles; | |
731 | ! files_found = xp->xp_files; | |
732 | showtail = cmd_showtail; | |
733 | } | |
734 | ||
735 | *************** | |
736 | *** 3215,3221 **** | |
737 | cmdline_row = msg_row; /* will put it back later */ | |
738 | } | |
739 | ||
740 | ! if (cmd_numfiles == -1) | |
741 | FreeWild(num_files, files_found); | |
742 | ||
743 | return EXPAND_OK; | |
744 | --- 3239,3245 ---- | |
745 | cmdline_row = msg_row; /* will put it back later */ | |
746 | } | |
747 | ||
748 | ! if (xp->xp_numfiles == -1) | |
749 | FreeWild(num_files, files_found); | |
750 | ||
751 | return EXPAND_OK; | |
752 | *** ../vim-6.2.062/src/proto/ex_getln.pro Sun Jun 1 12:26:09 2003 | |
753 | --- src/proto/ex_getln.pro Sat Jul 26 18:38:51 2003 | |
754 | *************** | |
755 | *** 14,19 **** | |
756 | --- 14,21 ---- | |
757 | void compute_cmdrow __ARGS((void)); | |
758 | void gotocmdline __ARGS((int clr)); | |
759 | char_u *ExpandOne __ARGS((expand_T *xp, char_u *str, char_u *orig, int options, int mode)); | |
760 | + void ExpandInit __ARGS((expand_T *xp)); | |
761 | + void ExpandCleanup __ARGS((expand_T *xp)); | |
762 | void ExpandEscape __ARGS((expand_T *xp, char_u *str, int numfiles, char_u **files, int options)); | |
763 | void tilde_replace __ARGS((char_u *orig_pat, int num_files, char_u **files)); | |
764 | char_u *sm_gettail __ARGS((char_u *s)); | |
765 | *** ../vim-6.2.062/src/misc1.c Thu May 29 20:32:05 2003 | |
766 | --- src/misc1.c Sat Jul 26 18:37:24 2003 | |
767 | *************** | |
768 | *** 3212,3221 **** | |
769 | { | |
770 | expand_T xpc; | |
771 | ||
772 | xpc.xp_context = EXPAND_FILES; | |
773 | - xpc.xp_backslash = XP_BS_NONE; | |
774 | var = ExpandOne(&xpc, dst, NULL, | |
775 | WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); | |
776 | mustfree = TRUE; | |
777 | } | |
778 | ||
779 | --- 3212,3222 ---- | |
780 | { | |
781 | expand_T xpc; | |
782 | ||
783 | + ExpandInit(&xpc); | |
784 | xpc.xp_context = EXPAND_FILES; | |
785 | var = ExpandOne(&xpc, dst, NULL, | |
786 | WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE); | |
787 | + ExpandCleanup(&xpc); | |
788 | mustfree = TRUE; | |
789 | } | |
790 | ||
791 | *** ../vim-6.2.062/src/structs.h Mon May 26 21:08:40 2003 | |
792 | --- src/structs.h Sat Jul 26 18:30:51 2003 | |
793 | *************** | |
794 | *** 376,381 **** | |
795 | --- 376,384 ---- | |
796 | char_u *xp_pattern; /* start of item to expand */ | |
797 | char_u *xp_arg; /* generic expansion argument */ | |
798 | int xp_backslash; /* one of the XP_BS_ values */ | |
799 | + int xp_numfiles; /* number of files found by | |
800 | + file name completion */ | |
801 | + char_u **xp_files; /* list of files */ | |
802 | } expand_T; | |
803 | ||
804 | /* values for xp_backslash */ | |
805 | *** ../vim-6.2.062/src/tag.c Sun Jun 1 14:41:25 2003 | |
806 | --- src/tag.c Thu Jul 31 18:27:34 2003 | |
807 | *************** | |
808 | *** 2811,2820 **** | |
809 | */ | |
810 | if (expand && mch_has_wildcard(fname)) | |
811 | { | |
812 | xpc.xp_context = EXPAND_FILES; | |
813 | - xpc.xp_backslash = XP_BS_NONE; | |
814 | expanded_fname = ExpandOne(&xpc, (char_u *)fname, NULL, | |
815 | WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); | |
816 | if (expanded_fname != NULL) | |
817 | fname = expanded_fname; | |
818 | } | |
819 | --- 2811,2821 ---- | |
820 | */ | |
821 | if (expand && mch_has_wildcard(fname)) | |
822 | { | |
823 | + ExpandInit(&xpc); | |
824 | xpc.xp_context = EXPAND_FILES; | |
825 | expanded_fname = ExpandOne(&xpc, (char_u *)fname, NULL, | |
826 | WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE); | |
827 | + ExpandCleanup(&xpc); | |
828 | if (expanded_fname != NULL) | |
829 | fname = expanded_fname; | |
830 | } | |
831 | *** ../vim-6.2.062/src/version.c Sun Aug 10 14:52:30 2003 | |
832 | --- src/version.c Sun Aug 10 22:14:52 2003 | |
833 | *************** | |
834 | *** 632,633 **** | |
835 | --- 632,635 ---- | |
836 | { /* Add new patch number below this line */ | |
837 | + /**/ | |
838 | + 63, | |
839 | /**/ | |
840 | ||
841 | -- | |
842 | From "know your smileys": | |
843 | ...---... SOS | |
844 | ||
845 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
846 | /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ | |
847 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
848 | \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |