comparison src/ex_cmds2.c @ 11935:976b480ced9a v8.0.0847

patch 8.0.0847: :argadd without argument can't handle space in file name commit https://github.com/vim/vim/commit/398ee7326b78b892a5c8380dfe3f2521a64b4fa7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 3 14:29:14 2017 +0200 patch 8.0.0847: :argadd without argument can't handle space in file name Problem: :argadd without argument can't handle space in file name. (Harm te Hennepe) Solution: Escape the space. (Yasuhiro Matsumoto, closes #1917)
author Christian Brabandt <cb@256bit.org>
date Thu, 03 Aug 2017 14:30:04 +0200
parents f87c43fca41d
children bc0fee081e1e
comparison
equal deleted inserted replaced
11934:695ef5fe791b 11935:976b480ced9a
2318 2318
2319 /* 2319 /*
2320 * Separate the arguments in "str" and return a list of pointers in the 2320 * Separate the arguments in "str" and return a list of pointers in the
2321 * growarray "gap". 2321 * growarray "gap".
2322 */ 2322 */
2323 int 2323 static int
2324 get_arglist(garray_T *gap, char_u *str) 2324 get_arglist(garray_T *gap, char_u *str, int escaped)
2325 { 2325 {
2326 ga_init2(gap, (int)sizeof(char_u *), 20); 2326 ga_init2(gap, (int)sizeof(char_u *), 20);
2327 while (*str != NUL) 2327 while (*str != NUL)
2328 { 2328 {
2329 if (ga_grow(gap, 1) == FAIL) 2329 if (ga_grow(gap, 1) == FAIL)
2330 { 2330 {
2331 ga_clear(gap); 2331 ga_clear(gap);
2332 return FAIL; 2332 return FAIL;
2333 } 2333 }
2334 ((char_u **)gap->ga_data)[gap->ga_len++] = str; 2334 ((char_u **)gap->ga_data)[gap->ga_len++] = str;
2335
2336 /* If str is escaped, don't handle backslashes or spaces */
2337 if (!escaped)
2338 return OK;
2335 2339
2336 /* Isolate one argument, change it in-place, put a NUL after it. */ 2340 /* Isolate one argument, change it in-place, put a NUL after it. */
2337 str = do_one_arg(str); 2341 str = do_one_arg(str);
2338 } 2342 }
2339 return OK; 2343 return OK;
2353 int wig) 2357 int wig)
2354 { 2358 {
2355 garray_T ga; 2359 garray_T ga;
2356 int i; 2360 int i;
2357 2361
2358 if (get_arglist(&ga, str) == FAIL) 2362 if (get_arglist(&ga, str, TRUE) == FAIL)
2359 return FAIL; 2363 return FAIL;
2360 if (wig == TRUE) 2364 if (wig == TRUE)
2361 i = expand_wildcards(ga.ga_len, (char_u **)ga.ga_data, 2365 i = expand_wildcards(ga.ga_len, (char_u **)ga.ga_data,
2362 fcountp, fnamesp, EW_FILE|EW_NOTFOUND); 2366 fcountp, fnamesp, EW_FILE|EW_NOTFOUND);
2363 else 2367 else
2399 int i; 2403 int i;
2400 #ifdef FEAT_LISTCMDS 2404 #ifdef FEAT_LISTCMDS
2401 char_u *p; 2405 char_u *p;
2402 int match; 2406 int match;
2403 #endif 2407 #endif
2408 int arg_escaped = TRUE;
2404 2409
2405 /* 2410 /*
2406 * Set default argument for ":argadd" command. 2411 * Set default argument for ":argadd" command.
2407 */ 2412 */
2408 if (what == AL_ADD && *str == NUL) 2413 if (what == AL_ADD && *str == NUL)
2409 { 2414 {
2410 if (curbuf->b_ffname == NULL) 2415 if (curbuf->b_ffname == NULL)
2411 return FAIL; 2416 return FAIL;
2412 str = curbuf->b_fname; 2417 str = curbuf->b_fname;
2418 arg_escaped = FALSE;
2413 } 2419 }
2414 2420
2415 /* 2421 /*
2416 * Collect all file name arguments in "new_ga". 2422 * Collect all file name arguments in "new_ga".
2417 */ 2423 */
2418 if (get_arglist(&new_ga, str) == FAIL) 2424 if (get_arglist(&new_ga, str, arg_escaped) == FAIL)
2419 return FAIL; 2425 return FAIL;
2420 2426
2421 #ifdef FEAT_LISTCMDS 2427 #ifdef FEAT_LISTCMDS
2422 if (what == AL_DEL) 2428 if (what == AL_DEL)
2423 { 2429 {