// the fix part (no wildcards) and the part containing the wildcards
// of the search path
char_u *ffs_fix_path;
-#ifdef FEAT_PATH_EXTRA
char_u *ffs_wc_path;
-#endif
// files/dirs found in the above directory, matched by the first wildcard
// of wc_part
{
struct ff_visited *ffv_next;
-#ifdef FEAT_PATH_EXTRA
// Visited directories are different if the wildcard string are
// different. So we have to save it.
char_u *ffv_wc_path;
-#endif
+
// for unix use inode etc for comparison (needed because of links), else
// use filename.
#ifdef UNIX
char_u *ffsc_file_to_search;
char_u *ffsc_start_dir;
char_u *ffsc_fix_path;
-#ifdef FEAT_PATH_EXTRA
char_u *ffsc_wc_path;
int ffsc_level;
char_u **ffsc_stopdirs_v;
-#endif
int ffsc_find_what;
int ffsc_tagfile;
} ff_search_ctx_T;
// locally needed functions
-#ifdef FEAT_PATH_EXTRA
static int ff_check_visited(ff_visited_T **, char_u *, char_u *);
-#else
-static int ff_check_visited(ff_visited_T **, char_u *);
-#endif
static void vim_findfile_free_visited(void *search_ctx_arg);
static void vim_findfile_free_visited_list(ff_visited_list_hdr_T **list_headp);
static void ff_free_visited_list(ff_visited_T *vl);
static ff_stack_T *ff_pop(ff_search_ctx_T *search_ctx);
static void ff_clear(ff_search_ctx_T *search_ctx);
static void ff_free_stack_element(ff_stack_T *stack_ptr);
-#ifdef FEAT_PATH_EXTRA
static ff_stack_T *ff_create_stack_element(char_u *, char_u *, int, int);
-#else
-static ff_stack_T *ff_create_stack_element(char_u *, int, int);
-#endif
-#ifdef FEAT_PATH_EXTRA
static int ff_path_in_stoplist(char_u *, int, char_u **);
-#endif
static char_u *ff_expand_buffer = NULL; // used for expanding filenames
int tagfile, // expanding names of tags files
char_u *rel_fname) // file name to use for "."
{
-#ifdef FEAT_PATH_EXTRA
char_u *wc_part;
-#endif
ff_stack_T *sptr;
ff_search_ctx_T *search_ctx;
#endif
}
-#ifdef FEAT_PATH_EXTRA
/*
* If stopdirs are given, split them into an array of pointers.
* If this fails (mem allocation), there is no upward search at all or a
search_ctx->ffsc_stopdirs_v[dircount-1] = NULL;
}
}
-#endif
-#ifdef FEAT_PATH_EXTRA
search_ctx->ffsc_level = level;
/*
goto error_return;
}
else
-#endif
search_ctx->ffsc_fix_path = vim_strsave(path);
if (search_ctx->ffsc_start_dir == NULL)
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
add_pathsep(ff_expand_buffer);
}
-#ifdef FEAT_PATH_EXTRA
else
{
char_u *p = gettail(search_ctx->ffsc_fix_path);
search_ctx->ffsc_wc_path = temp;
}
}
-#endif
vim_free(buf);
}
sptr = ff_create_stack_element(ff_expand_buffer,
-#ifdef FEAT_PATH_EXTRA
- search_ctx->ffsc_wc_path,
-#endif
- level, 0);
+ search_ctx->ffsc_wc_path, level, 0);
if (sptr == NULL)
goto error_return;
return NULL;
}
-#if defined(FEAT_PATH_EXTRA) || defined(PROTO)
/*
* Get the stopdir string. Check that ';' is not escaped.
*/
r_ptr = NULL;
return r_ptr;
}
-#endif
/*
* Clean up the given search context. Can handle a NULL pointer.
vim_findfile(void *search_ctx_arg)
{
char_u *file_path;
-#ifdef FEAT_PATH_EXTRA
char_u *rest_of_wildcards;
char_u *path_end = NULL;
-#endif
ff_stack_T *stackp;
int len;
int i;
if ((file_path = alloc(MAXPATHL)) == NULL)
return NULL;
-#ifdef FEAT_PATH_EXTRA
// store the end of the start dir -- needed for upward search
if (search_ctx->ffsc_start_dir != NULL)
path_end = &search_ctx->ffsc_start_dir[
STRLEN(search_ctx->ffsc_start_dir)];
-#endif
-#ifdef FEAT_PATH_EXTRA
// upward search loop
for (;;)
{
-#endif
// downward search loop
for (;;)
{
if (stackp->ffs_filearray == NULL
&& ff_check_visited(&search_ctx->ffsc_dir_visited_list
->ffvl_visited_list,
- stackp->ffs_fix_path
-#ifdef FEAT_PATH_EXTRA
- , stackp->ffs_wc_path
-#endif
- ) == FAIL)
+ stackp->ffs_fix_path, stackp->ffs_wc_path) == FAIL)
{
#ifdef FF_VERBOSE
if (p_verbose >= 5)
goto fail;
}
-#ifdef FEAT_PATH_EXTRA
rest_of_wildcards = stackp->ffs_wc_path;
if (*rest_of_wildcards != NUL)
{
if (vim_ispathsep(*rest_of_wildcards))
rest_of_wildcards++;
}
-#endif
/*
* Expand wildcards like "*" and "$VAR".
stackp->ffs_filearray_cur = 0;
stackp->ffs_stage = 0;
}
-#ifdef FEAT_PATH_EXTRA
else
rest_of_wildcards = &stackp->ffs_wc_path[
STRLEN(stackp->ffs_wc_path)];
-#endif
if (stackp->ffs_stage == 0)
{
// this is the first time we work on this directory
-#ifdef FEAT_PATH_EXTRA
if (*rest_of_wildcards == NUL)
-#endif
{
/*
* We don't have further wildcards to expand, so we have to
== mch_isdir(file_path)))))
#ifndef FF_VERBOSE
&& (ff_check_visited(
- &search_ctx->ffsc_visited_list->ffvl_visited_list,
- file_path
-#ifdef FEAT_PATH_EXTRA
- , (char_u *)""
-#endif
- ) == OK)
+ &search_ctx->ffsc_visited_list
+ ->ffvl_visited_list,
+ file_path, (char_u *)"") == OK)
#endif
)
{
#ifdef FF_VERBOSE
if (ff_check_visited(
- &search_ctx->ffsc_visited_list->ffvl_visited_list,
- file_path
-#ifdef FEAT_PATH_EXTRA
- , (char_u *)""
-#endif
- ) == FAIL)
+ &search_ctx->ffsc_visited_list
+ ->ffvl_visited_list,
+ file_path, (char_u *)"") == FAIL)
{
if (p_verbose >= 5)
{
}
}
}
-#ifdef FEAT_PATH_EXTRA
else
{
/*
stackp->ffs_level - 1, 0));
}
}
-#endif
stackp->ffs_filearray_cur = 0;
stackp->ffs_stage = 1;
}
-#ifdef FEAT_PATH_EXTRA
/*
* if wildcards contains '**' we have to descent till we reach the
* leaves of the directory tree.
stackp->ffs_wc_path, stackp->ffs_level - 1, 1));
}
}
-#endif
// we are done with the current directory
ff_free_stack_element(stackp);
}
-#ifdef FEAT_PATH_EXTRA
// If we reached this, we didn't find anything downwards.
// Let's check if we should do an upward search.
if (search_ctx->ffsc_start_dir
else
break;
}
-#endif
fail:
vim_free(file_path);
while (vl != NULL)
{
vp = vl->ffv_next;
-#ifdef FEAT_PATH_EXTRA
vim_free(vl->ffv_wc_path);
-#endif
vim_free(vl);
vl = vp;
}
return retptr;
}
-#ifdef FEAT_PATH_EXTRA
/*
* check if two wildcard paths are equal. Returns TRUE or FALSE.
* They are equal if:
}
return s1[i] == s2[j];
}
-#endif
/*
* maintains the list of already visited files and dirs
static int
ff_check_visited(
ff_visited_T **visited_list,
- char_u *fname
-#ifdef FEAT_PATH_EXTRA
- , char_u *wc_path
-#endif
- )
+ char_u *fname,
+ char_u *wc_path)
{
ff_visited_T *vp;
#ifdef UNIX
fnamecmp(vp->ffv_fname, ff_expand_buffer) == 0
)
{
-#ifdef FEAT_PATH_EXTRA
// are the wildcard parts equal
if (ff_wc_equal(vp->ffv_wc_path, wc_path) == TRUE)
-#endif
// already visited
return FAIL;
}
#ifdef UNIX
}
#endif
-#ifdef FEAT_PATH_EXTRA
if (wc_path != NULL)
vp->ffv_wc_path = vim_strsave(wc_path);
else
vp->ffv_wc_path = NULL;
-#endif
vp->ffv_next = *visited_list;
*visited_list = vp;
static ff_stack_T *
ff_create_stack_element(
char_u *fix_part,
-#ifdef FEAT_PATH_EXTRA
char_u *wc_part,
-#endif
int level,
int star_star_empty)
{
fix_part = (char_u *)"";
new->ffs_fix_path = vim_strsave(fix_part);
-#ifdef FEAT_PATH_EXTRA
if (wc_part == NULL)
wc_part = (char_u *)"";
new->ffs_wc_path = vim_strsave(wc_part);
-#endif
- if (new->ffs_fix_path == NULL
-#ifdef FEAT_PATH_EXTRA
- || new->ffs_wc_path == NULL
-#endif
- )
+ if (new->ffs_fix_path == NULL || new->ffs_wc_path == NULL)
{
ff_free_stack_element(new);
new = NULL;
{
// vim_free handles possible NULL pointers
vim_free(stack_ptr->ffs_fix_path);
-#ifdef FEAT_PATH_EXTRA
vim_free(stack_ptr->ffs_wc_path);
-#endif
if (stack_ptr->ffs_filearray != NULL)
FreeWild(stack_ptr->ffs_filearray_size, stack_ptr->ffs_filearray);
vim_free(search_ctx->ffsc_file_to_search);
vim_free(search_ctx->ffsc_start_dir);
vim_free(search_ctx->ffsc_fix_path);
-#ifdef FEAT_PATH_EXTRA
vim_free(search_ctx->ffsc_wc_path);
-#endif
-#ifdef FEAT_PATH_EXTRA
if (search_ctx->ffsc_stopdirs_v != NULL)
{
int i = 0;
vim_free(search_ctx->ffsc_stopdirs_v);
}
search_ctx->ffsc_stopdirs_v = NULL;
-#endif
// reset everything
search_ctx->ffsc_file_to_search = NULL;
search_ctx->ffsc_start_dir = NULL;
search_ctx->ffsc_fix_path = NULL;
-#ifdef FEAT_PATH_EXTRA
search_ctx->ffsc_wc_path = NULL;
search_ctx->ffsc_level = 0;
-#endif
}
-#ifdef FEAT_PATH_EXTRA
/*
* check if the given path is in the stopdirs
* returns TRUE if yes else FALSE
}
return FALSE;
}
-#endif
/*
* Find the file name "ptr[len]" in the path. Also finds directory names.
buf[0] = 0;
copy_option_part(&dir, buf, MAXPATHL, " ,");
-# ifdef FEAT_PATH_EXTRA
// get the stopdir string
r_ptr = vim_findfile_stopdir(buf);
-# else
- r_ptr = NULL;
-# endif
fdip_search_ctx = vim_findfile_init(buf, ff_file_to_find,
r_ptr, 100, FALSE, find_what,
fdip_search_ctx, FALSE, rel_fname);