public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/main] Cygwin: dirname: fix handling of leading slashes
@ 2023-03-29 8:25 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2023-03-29 8:25 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2898a359b80c18fb0c3d4122b8f40daed49ba11e
commit 2898a359b80c18fb0c3d4122b8f40daed49ba11e
Author: Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Wed Mar 29 10:18:23 2023 +0200
Commit: Corinna Vinschen <corinna@vinschen.de>
CommitDate: Wed Mar 29 10:23:05 2023 +0200
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>
Diff:
---
winsup/cygwin/path.cc | 2 +-
winsup/cygwin/release/3.4.7 | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index eaf695b8182a..582238d1503f 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -5120,7 +5120,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 a121d81b62fa..2c305ec5f320 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-29 8:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 8:25 [newlib-cygwin/main] Cygwin: dirname: fix handling of leading slashes Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).