public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_4-branch] Cygwin: dirname: fix handling of leading slashes Date: Wed, 29 Mar 2023 08:25:45 +0000 (GMT) [thread overview] Message-ID: <20230329082545.9F038385840F@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2bc5e1f6f35bbafd5de62d532d6a77b6292bed8a commit 2bc5e1f6f35bbafd5de62d532d6a77b6292bed8a 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:13 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 97099af892d5..5b3df20dd321 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 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
reply other threads:[~2023-03-29 8:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230329082545.9F038385840F@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).