fix part of realpath for drive-qualified DOS paths:

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.
This commit is contained in:
tg 2017-10-10 21:30:43 +00:00
parent 7f38eafe26
commit 694aab50ce
1 changed files with 19 additions and 1 deletions

20
misc.c
View File

@ -32,7 +32,7 @@
#include <grp.h>
#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 */