0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

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)
This commit is contained in:
Bram Moolenaar
2014-05-07 18:35:30 +02:00
parent 3ec7f4e402
commit 1b1063af58
10 changed files with 100 additions and 101 deletions

View File

@@ -7985,7 +7985,7 @@ static struct fst
{"getwinposy", 0, 0, f_getwinposy},
{"getwinvar", 2, 3, f_getwinvar},
{"glob", 1, 3, f_glob},
{"globpath", 2, 3, f_globpath},
{"globpath", 2, 4, f_globpath},
{"has", 1, 1, f_has},
{"has_key", 2, 2, f_has_key},
{"haslocaldir", 0, 0, f_haslocaldir},
@@ -12151,18 +12151,37 @@ f_globpath(argvars, rettv)
char_u buf1[NUMBUFLEN];
char_u *file = get_tv_string_buf_chk(&argvars[1], buf1);
int error = FALSE;
garray_T ga;
int i;
/* When the optional second argument is non-zero, don't remove matches
* for 'wildignore' and don't put matches for 'suffixes' at the end. */
if (argvars[2].v_type != VAR_UNKNOWN
&& get_tv_number_chk(&argvars[2], &error))
flags |= WILD_KEEP_ALL;
rettv->v_type = VAR_STRING;
if (file == NULL || error)
rettv->vval.v_string = NULL;
if (argvars[2].v_type != VAR_UNKNOWN)
{
if (get_tv_number_chk(&argvars[2], &error))
flags |= WILD_KEEP_ALL;
if (argvars[3].v_type != VAR_UNKNOWN
&& get_tv_number_chk(&argvars[3], &error))
{
rettv->v_type = VAR_LIST;
rettv->vval.v_list = NULL;
}
}
if (file != NULL && !error)
{
ga_init2(&ga, (int)sizeof(char_u *), 10);
globpath(get_tv_string(&argvars[0]), file, &ga, flags);
if (rettv->v_type == VAR_STRING)
rettv->vval.v_string = ga_concat_strings(&ga, "\n");
else if (rettv_list_alloc(rettv) != FAIL)
for (i = 0; i < ga.ga_len; ++i)
list_append_string(rettv->vval.v_list,
((char_u **)(ga.ga_data))[i], -1);
ga_clear_strings(&ga);
}
else
rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file,
flags);
rettv->vval.v_string = NULL;
}
/*