comparison src/misc1.c @ 5873:8e9db1f27a00 v7.4.279

updated for version 7.4.279 Problem: globpath() returns a string, making it difficult to get a list of matches. (Greg Novack) Solution: Add an optional argument like with glob(). (Adnan Zafar)
author Bram Moolenaar <bram@vim.org>
date Wed, 07 May 2014 18:35:30 +0200
parents a6b59ee633a3
children 5cb1828fd005
comparison
equal deleted inserted replaced
5872:8661eb2cc9a9 5873:8e9db1f27a00
10334 char_u *pattern; 10334 char_u *pattern;
10335 int flags; /* EW_* flags */ 10335 int flags; /* EW_* flags */
10336 { 10336 {
10337 char_u *curdir; 10337 char_u *curdir;
10338 garray_T path_ga; 10338 garray_T path_ga;
10339 char_u *files = NULL;
10340 char_u *s; /* start */
10341 char_u *e; /* end */
10342 char_u *paths = NULL; 10339 char_u *paths = NULL;
10343 10340
10344 if ((curdir = alloc((unsigned)MAXPATHL)) == NULL) 10341 if ((curdir = alloc((unsigned)MAXPATHL)) == NULL)
10345 return 0; 10342 return 0;
10346 mch_dirname(curdir, MAXPATHL); 10343 mch_dirname(curdir, MAXPATHL);
10349 expand_path_option(curdir, &path_ga); 10346 expand_path_option(curdir, &path_ga);
10350 vim_free(curdir); 10347 vim_free(curdir);
10351 if (path_ga.ga_len == 0) 10348 if (path_ga.ga_len == 0)
10352 return 0; 10349 return 0;
10353 10350
10354 paths = ga_concat_strings(&path_ga); 10351 paths = ga_concat_strings(&path_ga, ",");
10355 ga_clear_strings(&path_ga); 10352 ga_clear_strings(&path_ga);
10356 if (paths == NULL) 10353 if (paths == NULL)
10357 return 0; 10354 return 0;
10358 10355
10359 files = globpath(paths, pattern, (flags & EW_ICASE) ? WILD_ICASE : 0); 10356 globpath(paths, pattern, gap, (flags & EW_ICASE) ? WILD_ICASE : 0);
10360 vim_free(paths); 10357 vim_free(paths);
10361 if (files == NULL)
10362 return 0;
10363
10364 /* Copy each path in files into gap */
10365 s = e = files;
10366 while (*s != NUL)
10367 {
10368 while (*e != '\n' && *e != NUL)
10369 e++;
10370 if (*e == NUL)
10371 {
10372 addfile(gap, s, flags);
10373 break;
10374 }
10375 else
10376 {
10377 /* *e is '\n' */
10378 *e = NUL;
10379 addfile(gap, s, flags);
10380 e++;
10381 s = e;
10382 }
10383 }
10384 vim_free(files);
10385 10358
10386 return gap->ga_len; 10359 return gap->ga_len;
10387 } 10360 }
10388 #endif 10361 #endif
10389 10362