Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2023-03-29 11:18:23 +0300
committerCorinna Vinschen <corinna@vinschen.de>2023-03-29 11:23:13 +0300
commit2bc5e1f6f35bbafd5de62d532d6a77b6292bed8a (patch)
treedfab63ac6d735e0f682806cff3a8d59106ab89db
parente9b1d1ce7f3f20af2860695ab947124219ca6531 (diff)
Cygwin: dirname: fix handling of leading slashes
Per https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/xbd_chap04.html: "A pathname that begins with two successive slashes may be interpreted in an implementation-defined manner, although more than two leading slashes shall be treated as a single slash." So more than 2 leading slashes are supposed to be folded into one, which our dirname neglected. Fix that. Fixes: 24e8fc6872a3b ("* cygwin.din (basename): Export.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r--winsup/cygwin/path.cc2
-rw-r--r--winsup/cygwin/release/3.4.73
2 files changed, 4 insertions, 1 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 97099af89..5b3df20dd 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -5219,7 +5219,7 @@ dirname (char *path)
return strcpy (buf, ".");
if (isalpha (path[0]) && path[1] == ':')
bs += 2;
- else if (strspn (path, "/\\") > 1)
+ else if (strspn (path, "/\\") == 2)
++bs;
c = strrchr (bs, '/');
if ((d = strrchr (c ?: bs, '\\')) > c)
diff --git a/winsup/cygwin/release/3.4.7 b/winsup/cygwin/release/3.4.7
index a121d81b6..2c305ec5f 100644
--- a/winsup/cygwin/release/3.4.7
+++ b/winsup/cygwin/release/3.4.7
@@ -6,3 +6,6 @@ Bug Fixes
- kill(1): don't print spurious error message.
Addresses: https://cygwin.com/pipermail/cygwin/2023-March/253291.html
+
+- Align behaviour of dirname in terms of leading slashes to POSIX:
+ https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html