34 lines
1.3 KiB
Diff
34 lines
1.3 KiB
Diff
From d549396baf93c7ffd757e631c3b5498ed1daff72 Mon Sep 17 00:00:00 2001
|
|
From: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
Date: Tue, 8 Nov 2022 16:24:20 +0100
|
|
Subject: [PATCH 35/N] When converting to a Unix path, avoid double trailing
|
|
slashes
|
|
|
|
When calling `cygpath -u C:/msys64/` in an MSYS2 setup that was
|
|
installed into `C:/msys64/`, the result should be `/`, not `//`.
|
|
|
|
Let's ensure that we do not append another trailing slash if the
|
|
converted path already ends in a slash.
|
|
|
|
This fixes https://github.com/msys2/msys2-runtime/issues/112
|
|
|
|
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
|
|
---
|
|
winsup/cygwin/mount.cc | 3 +++
|
|
1 file changed, 3 insertions(+)
|
|
|
|
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
|
|
index 939578a..37152fb 100644
|
|
--- a/winsup/cygwin/mount.cc
|
|
+++ b/winsup/cygwin/mount.cc
|
|
@@ -954,6 +954,9 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
|
|
nextchar = 1;
|
|
|
|
int addslash = nextchar > 0 ? 1 : 0;
|
|
+ /* avoid appending a slash if the result already has a trailing slash */
|
|
+ if (append_slash && mi.posix_pathlen && mi.posix_path[mi.posix_pathlen-1] == '/')
|
|
+ append_slash = addslash = 0;
|
|
if ((mi.posix_pathlen + (pathbuflen - mi.native_pathlen) + addslash) >= NT_MAX_PATH)
|
|
return ENAMETOOLONG;
|
|
strcpy (posix_path, mi.posix_path);
|