MSYS2-packages/msys2-runtime-3.3/0010-Special-case-for-converting-root-directory-to-have-t.patch
Christoph Reiter 743bae3086 Add msys2-runtime-3.3
Provides and conflicts with msys2-runtime, so can be used to replace it if wanted.

Keep this as a separate package to test for regressions in cygwin
and to have (in theory) a runtime that supports 32bit in the repo.

There is no guarantee for how long we are going to keep this.
2022-12-09 17:58:25 +01:00

56 lines
1.8 KiB
Diff

From 4676ec44f24a0bfa208e6f0c79b0b059c88f6b1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B8=CC=86=20=D0=9F?=
=?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=BE=D0=B2?= <alexey.pawlow@gmail.com>
Date: Sun, 14 Apr 2019 22:13:51 +0300
Subject: [PATCH 10/N] Special case for converting root directory to have
training slash
---
winsup/cygwin/path.cc | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 17646a8..77480aa 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -709,6 +709,12 @@ path_conv::check (const char *src, unsigned opt,
need_directory = 1;
*--tail = '\0';
}
+ /* Special case for "/" must set need_directory, without removing
+ trailing slash */
+ else if (tail == path_copy + 1 && isslash (tail[-1]))
+ {
+ need_directory = 1;
+ }
path_end = tail;
/* Scan path_copy from right to left looking either for a symlink
@@ -1248,16 +1254,17 @@ path_conv::check (const char *src, unsigned opt,
cfree (wide_path);
wide_path = NULL;
}
- if (need_directory)
+ }
+
+ if (need_directory)
+ {
+ size_t n = strlen (this->path);
+ /* Do not add trailing \ to UNC device names like \\.\a: */
+ if (this->path[n - 1] != '\\' &&
+ (strncmp (this->path, "\\\\.\\", 4) != 0))
{
- size_t n = strlen (this->path);
- /* Do not add trailing \ to UNC device names like \\.\a: */
- if (this->path[n - 1] != '\\' &&
- (strncmp (this->path, "\\\\.\\", 4) != 0))
- {
- this->modifiable_path ()[n] = '\\';
- this->modifiable_path ()[n + 1] = '\0';
- }
+ this->modifiable_path ()[n] = '\\';
+ this->modifiable_path ()[n + 1] = '\0';
}
}