Skip to content

Commit 5562607

Browse files
dscholazka
authored andcommitted
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 #112 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent bce9e93 commit 5562607

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

winsup/cygwin/mount.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,9 @@ mount_info::conv_to_posix_path (const char *src_path, char *posix_path,
954954
nextchar = 1;
955955

956956
int addslash = nextchar > 0 ? 1 : 0;
957+
/* avoid appending a slash if the result already has a trailing slash */
958+
if (append_slash && mi.posix_pathlen && mi.posix_path[mi.posix_pathlen-1] == '/')
959+
append_slash = addslash = 0;
957960
if ((mi.posix_pathlen + (pathbuflen - mi.native_pathlen) + addslash) >= NT_MAX_PATH)
958961
return ENAMETOOLONG;
959962
strcpy (posix_path, mi.posix_path);

0 commit comments

Comments
 (0)