further OS/2 fixes for simplify_path()
This commit is contained in:
parent
af61fd186a
commit
2cdd9d77de
28
misc.c
28
misc.c
@ -32,7 +32,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.282 2017/10/11 20:46:14 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.283 2017/10/11 21:49:06 tg Exp $");
|
||||||
|
|
||||||
#define KSH_CHVT_FLAG
|
#define KSH_CHVT_FLAG
|
||||||
#ifdef MKSH_SMALL
|
#ifdef MKSH_SMALL
|
||||||
@ -1948,8 +1948,10 @@ make_path(const char *cwd, const char *file,
|
|||||||
* .. ..
|
* .. ..
|
||||||
* ./foo foo
|
* ./foo foo
|
||||||
* foo/../../../bar ../../bar
|
* foo/../../../bar ../../bar
|
||||||
* C:/../foo C:/foo
|
* C:/foo/../.. C:/
|
||||||
* C:../foo C:../foo
|
* C:. C:
|
||||||
|
* C:.. C:..
|
||||||
|
* C:foo/../../blah C:../blah
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
simplify_path(char *p)
|
simplify_path(char *p)
|
||||||
@ -1957,11 +1959,16 @@ simplify_path(char *p)
|
|||||||
char *dp, *ip, *sp, *tp;
|
char *dp, *ip, *sp, *tp;
|
||||||
size_t len;
|
size_t len;
|
||||||
bool needslash;
|
bool needslash;
|
||||||
|
|
||||||
#ifdef MKSH_DOSPATH
|
#ifdef MKSH_DOSPATH
|
||||||
|
bool needdot = true;
|
||||||
|
|
||||||
/* keep drive letter */
|
/* keep drive letter */
|
||||||
if (mksh_drvltr(p))
|
if (mksh_drvltr(p)) {
|
||||||
p += 2;
|
p += 2;
|
||||||
|
needdot = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define needdot true
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
@ -2040,10 +2047,15 @@ simplify_path(char *p)
|
|||||||
needslash = true;
|
needslash = true;
|
||||||
/* try next component */
|
/* try next component */
|
||||||
}
|
}
|
||||||
if (dp == p)
|
if (dp == p) {
|
||||||
/* empty path -> dot */
|
/* empty path -> dot (or slash, when absolute) */
|
||||||
*dp++ = needslash ? '/' : '.';
|
if (needslash)
|
||||||
|
*dp++ = '/';
|
||||||
|
else if (needdot)
|
||||||
|
*dp++ = '.';
|
||||||
|
}
|
||||||
*dp = '\0';
|
*dp = '\0';
|
||||||
|
#undef needdot
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user