MSYS2-packages/msys2-runtime-3.5/0034-When-converting-to-a-Unix-path-avoid-double-trailing.patch
Johannes Schindelin 5ad10f7c3c msys2-runtime-3.5: update the patches to v3.5.1
After adjusting the `PKGBUILD` to reflect that this package is supposed
to track Cygwin v3.5.x, this commit adjusts the patches accordingly (the
trick was performed by `./update-patches.sh`, of course).

This corresponds to https://github.com/msys2/msys2-runtime/pull/204.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2024-03-10 00:06:13 +01:00

34 lines
1.3 KiB
Diff

From c7908f7f0603b3c80c349bcf2e7dfdf339f311ba 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 34/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 eff9803..bd6ec2a 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -1018,6 +1018,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);