Merge remote-tracking branch 'mksh/master'

Conflicts:
	Build.sh
	check.pl
	check.t
	edit.c
	emacsfn.h
	exec.c
	funcs.c
	main.c
	misc.c
	sh.h
	var.c
This commit is contained in:
KO Myung-Hun
2015-07-21 14:23:39 +09:00
16 changed files with 415 additions and 255 deletions

26
misc.c
View File

@ -30,7 +30,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.236 2015/07/05 14:58:33 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.238 2015/07/10 19:36:36 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@ -1421,12 +1421,12 @@ do_realpath(const char *upath)
/* max. recursion depth */
int symlinks = 32;
if (IS_ABS_PATH(upath)) {
if (mksh_abspath(upath)) {
/* upath is an absolute pathname */
strdupx(ipath, upath, ATEMP);
} else {
/* upath is a relative pathname, prepend cwd */
if ((tp = ksh_get_wd()) == NULL || !IS_ABS_PATH(tp))
if ((tp = ksh_get_wd()) == NULL || !mksh_abspath(tp))
return (NULL);
ipath = shf_smprintf("%s%s%s", tp, "/", upath);
afree(tp, ATEMP);
@ -1529,7 +1529,7 @@ do_realpath(const char *upath)
tp = shf_smprintf("%s%s%s", ldest, *ip ? "/" : "", ip);
afree(ipath, ATEMP);
ip = ipath = tp;
if (!IS_ABS_PATH(ldest)) {
if (!mksh_abspath(ldest)) {
/* symlink target is a relative path */
xp = Xrestpos(xs, xp, pos);
} else
@ -1629,7 +1629,7 @@ make_path(const char *cwd, const char *file,
if (!file)
file = null;
if (IS_ABS_PATH(file)) {
if (mksh_abspath(file)) {
*phys_pathp = 0;
use_cdpath = false;
} else {
@ -1646,15 +1646,15 @@ make_path(const char *cwd, const char *file,
if (!plist)
use_cdpath = false;
else if (use_cdpath) {
char *pend;
char *pend = plist;
for (pend = plist; *pend && *pend != PATH_SEP; pend++)
;
while (*pend && *pend != MKSH_PATHSEPC)
++pend;
plen = pend - plist;
*cdpathp = *pend ? pend + 1 : NULL;
}
if ((!use_cdpath || !plen || !IS_ABS_PATH(plist)) &&
if ((!use_cdpath || !plen || !mksh_abspath(plist)) &&
(cwd && *cwd)) {
len = strlen(cwd);
XcheckN(*xsp, xp, len);
@ -1743,7 +1743,7 @@ simplify_path(char *p)
continue;
else if (len == 2 && tp[1] == '.') {
/* parent level, but how? */
if (IS_ABS_PATH(p))
if (mksh_abspath(p))
/* absolute path, only one way */
goto strip_last_component;
else if (dp > sp) {
@ -1943,7 +1943,7 @@ c_cd(const char **wp)
/* Ignore failure (happens if readonly or integer) */
setstr(oldpwd_s, current_wd, KSH_RETURN_ERROR);
if (!IS_ABS_PATH(Xstring(xs, xp))) {
if (!mksh_abspath(Xstring(xs, xp))) {
pwd = NULL;
} else if (!physical) {
goto norealpath_PWD;
@ -2021,9 +2021,9 @@ chvt(const Getopt *go)
#endif
}
}
if ((fd = open(dv, O_RDWR | O_BINARY)) < 0) {
if ((fd = binopen2(dv, O_RDWR)) < 0) {
sleep(1);
if ((fd = open(dv, O_RDWR | O_BINARY)) < 0) {
if ((fd = binopen2(dv, O_RDWR)) < 0) {
errorf("%s: %s %s", "chvt", "can't open", dv);
}
}