diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index eaf695b81..582238d15 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 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