From d68e69bd5983a0484ad2999830dc9034007d4ae4 Mon Sep 17 00:00:00 2001 From: tg Date: Sun, 2 Apr 2017 13:08:07 +0000 Subject: [PATCH] =?UTF-8?q?split=20path-specific=20('C:\FOO'=20instead=20o?= =?UTF-8?q?f=20'/foo')=20stuff=20into=20MKSH=5FDOSPATH:=20=E2=80=A2=20back?= =?UTF-8?q?slashes=20as=20directory=20separators=20=E2=80=A2=20semicolon?= =?UTF-8?q?=20as=20$PATH=20separator=20=E2=80=A2=20drive=20letters=20are?= =?UTF-8?q?=20absolute=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exec.c | 4 ++-- misc.c | 4 ++-- sh.h | 25 +++++++++++++++++-------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/exec.c b/exec.c index 7ed7183..41273df 100644 --- a/exec.c +++ b/exec.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.191 2017/03/22 00:20:51 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.192 2017/04/02 13:08:06 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh" @@ -1136,7 +1136,7 @@ findcom(const char *name, int flags) union mksh_cchack npath; if (mksh_vdirsep(name) -#ifdef __OS2__ +#ifdef MKSH_DOSPATH && (strcmp(name, T_builtin) != 0) #endif ) { diff --git a/misc.c b/misc.c index 50e5388..c560958 100644 --- a/misc.c +++ b/misc.c @@ -30,7 +30,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.253 2017/03/26 00:10:24 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.254 2017/04/02 13:08:06 tg Exp $"); #define KSH_CHVT_FLAG #ifdef MKSH_SMALL @@ -1705,7 +1705,7 @@ simplify_path(char *p) case 0: return; case '/': -#ifdef __OS2__ +#ifdef MKSH_DOSPATH case '\\': #endif /* exactly two leading slashes? (SUSv4 3.266) */ diff --git a/sh.h b/sh.h index 6efbfc6..dd50312 100644 --- a/sh.h +++ b/sh.h @@ -175,7 +175,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.798 2017/03/26 00:10:25 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.799 2017/04/02 13:08:07 tg Exp $"); #endif #define MKSH_VERSION "R54 2017/03/25" @@ -392,13 +392,21 @@ struct rusage { #endif #ifdef __OS2__ +#define MKSH_UNIXROOT "/@unixroot" +#define MKSH_DOSPATH +#else +#define MKSH_UNIXROOT "" +#endif + +#ifdef MKSH_DOSPATH +#ifndef __GNUC__ +# error GCC extensions needed later on +#endif #define MKSH_PATHSEPS ";" #define MKSH_PATHSEPC ';' -#define MKSH_UNIXROOT "/@unixroot" #else #define MKSH_PATHSEPS ":" #define MKSH_PATHSEPC ':' -#define MKSH_UNIXROOT "" #endif #if !HAVE_FLOCK_DECL @@ -2405,9 +2413,6 @@ EXTERN bool tty_hasstate; /* true if tty_state is valid */ extern int tty_init_fd(void); /* initialise tty_fd, tty_devtty */ #ifdef __OS2__ -#ifndef __GNUC__ -# error oops? -#endif #define binopen2(path,flags) __extension__({ \ int binopen2_fd = open((path), (flags) | O_BINARY); \ if (binopen2_fd >= 0) \ @@ -2420,6 +2425,12 @@ extern int tty_init_fd(void); /* initialise tty_fd, tty_devtty */ setmode(binopen3_fd, O_BINARY); \ (binopen3_fd); \ }) +#else +#define binopen2(path,flags) open((path), (flags) | O_BINARY) +#define binopen3(path,flags,mode) open((path), (flags) | O_BINARY, (mode)) +#endif + +#ifdef MKSH_DOSPATH #define mksh_abspath(s) __extension__({ \ const char *mksh_abspath_s = (s); \ (mksh_cdirsep(mksh_abspath_s[0]) || \ @@ -2436,8 +2447,6 @@ extern int tty_init_fd(void); /* initialise tty_fd, tty_devtty */ * can merge this upstream, but good job so far @komh, thanks! */ #else -#define binopen2(path,flags) open((path), (flags) | O_BINARY) -#define binopen3(path,flags,mode) open((path), (flags) | O_BINARY, (mode)) #define mksh_abspath(s) ((s)[0] == '/') #define mksh_cdirsep(c) ((c) == '/') #define mksh_sdirsep(s) strchr((s), '/')