diff src/misc1.c @ 6663:056809de0b29 v7.4.656

updated for version 7.4.656 Problem: Missing changes for glob() in one file. Solution: Add the missing changes.
author Bram Moolenaar <bram@vim.org>
date Thu, 05 Mar 2015 21:21:19 +0100
parents f8f2a61e538d
children 9fda0c52db0b
line wrap: on
line diff
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -10168,11 +10168,15 @@ unix_expandpath(gap, path, wildoff, flag
 		}
 		else
 		{
+		    struct stat sb;
+
 		    /* 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 (mch_getperm(buf) >= 0)	/* add existing file */
+		    /* add existing file or symbolic link */
+		    if ((flags & EW_ALLLINKS) ? mch_lstat(buf, &sb) >= 0
+						      : mch_getperm(buf) >= 0)
 		    {
 #ifdef MACOS_CONVERT
 			size_t precomp_len = STRLEN(buf)+1;
@@ -10919,6 +10923,7 @@ expand_backtick(gap, pat, flags)
  * 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(gap, f, flags)
@@ -10928,9 +10933,11 @@ addfile(gap, f, flags)
 {
     char_u	*p;
     int		isdir;
-
-    /* if the file/dir doesn't exist, may not add it */
-    if (!(flags & EW_NOTFOUND) && mch_getperm(f) < 0)
+    struct stat sb;
+
+    /* if the file/dir/link doesn't exist, may not add it */
+    if (!(flags & EW_NOTFOUND) && ((flags & EW_ALLLINKS)
+				? mch_lstat(f, &sb) < 0 : mch_getperm(f) < 0))
 	return;
 
 #ifdef FNAME_ILLEGAL