From 299044d4efff0f3ea0ae910977ebe77099cfebf4 Mon Sep 17 00:00:00 2001 From: Justin Gassner Date: Mon, 25 Jan 2016 19:36:57 +0100 Subject: vim-patch:7.4.656 Problem: Missing changes for glob() in one file. Solution: Add the missing changes. https://github.com/vim/vim/commit/d8b77f7dc04e5721989df9c505b8568194261a39 --- src/nvim/path.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'src/nvim/path.c') diff --git a/src/nvim/path.c b/src/nvim/path.c index 5ac3d07f67..8b9a49dfc0 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -681,11 +681,16 @@ static size_t do_path_expand(garray_T *gap, const char_u *path, /* remove backslashes for the remaining components only */ (void)do_path_expand(gap, buf, len + 1, flags, false); } else { - /* no more wildcards, check if there is a match */ - /* remove backslashes for the remaining components only */ - if (*path_end != NUL) + FileInfo file_info; + + // no more wildcards, check if there is a match + // remove backslashes for the remaining components only + if (*path_end != NUL) { backslash_halve(buf + len + 1); - if (os_file_exists(buf)) { /* add existing file */ + } + // add existing file or symbolic link + if ((flags & EW_ALLLINKS) ? os_fileinfo_link((char *)buf, &file_info) + : os_file_exists(buf)) { addfile(gap, buf, flags); } } @@ -1294,26 +1299,28 @@ expand_backtick ( return cnt; } -/* - * Add a file to a file list. Accepted flags: - * EW_DIR add directories - * EW_FILE add files - * EW_EXEC add executable files - * EW_NOTFOUND add even when it doesn't exist - * EW_ADDSLASH add slash after directory name - */ -void -addfile ( +// Add a file to a file list. Accepted flags: +// EW_DIR add directories +// EW_FILE add files +// EW_EXEC add executable files +// EW_NOTFOUND add even when it doesn't exist +// EW_ADDSLASH add slash after directory name +// EW_ALLLINKS add symlink also when the referred file does not exist +void addfile( garray_T *gap, char_u *f, /* filename */ int flags ) { bool isdir; + FileInfo file_info; - /* if the file/dir doesn't exist, may not add it */ - if (!(flags & EW_NOTFOUND) && !os_file_exists(f)) + // if the file/dir/link doesn't exist, may not add it + if (!(flags & EW_NOTFOUND) && + ((flags & EW_ALLLINKS) ? + !os_fileinfo_link((char *)f, &file_info) : !os_file_exists(f))) { return; + } #ifdef FNAME_ILLEGAL /* if the file/dir contains illegal characters, don't add it */ -- cgit