From: Eli Zaretskii Date: Mon, 10 Mar 2014 17:31:17 +0000 (+0200) Subject: src/w32.c (stat_worker): Fix commentary. X-Git-Tag: emacs-24.3.90~228 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=316d9327d7a1777b0bede48484f636c75181b921;p=emacs.git src/w32.c (stat_worker): Fix commentary. --- diff --git a/src/w32.c b/src/w32.c index e84c63d674c..8802e13e71d 100644 --- a/src/w32.c +++ b/src/w32.c @@ -4745,10 +4745,9 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks) return -1; } - /* Remove trailing directory separator, unless name is the root - directory of a drive or UNC volume in which case ensure there - is a trailing separator. */ len = strlen (name); + /* Allocate 1 extra byte so that we could append a slash to a root + directory, down below. */ name = strcpy (alloca (len + 2), name); /* Avoid a somewhat costly call to is_symlink if the filesystem @@ -4963,6 +4962,7 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks) } else if (rootdir) { + /* Make sure root directories end in a slash. */ if (!IS_DIRECTORY_SEP (name[len-1])) strcat (name, "\\"); if (GetDriveType (name) < 2) @@ -4978,6 +4978,8 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks) { int have_wfd = -1; + /* Make sure non-root directories do NOT end in a slash, + otherwise FindFirstFile might fail. */ if (IS_DIRECTORY_SEP (name[len-1])) name[len - 1] = 0;