From ba14e174a6afb436c0ea57faaa9cf169be764076 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 21 May 1998 02:06:21 +0000 Subject: [PATCH] (Ffile_name_directory, Ffile_name_nondirectory) [DOS_NT]: Handle the special construct "/:" when followed by d:foo. --- src/fileio.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 50abfd8988..5814e2794e 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -382,8 +382,11 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'.") && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' #endif /* VMS */ #ifdef DOS_NT - /* only recognise drive specifier at beginning */ - && !(p[-1] == ':' && p == beg + 2) + /* only recognise drive specifier at the beginning */ + && !(p[-1] == ':' + /* handle the "/:d:foo" and "/:foo" cases correctly */ + && ((p == beg + 2 && !IS_DIRECTORY_SEP (*beg)) + || (p == beg + 4 && IS_DIRECTORY_SEP (*beg)))) #endif ) p--; @@ -391,11 +394,20 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'.") return Qnil; #ifdef DOS_NT /* Expansion of "c:" to drive and default directory. */ - if (p == beg + 2 && beg[1] == ':') + if (p[-1] == ':') { /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir. */ unsigned char *res = alloca (MAXPATHLEN + 1); - if (getdefdir (toupper (*beg) - 'A' + 1, res)) + unsigned char *r = res; + + if (p == beg + 4 && IS_DIRECTORY_SEP (*beg) && beg[1] == ':') + { + strncpy (res, beg, 2); + beg += 2; + r += 2; + } + + if (getdefdir (toupper (*beg) - 'A' + 1, r)) { if (!IS_DIRECTORY_SEP (res[strlen (res) - 1])) strcat (res, "/"); @@ -440,7 +452,9 @@ or the entire name if it contains no slash.") #endif /* VMS */ #ifdef DOS_NT /* only recognise drive specifier at beginning */ - && !(p[-1] == ':' && p == beg + 2) + && !(p[-1] == ':' + /* handle the "/:d:foo" case correctly */ + && (p == beg + 2 || (p == beg + 4 && IS_DIRECTORY_SEP (*beg)))) #endif ) p--; -- 2.20.1