keep drive letter when simplifying path (untested)

This commit is contained in:
tg 2017-10-11 20:46:14 +00:00
parent 2b329c9343
commit 9dc689dd17
1 changed files with 10 additions and 2 deletions

12
misc.c
View File

@ -32,7 +32,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.281 2017/10/11 19:06:44 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.282 2017/10/11 20:46:14 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@ -1785,7 +1785,7 @@ do_realpath(const char *upath)
}
#ifdef MKSH_DOSPATH
/* drive letter? */
if (ctype(ip[0], C_ALPHA) && ip[1] == ':') {
if (mksh_drvltr(ip)) {
/* keep it */
Xput(xs, xp, *ip++);
Xput(xs, xp, *ip++);
@ -1948,6 +1948,8 @@ make_path(const char *cwd, const char *file,
* .. ..
* ./foo foo
* foo/../../../bar ../../bar
* C:/../foo C:/foo
* C:../foo C:../foo
*/
void
simplify_path(char *p)
@ -1956,6 +1958,12 @@ simplify_path(char *p)
size_t len;
bool needslash;
#ifdef MKSH_DOSPATH
/* keep drive letter */
if (mksh_drvltr(p))
p += 2;
#endif
switch (*p) {
case 0:
return;