From 7d387fd54e80dec9f95055d1387b124f75d5e5b5 Mon Sep 17 00:00:00 2001 From: tg Date: Sat, 12 Nov 2016 03:54:48 +0000 Subject: [PATCH] fix embarassing pasto and OS/2 UNC logic; thanks komh! --- exec.c | 4 ++-- misc.c | 17 +++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/exec.c b/exec.c index 882b628..0a7ac0b 100644 --- a/exec.c +++ b/exec.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.186 2016/11/11 23:31:34 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.187 2016/11/12 03:54:48 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh" @@ -1242,7 +1242,7 @@ search_access(const char *fn, int mode) } #ifdef __OS2__ /* treat all files as executable on OS/2 */ - sb.st_mode &= S_IXUSR | S_IXGRP | S_IXOTH; + sb.st_mode |= S_IXUSR | S_IXGRP | S_IXOTH; #endif if (mode == X_OK && (!S_ISREG(sb.st_mode) || !(sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))) diff --git a/misc.c b/misc.c index 647d1d1..1f845c2 100644 --- a/misc.c +++ b/misc.c @@ -30,7 +30,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.249 2016/11/11 23:31:35 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.250 2016/11/12 03:54:48 tg Exp $"); #define KSH_CHVT_FLAG #ifdef MKSH_SMALL @@ -1541,12 +1541,11 @@ do_realpath(const char *upath) /* symlink target is an absolute path */ xp = Xstring(xs, xp); beginning_of_a_pathname: - /* assert: (ip == ipath)[0] == '/' */ + /* assert: mksh_cdirsep((ip == ipath)[0]) */ /* assert: xp == xs.beg => start of path */ /* exactly two leading slashes? (SUSv4 3.266) */ - /* @komh do NOT use mksh_cdirsep() here */ - if (ip[1] == '/' && ip[2] != '/') { + if (ip[1] == ip[0] && !mksh_cdirsep(ip[2])) { /* keep them, e.g. for UNC pathnames */ Xput(xs, xp, '/'); } @@ -1711,15 +1710,13 @@ simplify_path(char *p) case 0: return; case '/': - /* exactly two leading slashes? (SUSv4 3.266) */ - /* @komh no mksh_cdirsep() here! */ - if (p[1] == '/' && p[2] != '/') - /* keep them, e.g. for UNC pathnames */ - ++p; #ifdef __OS2__ - /* FALLTHROUGH */ case '\\': #endif + /* exactly two leading slashes? (SUSv4 3.266) */ + if (p[1] == p[0] && !mksh_cdirsep(p[2])) + /* keep them, e.g. for UNC pathnames */ + ++p; needslash = true; break; default: