From: Jim Meyering Date: Sat, 22 Jan 2000 21:29:02 +0000 (+0000) Subject: (dir_name): Support for DOS-style file names with drive letters. X-Git-Tag: FILEUTILS-4_0p~112 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=09f1b5f9407c5c812dd8477ff6ac6ce01681be11;p=thirdparty%2Fcoreutils.git (dir_name): Support for DOS-style file names with drive letters. --- diff --git a/lib/dirname.c b/lib/dirname.c index 483c338672..cf62de7a04 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; }