On Wed, Aug 4, 2010 at 4:39 AM, Bram Moolenaar <[email protected]> wrote:
>> Attached is the fix on top of Revision: 7d1044b27e.
>
> Thanks and sorry, I suppose I caused this problem.
That is minuscule compared to all the problems that I have caused with
all this find-completion stuff :)
Prove (this will show that I'm still naive at grokking vim source code):
We shouldn't have to write window-specific code for the find completion
because apparently f_globpath() works fine on both unix and windows and
it happily uses globpath() to do its job.
To cut a long story short, I found this out while writing a test script
for testing the find completion stuff.
With that realization I'm going to investigate why is it that on
windows, globpath() as used in the expand_in_path() function fails to do
its jobs when it works just fine when used in f_globpath(), with the
exact same set of arguments.
I'm attaching a patch to produce my "debug" version of eval.c and
misc1.c which will show this problem for those who would like to help in
investigating this.
On windows, doing
:echo globpath("c:/src/vim/**", "misc*")
calls f_globpath(), which in turn calls globpath() with the arguments
"c:/src/vim/**", "misc*" and 0 for path, file and expand_options,
respectively and it successfully gives
c:\src\vim\src\misc1.c
c:\src\vim\src\misc2.c
c:\src\vim\src\proto\misc1.c
c:\src\vim\src\proto\misc2.c
c:\src\vim\src\ObjC\misc1.obj
c:\src\vim\src\ObjC\misc2.obj
c:\src\vim\src\ObjG\misc1.obj
c:\src\vim\src\ObjG\misc2.obj
while doing
:set path=c:/src/vim/**
:find misc<tab>
which call expand_in_path(), which in turns call globpath(), fails with
the exact same argument "c:/src/vim/**", "misc*" and 0 for path, file and
expand_options, respectively.
Help!
nazri.
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/eval.c b/src/eval.c
index 8a26b66..db6fdb5 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -11692,8 +11692,15 @@ f_globpath(argvars, rettv)
if (file == NULL || error)
rettv->vval.v_string = NULL;
else
- rettv->vval.v_string = globpath(get_tv_string(&argvars[0]), file,
- flags);
+ {
+ char_u *p = get_tv_string(&argvars[0]);
+ smsg("X calling globpath:");
+ smsg("X path: '%s'", p);
+ smsg("X file: '%s'", file);
+ smsg("X flags: '%d'", flags);
+ rettv->vval.v_string = globpath(p, file, flags);
+ smsg("X result: '%s'", rettv->vval.v_string);
+ }
}
/*
diff --git a/src/misc1.c b/src/misc1.c
index b0f7e91..eeed9f8 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -9578,14 +9578,10 @@ expand_in_path(gap, pattern, flags)
char_u *curdir;
garray_T path_ga;
int i;
-# ifdef WIN3264
- char_u *file_pattern;
-# else
char_u *files = NULL;
char_u *s; /* start */
char_u *e; /* end */
char_u *paths = NULL;
-# endif
if ((curdir = alloc((unsigned)MAXPATHL)) == NULL)
return 0;
@@ -9594,20 +9590,6 @@ expand_in_path(gap, pattern, flags)
expand_path_option(curdir, &path_ga);
vim_free(curdir);
path_list = (char_u **)(path_ga.ga_data);
-# ifdef WIN3264
- if ((file_pattern = alloc((unsigned)MAXPATHL)) == NULL)
- return 0;
- for (i = 0; i < path_ga.ga_len; i++)
- {
- if (STRLEN(path_list[i]) + STRLEN(pattern) + 2 > MAXPATHL)
- continue;
- STRCPY(file_pattern, path_list[i]);
- STRCAT(file_pattern, "/");
- STRCAT(file_pattern, pattern);
- mch_expandpath(gap, file_pattern, EW_DIR|EW_ADDSLASH|EW_FILE);
- }
- vim_free(file_pattern);
-# else
for (i = 0; i < path_ga.ga_len; i++)
{
if (paths == NULL)
@@ -9626,12 +9608,22 @@ expand_in_path(gap, pattern, flags)
}
}
+ verbose_enter_scroll();
+ smsg("Y calling globpath:");
+ smsg("Y path: '%s'", paths);
+ smsg("Y file: '%s'", pattern);
+ smsg("Y flags: '%d'", 0);
files = globpath(paths, pattern, 0);
vim_free(paths);
if (files == NULL)
+ {
+ msg("Y files is NULL");
return 0;
+ }
+ smsg("Y result: '%s'", files);
+ verbose_leave();
/* Copy each path in files into gap */
s = e = files;
while (*s != NUL)
@@ -9654,7 +9646,6 @@ expand_in_path(gap, pattern, flags)
}
vim_free(files);
-# endif
return gap->ga_len;
}