summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-01-22 21:29:02 +0000
committerJim Meyering <jim@meyering.net>2000-01-22 21:29:02 +0000
commit09f1b5f9407c5c812dd8477ff6ac6ce01681be11 (patch)
tree0ed6beafab0448b05aa2e8017879ac4427de4136 /lib
parenta2e435c395a5bd9ce6cd6b33075acc35b42f545e (diff)
downloadcoreutils-09f1b5f9407c5c812dd8477ff6ac6ce01681be11.tar.xz
(dir_name): Support for DOS-style file names with drive letters.
Diffstat (limited to 'lib')
-rw-r--r--lib/dirname.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/dirname.c b/lib/dirname.c
index 483c33867..cf62de7a0 100644
--- a/lib/dirname.c
+++ b/lib/dirname.c
@@ -57,8 +57,17 @@ dir_name (const char *path)
else
{
/* Remove any trailing slashes from the result. */
+#ifdef MSDOS
+ char *lim = (path[0] >= 'A' && path[0] <= 'z' && path[1] == ':')
+ ? path + 2 : path;
+
+ /* If canonicalized "d:/path", leave alone the root case "d:/". */
+ while (slash > lim && *slash == '/')
+ --slash;
+#else
while (slash > path && *slash == '/')
--slash;
+#endif
length = slash - path + 1;
}