From 694aab50ce7232255716be6778927b898f58282a Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 10 Oct 2017 21:30:43 +0000 Subject: [PATCH] fix part of realpath for drive-qualified DOS paths: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if a path or symlink target is drive-qualified, keep the drive letter (this part from komh) and, if present, a leading (back)slash (from me) missing: if a drive qualification is *not* followed by a (back)slash, we must retrieve the per-drive cwd for the target drive and insert it just like we insert the cwd for (normal/Unix) relative paths; maybe consider redoing absolute/relative path logic, DOS paths are tristate komh’s commit: fix realpath failure on OS/2 On OS/2, an absolute path is 'x:/path/to/file'. Because it has not a leading slash, '/' is prepended, that is, '/x:/path/to/file'. As a result, it fails to find a requested file. --- misc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/misc.c b/misc.c index 1205072..88eaeba 100644 --- a/misc.c +++ b/misc.c @@ -32,7 +32,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.279 2017/08/07 21:39:25 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.280 2017/10/10 21:30:43 tg Exp $"); #define KSH_CHVT_FLAG #ifdef MKSH_SMALL @@ -1783,6 +1783,24 @@ do_realpath(const char *upath) /* keep them, e.g. for UNC pathnames */ Xput(xs, xp, '/'); } +#ifdef MKSH_DOSPATH + /* drive letter? */ + if (ctype(ip[0], C_ALPHA) && ip[1] == ':') { + /* keep it */ + Xput(xs, xp, *ip++); + Xput(xs, xp, *ip++); + /* as well as a leading (back)slash */ + if (mksh_cdirsep(*ip)) + Xput(xs, xp, *ip++); + /* + * XXX else: get the cwd on that drive + * XXX and prepend it here as this is + * XXX a drive-qualified relative path + * XXX which we are supposed to convert + * XXX to an absolute (with drive) one + */ + } +#endif } } /* otherwise (no symlink) merely go on */