From 316d9327d7a1777b0bede48484f636c75181b921 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 10 Mar 2014 19:31:17 +0200 Subject: [PATCH] src/w32.c (stat_worker): Fix commentary. --- src/w32.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; -- 2.39.2