Module Name: src Committed By: kamil Date: Thu Jun 22 13:33:39 UTC 2017
Modified Files: src/bin/ksh: c_ksh.c c_sh.c config.h edit.c emacs.c eval.c exec.c history.c io.c jobs.c lex.c main.c misc.c path.c sh.h shf.c tree.h vi.c Log Message: Remove os2 support in ksh(1) OK by <kre> To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/bin/ksh/c_ksh.c cvs rdiff -u -r1.16 -r1.17 src/bin/ksh/c_sh.c src/bin/ksh/eval.c cvs rdiff -u -r1.8 -r1.9 src/bin/ksh/config.h src/bin/ksh/sh.h cvs rdiff -u -r1.26 -r1.27 src/bin/ksh/edit.c cvs rdiff -u -r1.32 -r1.33 src/bin/ksh/emacs.c cvs rdiff -u -r1.15 -r1.16 src/bin/ksh/exec.c src/bin/ksh/lex.c \ src/bin/ksh/main.c cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/history.c cvs rdiff -u -r1.9 -r1.10 src/bin/ksh/io.c src/bin/ksh/path.c cvs rdiff -u -r1.10 -r1.11 src/bin/ksh/jobs.c cvs rdiff -u -r1.17 -r1.18 src/bin/ksh/misc.c cvs rdiff -u -r1.7 -r1.8 src/bin/ksh/shf.c cvs rdiff -u -r1.4 -r1.5 src/bin/ksh/tree.h cvs rdiff -u -r1.13 -r1.14 src/bin/ksh/vi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/ksh/c_ksh.c diff -u src/bin/ksh/c_ksh.c:1.19 src/bin/ksh/c_ksh.c:1.20 --- src/bin/ksh/c_ksh.c:1.19 Thu Jun 22 13:32:04 2017 +++ src/bin/ksh/c_ksh.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: c_ksh.c,v 1.19 2017/06/22 13:32:04 kamil Exp $ */ +/* $NetBSD: c_ksh.c,v 1.20 2017/06/22 13:33:39 kamil Exp $ */ /* * built-in Korn commands: c_* @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: c_ksh.c,v 1.19 2017/06/22 13:32:04 kamil Exp $"); +__RCSID("$NetBSD: c_ksh.c,v 1.20 2017/06/22 13:33:39 kamil Exp $"); #endif #include "sh.h" @@ -141,15 +141,7 @@ c_cd(wp) setstr(oldpwd_s, current_wd, KSH_RETURN_ERROR); if (!ISABSPATH(Xstring(xs, xp))) { -#ifdef OS2 - /* simplify_path() doesn't know about os/2's drive contexts, - * so it can't set current_wd when changing to a:foo. - * Handle this by calling getcwd()... - */ - pwd = ksh_get_wd((char *) 0, 0); -#else /* OS2 */ pwd = (char *) 0; -#endif /* OS2 */ } else #ifdef S_ISLNK if (!physical || !(pwd = get_phys_path(Xstring(xs, xp)))) @@ -232,7 +224,6 @@ c_print(wp) #define PO_PMINUSMINUS BIT(2) /* print a -- argument */ #define PO_HIST BIT(3) /* print to history instead of stdout */ #define PO_COPROC BIT(4) /* printing to coprocess: block SIGPIPE */ -#define PO_FSLASH BIT(5) /* swap slash for backslash (for os2 ) */ int fd = 1; int flags = PO_EXPAND|PO_NL; char *s; @@ -273,11 +264,7 @@ c_print(wp) } } else { int optc; -#if OS2 - const char *options = "Rnpfrsu,"; /* added f flag */ -#else const char *options = "Rnprsu,"; -#endif while ((optc = ksh_getopt(wp, &builtin_opt, options)) != EOF) switch (optc) { case 'R': /* fake BSD echo command */ @@ -288,11 +275,6 @@ c_print(wp) case 'e': flags |= PO_EXPAND; break; -#ifdef OS2 - case 'f': - flags |= PO_FSLASH; - break; -#endif case 'n': flags &= ~PO_NL; break; @@ -338,13 +320,6 @@ c_print(wp) s = *wp; while ((c = *s++) != '\0') { Xcheck(xs, xp); -#ifdef OS2 - if ((flags & PO_FSLASH) && c == '\\') - if (*s == '\\') - *s++; - else - c = '/'; -#endif /* OS2 */ if ((flags & PO_EXPAND) && c == '\\') { int i; Index: src/bin/ksh/c_sh.c diff -u src/bin/ksh/c_sh.c:1.16 src/bin/ksh/c_sh.c:1.17 --- src/bin/ksh/c_sh.c:1.16 Tue Oct 11 06:31:07 2016 +++ src/bin/ksh/c_sh.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: c_sh.c,v 1.16 2016/10/11 06:31:07 dholland Exp $ */ +/* $NetBSD: c_sh.c,v 1.17 2017/06/22 13:33:39 kamil Exp $ */ /* * built-in Bourne commands @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: c_sh.c,v 1.16 2016/10/11 06:31:07 dholland Exp $"); +__RCSID("$NetBSD: c_sh.c,v 1.17 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -331,9 +331,6 @@ c_read(wp) while (1) { c = shf_getc(shf); if (c == '\0' -#ifdef OS2 - || c == '\r' -#endif /* OS2 */ ) continue; if (c == EOF && shf_error(shf) @@ -905,13 +902,5 @@ const struct builtin shbuiltins [] = { {"ulimit", c_ulimit}, {"+umask", c_umask}, {"*=unset", c_unset}, -#ifdef OS2 - /* In OS2, the first line of a file can be "extproc name", which - * tells the command interpreter (cmd.exe) to use name to execute - * the file. For this to be useful, ksh must ignore commands - * starting with extproc and this does the trick... - */ - {"extproc", c_label}, -#endif /* OS2 */ {NULL, NULL} }; Index: src/bin/ksh/eval.c diff -u src/bin/ksh/eval.c:1.16 src/bin/ksh/eval.c:1.17 --- src/bin/ksh/eval.c:1.16 Tue Oct 4 15:09:03 2016 +++ src/bin/ksh/eval.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.16 2016/10/04 15:09:03 joerg Exp $ */ +/* $NetBSD: eval.c,v 1.17 2017/06/22 13:33:39 kamil Exp $ */ /* * Expansion - quoting, separation, substitution, globbing @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: eval.c,v 1.16 2016/10/04 15:09:03 joerg Exp $"); +__RCSID("$NetBSD: eval.c,v 1.17 2017/06/22 13:33:39 kamil Exp $"); #endif #include <stdint.h> @@ -1062,15 +1062,7 @@ globit(xs, xpp, sp, wp, check) *xp = '\0'; } } -#ifdef OS2 /* Done this way to avoid bug in gcc 2.7.2... */ - /* Ugly kludge required for command - * completion - see how search_access() - * is implemented for OS/2... - */ -# define KLUDGE_VAL 4 -#else /* OS2 */ # define KLUDGE_VAL 0 -#endif /* OS2 */ XPput(*wp, str_nsave(Xstring(*xs, xp), Xlength(*xs, xp) + KLUDGE_VAL, ATEMP)); return; @@ -1296,10 +1288,6 @@ homedir(name) ap = tenter(&homedirs, name, hash(name)); if (!(ap->flag & ISSET)) { -#ifdef OS2 - /* No usernames in OS2 - punt */ - return NULL; -#else /* OS2 */ struct passwd *pw; size_t n; @@ -1315,7 +1303,6 @@ homedir(name) ap->val.s = str_save(pw->pw_dir, APERM); } ap->flag |= DEFINED|ISSET|ALLOC; -#endif /* OS2 */ } return ap->val.s; } Index: src/bin/ksh/config.h diff -u src/bin/ksh/config.h:1.8 src/bin/ksh/config.h:1.9 --- src/bin/ksh/config.h:1.8 Thu Aug 19 23:00:22 2004 +++ src/bin/ksh/config.h Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: config.h,v 1.8 2004/08/19 23:00:22 christos Exp $ */ +/* $NetBSD: config.h,v 1.9 2017/06/22 13:33:39 kamil Exp $ */ /* config.h. Generated automatically by configure. */ /* config.h.in. Generated automatically from configure.in by autoheader. */ @@ -184,9 +184,6 @@ /* Define if you arg running ISC unix */ /* #undef OS_ISC */ -/* Define if you arg running OS2 with the EMX library */ -/* #undef OS2 */ - /* Define if you have a POSIX.1 compatible <sys/wait.h> */ #define POSIX_SYS_WAIT 1 Index: src/bin/ksh/sh.h diff -u src/bin/ksh/sh.h:1.8 src/bin/ksh/sh.h:1.9 --- src/bin/ksh/sh.h:1.8 Thu Jun 22 13:32:04 2017 +++ src/bin/ksh/sh.h Thu Jun 22 13:33:39 2017 @@ -1,10 +1,10 @@ -/* $NetBSD: sh.h,v 1.8 2017/06/22 13:32:04 kamil Exp $ */ +/* $NetBSD: sh.h,v 1.9 2017/06/22 13:33:39 kamil Exp $ */ /* * Public Domain Bourne/Korn shell */ -/* $Id: sh.h,v 1.8 2017/06/22 13:32:04 kamil Exp $ */ +/* $Id: sh.h,v 1.9 2017/06/22 13:33:39 kamil Exp $ */ #include "config.h" /* system and option configuration info */ @@ -203,9 +203,6 @@ typedef RETSIGTYPE (*handler_t) ARGS((in #endif /* !HAVE_KILLPG */ /* Special cases for execve(2) */ -#ifdef OS2 -extern int ksh_execve(char *cmd, char **args, char **env, int flags); -#else /* OS2 */ # if defined(OS_ISC) && defined(_POSIX_SOURCE) /* Kludge for ISC 3.2 (and other versions?) so programs will run correctly. */ # define ksh_execve(p, av, ev, flags) \ @@ -217,7 +214,6 @@ extern int ksh_execve(char *cmd, char ** # else /* OS_ISC && _POSIX */ # define ksh_execve(p, av, ev, flags) execve(p, av, ev) # endif /* OS_ISC && _POSIX */ -#endif /* OS2 */ /* this is a hang-over from older versions of the os2 port */ #define ksh_dupbase(fd, base) fcntl(fd, F_DUPFD, base) @@ -273,19 +269,10 @@ extern int dup2 ARGS((int, int)); # define EXTERN_DEFINED #endif -#ifdef OS2 -# define inDOS() (!(_emx_env & 0x200)) -#endif - #ifndef EXECSHELL /* shell to exec scripts (see also $SHELL initialization in main.c) */ -# ifdef OS2 -# define EXECSHELL (inDOS() ? "c:\\command.com" : "c:\\os2\\cmd.exe") -# define EXECSHELL_STR (inDOS() ? "COMSPEC" : "OS2_SHELL") -# else /* OS2 */ # define EXECSHELL "/bin/sh" # define EXECSHELL_STR "EXECSHELL" -# endif /* OS2 */ #endif /* ISABSPATH() means path is fully and completely specified, @@ -296,29 +283,7 @@ extern int dup2 ARGS((int, int)); * unix /foo yes yes no * unix foo no no yes * unix ../foo no no yes - * os2+cyg a:/foo yes yes no - * os2+cyg a:foo no no no - * os2+cyg /foo no yes no - * os2+cyg foo no no yes - * os2+cyg ../foo no no yes - * cyg //foo yes yes no - */ -#ifdef OS2 -# define PATHSEP ';' -# define DIRSEP '/' /* even though \ is native */ -# define DIRSEPSTR "\\" -# define ISDIRSEP(c) ((c) == '\\' || (c) == '/') -# define ISABSPATH(s) (((s)[0] && (s)[1] == ':' && ISDIRSEP((s)[2]))) -# define ISROOTEDPATH(s) (ISDIRSEP((s)[0]) || ISABSPATH(s)) -# define ISRELPATH(s) (!(s)[0] || ((s)[1] != ':' && !ISDIRSEP((s)[0]))) -# define FILECHCONV(c) (isascii(c) && isupper(c) ? tolower(c) : c) -# define FILECMP(s1, s2) stricmp(s1, s2) -# define FILENCMP(s1, s2, n) strnicmp(s1, s2, n) -extern char *ksh_strchr_dirsep(const char *path); -extern char *ksh_strrchr_dirsep(const char *path); -# define chdir _chdir2 -# define getcwd _getcwd2 -#else + */ # define PATHSEP ':' # define DIRSEP '/' # define DIRSEPSTR "/" @@ -331,7 +296,6 @@ extern char *ksh_strrchr_dirsep(const ch # define FILENCMP(s1, s2, n) strncmp(s1, s2, n) # define ksh_strchr_dirsep(p) strchr(p, DIRSEP) # define ksh_strrchr_dirsep(p) strrchr(p, DIRSEP) -#endif typedef int bool_t; #define FALSE 0 Index: src/bin/ksh/edit.c diff -u src/bin/ksh/edit.c:1.26 src/bin/ksh/edit.c:1.27 --- src/bin/ksh/edit.c:1.26 Thu Jun 22 13:32:04 2017 +++ src/bin/ksh/edit.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: edit.c,v 1.26 2017/06/22 13:32:04 kamil Exp $ */ +/* $NetBSD: edit.c,v 1.27 2017/06/22 13:33:39 kamil Exp $ */ /* * Command line editing - common code @@ -7,7 +7,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: edit.c,v 1.26 2017/06/22 13:32:04 kamil Exp $"); +__RCSID("$NetBSD: edit.c,v 1.27 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -161,10 +161,6 @@ x_read(buf, len) int x_getc() { -#ifdef OS2 - unsigned char c = _read_kbd(0, 1, 0); - return c == 0 ? 0xE0 : c; -#else /* OS2 */ char c; int n; @@ -177,7 +173,6 @@ x_getc() if (n != 1) return -1; return (int) (unsigned char) c; -#endif /* OS2 */ } void Index: src/bin/ksh/emacs.c diff -u src/bin/ksh/emacs.c:1.32 src/bin/ksh/emacs.c:1.33 --- src/bin/ksh/emacs.c:1.32 Sat Apr 25 05:11:37 2009 +++ src/bin/ksh/emacs.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: emacs.c,v 1.32 2009/04/25 05:11:37 lukem Exp $ */ +/* $NetBSD: emacs.c,v 1.33 2017/06/22 13:33:39 kamil Exp $ */ /* * Emacs-like command line editing and history @@ -10,7 +10,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: emacs.c,v 1.32 2009/04/25 05:11:37 lukem Exp $"); +__RCSID("$NetBSD: emacs.c,v 1.33 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -62,17 +62,8 @@ struct x_defbindings { #define is_cfs(c) (c == ' ' || c == '\t' || c == '"' || c == '\'') #define is_mfs(c) (!(isalnum((unsigned char)c) || c == '_' || c == '$')) /* Separator for motion */ -#ifdef OS2 - /* Deal with 8 bit chars & an extra prefix for function key (these two - * changes increase memory usage from 9,216 bytes to 24,416 bytes...) - */ -# define CHARMASK 0xFF /* 8-bit ASCII character mask */ -# define X_NTABS 4 /* normal, meta1, meta2, meta3 */ -static int x_prefix3 = 0xE0; -#else /* OS2 */ # define CHARMASK 0xFF /* 8-bit character mask */ # define X_NTABS 3 /* normal, meta1, meta2 */ -#endif /* OS2 */ #define X_TABSZ (CHARMASK+1) /* size of keydef tables etc */ /* Arguments for do_complete() @@ -234,9 +225,6 @@ static const struct x_ftab x_ftab[] = { #else { 0, 0, 0 }, #endif -#ifdef OS2 - { x_meta3, "prefix-3", XF_PREFIX }, -#else { 0, 0, 0 }, #endif /* @END-FUNC-TAB@ */ @@ -316,13 +304,6 @@ static struct x_defbindings const x_defb { XFUNC_fold_lower, 1, 'l' }, { XFUNC_fold_capitalize, 1, 'C' }, { XFUNC_fold_capitalize, 1, 'c' }, -#ifdef OS2 - { XFUNC_meta3, 0, 0xE0 }, - { XFUNC_mv_back, 3, 'K' }, - { XFUNC_mv_forw, 3, 'M' }, - { XFUNC_next_com, 3, 'P' }, - { XFUNC_prev_com, 3, 'H' }, -#endif /* OS2 */ /* These for ansi arrow keys: arguablely shouldn't be here by * default, but its simpler/faster/smaller than using termcap * entries. @@ -1209,16 +1190,6 @@ x_meta2(c) return KSTD; } -#ifdef OS2 -static int -x_meta3(c) - int c; -{ - x_curprefix = 3; - return KSTD; -} -#endif /* OS2 */ - static int x_kill(c) int c; @@ -1358,11 +1329,6 @@ x_mapin(cp, area) /* XXX -- should handle \^ escape? */ if (*cp == '^') { cp++; -#ifdef OS2 - if (*cp == '0') /* To define function keys */ - *op++ = 0xE0; - else -#endif /* OS2 */ if (*cp >= '?') /* includes '?'; ASCII */ *op++ = CTRL(*cp); else { @@ -1385,12 +1351,6 @@ x_mapout(c) static char buf[8]; register char *p = buf; -#ifdef OS2 - if (c == 0xE0) { - *p++ = '^'; - *p++ = '0'; - } else -#endif /* OS2 */ if (iscntrl((unsigned char)c)) { *p++ = '^'; *p++ = UNCTRL(c); @@ -1408,10 +1368,7 @@ x_print(prefix, key) shprintf("%s", x_mapout(x_prefix1)); if (prefix == 2) shprintf("%s", x_mapout(x_prefix2)); -#ifdef OS2 - if (prefix == 3) - shprintf("%s", x_mapout(x_prefix3)); -#endif /* OS2 */ + shprintf("%s = ", x_mapout(key)); if (x_tab[prefix][key] != XFUNC_ins_string) shprintf("%s\n", x_ftab[x_tab[prefix][key]].xf_name); @@ -1464,10 +1421,6 @@ x_bind(a1, a2, macro, list) prefix = 1; else if (x_tab[prefix][key] == XFUNC_meta2) prefix = 2; -#ifdef OS2 - else if (x_tab[prefix][key] == XFUNC_meta3) - prefix = 3; -#endif /* OS2 */ else break; } Index: src/bin/ksh/exec.c diff -u src/bin/ksh/exec.c:1.15 src/bin/ksh/exec.c:1.16 --- src/bin/ksh/exec.c:1.15 Sun Mar 25 17:23:48 2012 +++ src/bin/ksh/exec.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.15 2012/03/25 17:23:48 christos Exp $ */ +/* $NetBSD: exec.c,v 1.16 2017/06/22 13:33:39 kamil Exp $ */ /* * execute command tree @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: exec.c,v 1.15 2012/03/25 17:23:48 christos Exp $"); +__RCSID("$NetBSD: exec.c,v 1.16 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -38,10 +38,6 @@ static int dbteste_eval ARGS((Test_env * const char *, int)); static void dbteste_error ARGS((Test_env *, int, const char *)); #endif /* KSH */ -#ifdef OS2 -static int search_access1 ARGS((const char *, int, int *)); -#endif /* OS2 */ - /* * handle systems that don't have F_SETFD @@ -424,8 +420,7 @@ execute(t, flags) #endif restoresigs(); cleanup_proc_env(); - /* XINTACT bit is for OS2 */ - ksh_execve(t->str, t->args, ap, (flags & XINTACT) ? 1 : 0); + ksh_execve(t->str, t->args, ap, flags); if (errno == ENOEXEC) scriptexec(t, ap); else @@ -782,32 +777,16 @@ scriptexec(tp, ap) (void) close(fd); } if ((buf[0] == '#' && buf[1] == '!' && (cp = &buf[2])) -# ifdef OS2 - || (strncmp(buf, "extproc", 7) == 0 && isspace((unsigned char)buf[7]) - && (cp = &buf[7])) -# endif /* OS2 */ ) { while (*cp && (*cp == ' ' || *cp == '\t')) cp++; if (*cp && *cp != '\n') { char *a0 = cp, *a1 = (char *) 0; -# ifdef OS2 - char *a2 = cp; -# endif /* OS2 */ while (*cp && *cp != '\n' && *cp != ' ' && *cp != '\t') { -# ifdef OS2 - /* Allow shell search without prepended path - * if shell with / in pathname cannot be found. - * Use / explicitly so \ can be used if explicit - * needs to be forced. - */ - if (*cp == '/') - a2 = cp + 1; -# endif /* OS2 */ cp++; } if (*cp && *cp != '\n') { @@ -826,38 +805,9 @@ scriptexec(tp, ap) *cp = '\0'; if (a1) *tp->args-- = a1; -# ifdef OS2 - if (a0 != a2) { - char *tmp_a0 = str_nsave(a0, - strlen(a0) + 5, ATEMP); - if (search_access(tmp_a0, X_OK, - (int *) 0)) - a0 = a2; - afree(tmp_a0, ATEMP); - } -# endif /* OS2 */ shellv = a0; } } -# ifdef OS2 - } else { - /* Use ksh documented shell default if present - * else use OS2_SHELL which is assumed to need - * the /c option and '\' as dir separator. - */ - char *p = shellv; - - shellv = str_val(global("EXECSHELL")); - if (shellv && *shellv) - shellv = search(shellv, path, X_OK, (int *) 0); - if (!shellv || !*shellv) { - shellv = p; - *tp->args-- = "/c"; - for (p = tp->str; *p; p++) - if (*p == '/') - *p = '\\'; - } -# endif /* OS2 */ } } #endif /* SHARPBANG */ @@ -1116,7 +1066,6 @@ search_access(pathx, mode, errnop) int mode; int *errnop; /* set if candidate found, but not suitable */ { -#ifndef OS2 int ret, err = 0; struct stat statb; @@ -1136,74 +1085,8 @@ search_access(pathx, mode, errnop) if (err && errnop && !*errnop) *errnop = err; return ret; -#else /* !OS2 */ - /* - * NOTE: ASSUMES path can be modified and has enough room at the - * end of the string for a suffix (ie, 4 extra characters). - * Certain code knows this (eg, eval.c(globit()), - * exec.c(search())). - */ - static char *xsuffixes[] = { ".ksh", ".exe", ".", ".sh", ".cmd", - ".com", ".bat", (char *) 0 - }; - static char *rsuffixes[] = { ".ksh", ".", ".sh", ".cmd", ".bat", - (char *) 0 - }; - int i; - char *mpath = (char *) pathx; - char *tp = mpath + strlen(mpath); - char *p; - char **sfx; - - /* If a suffix has been specified, check if it is one of the - * suffixes that indicate the file is executable - if so, change - * the access test to R_OK... - * This code assumes OS/2 files can have only one suffix... - */ - if ((p = strrchr((p = ksh_strrchr_dirsep(mpath)) ? p : mpath, '.'))) { - if (mode == X_OK) - mode = R_OK; - return search_access1(mpath, mode, errnop); - } - /* Try appending the various suffixes. Different suffixes for - * read and execute 'cause we don't want to read an executable... - */ - sfx = mode == R_OK ? rsuffixes : xsuffixes; - for (i = 0; sfx[i]; i++) { - strcpy(tp, p = sfx[i]); - if (search_access1(mpath, R_OK, errnop) == 0) - return 0; - *tp = '\0'; - } - return -1; -#endif /* !OS2 */ } -#ifdef OS2 -static int -search_access1(pathx, mode, errnop) - const char *pathx; - int mode; - int *errnop; /* set if candidate found, but not suitable */ -{ - int ret, err = 0; - struct stat statb; - - if (stat(pathx, &statb) < 0) - return -1; - ret = eaccess(pathx, mode); - if (ret < 0) - err = errno; /* File exists, but we can't access it */ - else if (!S_ISREG(statb.st_mode)) { - ret = -1; - err = S_ISDIR(statb.st_mode) ? EISDIR : EACCES; - } - if (err && errnop && !*errnop) - *errnop = err; - return ret; -} -#endif /* OS2 */ - /* * search for command with PATH */ @@ -1221,25 +1104,7 @@ search(name, pathx, mode, errnop) if (errnop) *errnop = 0; -#ifdef OS2 - /* Xinit() allocates 8 additional bytes, so appended suffixes won't - * overflow the memory. - */ - namelen = strlen(name) + 1; - Xinit(xs, xp, namelen, ATEMP); - memcpy(Xstring(xs, xp), name, namelen); - - if (ksh_strchr_dirsep(name)) { - if (search_access(Xstring(xs, xp), mode, errnop) >= 0) - return Xstring(xs, xp); /* not Xclose() - see above */ - Xfree(xs, xp); - return NULL; - } - /* Look in current context always. (os2 style) */ - if (search_access(Xstring(xs, xp), mode, errnop) == 0) - return Xstring(xs, xp); /* not Xclose() - xp may be wrong */ -#else /* OS2 */ if (ksh_strchr_dirsep(name)) { if (search_access(name, mode, errnop) == 0) return (char *)__UNCONST(name); @@ -1248,7 +1113,6 @@ search(name, pathx, mode, errnop) namelen = strlen(name) + 1; Xinit(xs, xp, 128, ATEMP); -#endif /* OS2 */ sp = pathx; while (sp != NULL) { @@ -1265,11 +1129,7 @@ search(name, pathx, mode, errnop) XcheckN(xs, xp, namelen); memcpy(xp, name, namelen); if (search_access(Xstring(xs, xp), mode, errnop) == 0) -#ifdef OS2 - return Xstring(xs, xp); /* Not Xclose() - see above */ -#else /* OS2 */ return Xclose(xs, xp + namelen); -#endif /* OS2 */ if (*sp++ == '\0') sp = NULL; } @@ -1382,10 +1242,6 @@ iosetup(iop, tp) return -1; } u = open(cp, flags, 0666); -#ifdef OS2 - if (u < 0 && strcmp(cp, "/dev/null") == 0) - u = open("nul", flags, 0666); -#endif /* OS2 */ } if (u < 0) { /* herein() may already have printed message */ Index: src/bin/ksh/lex.c diff -u src/bin/ksh/lex.c:1.15 src/bin/ksh/lex.c:1.16 --- src/bin/ksh/lex.c:1.15 Sun Oct 16 17:12:11 2011 +++ src/bin/ksh/lex.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.15 2011/10/16 17:12:11 joerg Exp $ */ +/* $NetBSD: lex.c,v 1.16 2017/06/22 13:33:39 kamil Exp $ */ /* * lexical analysis and source input @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: lex.c,v 1.15 2011/10/16 17:12:11 joerg Exp $"); +__RCSID("$NetBSD: lex.c,v 1.16 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -220,12 +220,6 @@ yylex(cf) switch (c) { case '\\': c = getsc(); -#ifdef OS2 - if (isalnum((unsigned char)c)) { - *wp++ = CHAR, *wp++ = '\\'; - *wp++ = CHAR, *wp++ = c; - } else -#endif if (c) /* trailing \ is lost */ *wp++ = QCHAR, *wp++ = c; break; Index: src/bin/ksh/main.c diff -u src/bin/ksh/main.c:1.15 src/bin/ksh/main.c:1.16 --- src/bin/ksh/main.c:1.15 Sun Oct 16 17:12:11 2011 +++ src/bin/ksh/main.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.15 2011/10/16 17:12:11 joerg Exp $ */ +/* $NetBSD: main.c,v 1.16 2017/06/22 13:33:39 kamil Exp $ */ /* * startup, main loop, environments and error handling @@ -7,7 +7,7 @@ #include <locale.h> #ifndef lint -__RCSID("$NetBSD: main.c,v 1.15 2011/10/16 17:12:11 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.16 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -106,11 +106,6 @@ main(int argc, char *argv[]) /* chmem_push("+c", 1); */ #endif /* MEM_DEBUG */ -#ifdef OS2 - setmode (0, O_BINARY); - setmode (1, O_TEXT); -#endif - /* make sure argv[] is sane */ if (!*argv) { static const char *empty_argv[] = { @@ -303,18 +298,7 @@ main(int argc, char *argv[]) kshname = argv[argi++]; } else if (argi < argc && !Flag(FSTDIN)) { s = pushs(SFILE, ATEMP); -#ifdef OS2 - /* a bug in os2 extproc shell processing doesn't - * pass full pathnames so we have to search for it. - * This changes the behavior of 'ksh arg' to search - * the users search path but it can't be helped. - */ - s->file = search(argv[argi++], path, R_OK, (int *) 0); - if (!s->file || !*s->file) - s->file = argv[argi - 1]; -#else s->file = argv[argi++]; -#endif /* OS2 */ s->u.shf = shf_open(s->file, O_RDONLY, 0, SHF_MAPHI|SHF_CLEXEC); if (s->u.shf == NULL) { exstat = 127; /* POSIX */ @@ -374,27 +358,10 @@ main(int argc, char *argv[]) warningf(FALSE, "Cannot determine current working directory"); if (Flag(FLOGIN)) { -#ifdef OS2 - char *profile; - - /* Try to find a profile - first see if $INIT has a value, - * then try /etc/profile.ksh, then c:/usr/etc/profile.ksh. - */ - if (!Flag(FPRIVILEGED) - && strcmp(profile = substitute("$INIT/profile.ksh", 0), - "/profile.ksh")) - include(profile, 0, (char **) 0, 1); - else if (include("/etc/profile.ksh", 0, (char **) 0, 1) < 0) - include("c:/usr/etc/profile.ksh", 0, (char **) 0, 1); - if (!Flag(FPRIVILEGED)) - include(substitute("$HOME/profile.ksh", 0), 0, - (char **) 0, 1); -#else /* OS2 */ include(KSH_SYSTEM_PROFILE, 0, (char **) 0, 1); if (!Flag(FPRIVILEGED)) include(substitute("$HOME/.profile", 0), 0, (char **) 0, 1); -#endif /* OS2 */ } if (Flag(FPRIVILEGED)) @@ -418,11 +385,9 @@ main(int argc, char *argv[]) env_file = substitute(env_file, DOTILDE); if (*env_file != '\0') include(env_file, 0, (char **) 0, 1); -#ifdef OS2 else if (Flag(FTALKING)) include(substitute("$HOME/kshrc.ksh", 0), 0, (char **) 0, 1); -#endif /* OS2 */ } if (is_restricted(argv[0]) || is_restricted(str_val(global("SHELL")))) @@ -804,44 +769,9 @@ static void remove_temps(tp) struct temp *tp; { -#ifdef OS2 - static struct temp *delayed_remove; - struct temp *t, **tprev; - - if (delayed_remove) { - for (tprev = &delayed_remove, t = delayed_remove; t; t = *tprev) - /* No need to check t->pid here... */ - if (unlink(t->name) >= 0 || errno == ENOENT) { - *tprev = t->next; - afree(t, APERM); - } else - tprev = &t->next; - } -#endif /* OS2 */ - for (; tp != NULL; tp = tp->next) if (tp->pid == procpid) { -#ifdef OS2 - /* OS/2 (and dos) do not allow files that are currently - * open to be removed, so we cache it away for future - * removal. - * XXX should only do this if errno - * is Efile-still-open-can't-remove - * (but I don't know what that is...) - */ - if (unlink(tp->name) < 0 && errno != ENOENT) { - t = (struct temp *) alloc( - sizeof(struct temp) + strlen(tp->name) + 1, - APERM); - memset(t, 0, sizeof(struct temp)); - t->name = (char *) &t[1]; - strlcpy(t->name, tp->name, strlen(tp->name) + 1); - t->next = delayed_remove; - delayed_remove = t; - } -#else /* OS2 */ unlink(tp->name); -#endif /* OS2 */ } } Index: src/bin/ksh/history.c diff -u src/bin/ksh/history.c:1.12 src/bin/ksh/history.c:1.13 --- src/bin/ksh/history.c:1.12 Sat Jan 14 18:35:43 2017 +++ src/bin/ksh/history.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: history.c,v 1.12 2017/01/14 18:35:43 maya Exp $ */ +/* $NetBSD: history.c,v 1.13 2017/06/22 13:33:39 kamil Exp $ */ /* * command history @@ -19,7 +19,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: history.c,v 1.12 2017/01/14 18:35:43 maya Exp $"); +__RCSID("$NetBSD: history.c,v 1.13 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -30,11 +30,7 @@ __RCSID("$NetBSD: history.c,v 1.12 2017/ # ifdef EASY_HISTORY # ifndef HISTFILE -# ifdef OS2 -# define HISTFILE "history.ksh" -# else /* OS2 */ # define HISTFILE ".pdksh_history" -# endif /* OS2 */ # endif # else Index: src/bin/ksh/io.c diff -u src/bin/ksh/io.c:1.9 src/bin/ksh/io.c:1.10 --- src/bin/ksh/io.c:1.9 Sun Jun 26 19:09:00 2005 +++ src/bin/ksh/io.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.9 2005/06/26 19:09:00 christos Exp $ */ +/* $NetBSD: io.c,v 1.10 2017/06/22 13:33:39 kamil Exp $ */ /* * shell buffered IO and formatted output @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: io.c,v 1.9 2005/06/26 19:09:00 christos Exp $"); +__RCSID("$NetBSD: io.c,v 1.10 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -370,20 +370,7 @@ check_fd(name, mode, emsgp) return -1; } fl &= O_ACCMODE; -#ifdef OS2 - if (mode == W_OK ) { - if (setmode(fd, O_TEXT) == -1) { - if (emsgp) - *emsgp = "couldn't set write mode"; - return -1; - } - } else if (mode == R_OK) - if (setmode(fd, O_BINARY) == -1) { - if (emsgp) - *emsgp = "couldn't set read mode"; - return -1; - } -#else /* OS2 */ + /* X_OK is a kludge to disable this check for dups (x<&1): * historical shells never did this check (XXX don't know what * posix has to say). @@ -398,7 +385,6 @@ check_fd(name, mode, emsgp) : "fd not open for writing"; return -1; } -#endif /* OS2 */ return fd; } #ifdef KSH Index: src/bin/ksh/path.c diff -u src/bin/ksh/path.c:1.9 src/bin/ksh/path.c:1.10 --- src/bin/ksh/path.c:1.9 Thu Jun 22 13:32:04 2017 +++ src/bin/ksh/path.c Thu Jun 22 13:33:39 2017 @@ -1,8 +1,8 @@ -/* $NetBSD: path.c,v 1.9 2017/06/22 13:32:04 kamil Exp $ */ +/* $NetBSD: path.c,v 1.10 2017/06/22 13:33:39 kamil Exp $ */ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: path.c,v 1.9 2017/06/22 13:32:04 kamil Exp $"); +__RCSID("$NetBSD: path.c,v 1.10 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -130,10 +130,6 @@ simplify_path(pathx) if ((isrooted = ISROOTEDPATH(pathx))) very_start++; -#if defined (OS2) - if (pathx[0] && pathx[1] == ':') /* skip a: */ - very_start += 2; -#endif /* OS2 */ /* Before After * /foo/ /foo @@ -143,11 +139,6 @@ simplify_path(pathx) * .. .. * ./foo foo * foo/../../../bar ../../bar - * OS2: - * a:/foo/../.. a:/ - * a:. a: - * a:.. a:.. - * a:foo/../../blah a:../blah */ for (cur = t = start = very_start; ; ) { Index: src/bin/ksh/jobs.c diff -u src/bin/ksh/jobs.c:1.10 src/bin/ksh/jobs.c:1.11 --- src/bin/ksh/jobs.c:1.10 Sun Oct 16 17:12:11 2011 +++ src/bin/ksh/jobs.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.10 2011/10/16 17:12:11 joerg Exp $ */ +/* $NetBSD: jobs.c,v 1.11 2017/06/22 13:33:39 kamil Exp $ */ /* * Process and job control @@ -26,7 +26,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: jobs.c,v 1.10 2011/10/16 17:12:11 joerg Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.11 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -648,10 +648,6 @@ exchild(t, flags, close_fd) Flag(FMONITOR) = 0; #endif /* JOBS */ Flag(FTALKING) = 0; -#ifdef OS2 - if (tty_fd >= 0) - flags |= XINTACT; -#endif /* OS2 */ tty_close(); cleartraps(); execute(t, (flags & XERROK) | XEXEC); /* no return */ Index: src/bin/ksh/misc.c diff -u src/bin/ksh/misc.c:1.17 src/bin/ksh/misc.c:1.18 --- src/bin/ksh/misc.c:1.17 Wed May 3 00:41:34 2017 +++ src/bin/ksh/misc.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.17 2017/05/03 00:41:34 christos Exp $ */ +/* $NetBSD: misc.c,v 1.18 2017/06/22 13:33:39 kamil Exp $ */ /* * Miscellaneous functions @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: misc.c,v 1.17 2017/05/03 00:41:34 christos Exp $"); +__RCSID("$NetBSD: misc.c,v 1.18 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -323,14 +323,10 @@ change_flag(f, what, newval) #endif /* EDIT */ /* Turning off -p? */ if (f == FPRIVILEGED && oldval && !newval) { -#ifdef OS2 - ; -#else /* OS2 */ seteuid(ksheuid = getuid()); setuid(ksheuid); setegid(getgid()); setgid(getgid()); -#endif /* OS2 */ } else if (f == FPOSIX && newval) { #ifdef BRACE_EXPAND Flag(FBRACEEXPAND) = 0 Index: src/bin/ksh/shf.c diff -u src/bin/ksh/shf.c:1.7 src/bin/ksh/shf.c:1.8 --- src/bin/ksh/shf.c:1.7 Sun Jun 26 19:09:00 2005 +++ src/bin/ksh/shf.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: shf.c,v 1.7 2005/06/26 19:09:00 christos Exp $ */ +/* $NetBSD: shf.c,v 1.8 2017/06/22 13:33:39 kamil Exp $ */ /* * Shell file I/O routines @@ -6,7 +6,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: shf.c,v 1.7 2005/06/26 19:09:00 christos Exp $"); +__RCSID("$NetBSD: shf.c,v 1.8 2017/06/22 13:33:39 kamil Exp $"); #endif @@ -577,13 +577,6 @@ shf_getse(buf, bsize, shf) shf->rnleft -= ncopy; buf += ncopy; bsize -= ncopy; -#ifdef OS2 - if (end && buf > orig_buf + 1 && buf[-2] == '\r') { - buf--; - bsize++; - buf[-1] = '\n'; - } -#endif } while (!end && bsize); *buf = '\0'; Index: src/bin/ksh/tree.h diff -u src/bin/ksh/tree.h:1.4 src/bin/ksh/tree.h:1.5 --- src/bin/ksh/tree.h:1.4 Wed Jul 7 19:20:09 2004 +++ src/bin/ksh/tree.h Thu Jun 22 13:33:39 2017 @@ -1,10 +1,10 @@ -/* $NetBSD: tree.h,v 1.4 2004/07/07 19:20:09 mycroft Exp $ */ +/* $NetBSD: tree.h,v 1.5 2017/06/22 13:33:39 kamil Exp $ */ /* * command trees for compile/execute */ -/* $Id: tree.h,v 1.4 2004/07/07 19:20:09 mycroft Exp $ */ +/* $Id: tree.h,v 1.5 2017/06/22 13:33:39 kamil Exp $ */ #define NOBLOCK ((struct op *)NULL) #define NOWORD ((char *)NULL) @@ -110,7 +110,6 @@ struct ioword { #define XERROK BIT(8) /* non-zero exit ok (for set -e) */ #define XCOPROC BIT(9) /* starting a co-process */ #define XTIME BIT(10) /* timing TCOM command */ -#define XINTACT BIT(11) /* OS2: proc started from interactive session */ /* * flags to control expansion of words (assumed by t->evalflags to fit Index: src/bin/ksh/vi.c diff -u src/bin/ksh/vi.c:1.13 src/bin/ksh/vi.c:1.14 --- src/bin/ksh/vi.c:1.13 Wed Feb 3 05:26:16 2016 +++ src/bin/ksh/vi.c Thu Jun 22 13:33:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vi.c,v 1.13 2016/02/03 05:26:16 christos Exp $ */ +/* $NetBSD: vi.c,v 1.14 2017/06/22 13:33:39 kamil Exp $ */ /* * vi command editing @@ -9,7 +9,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: vi.c,v 1.13 2016/02/03 05:26:16 christos Exp $"); +__RCSID("$NetBSD: vi.c,v 1.14 2017/06/22 13:33:39 kamil Exp $"); #endif #include "config.h" @@ -274,32 +274,8 @@ vi_hook(ch) } switch (vi_insert(ch)) { case -1: -#ifdef OS2 - /* Arrow keys generate 0xe0X, where X is H.. */ - state = VCMD; - argc1 = 1; - switch (x_getc()) { - case 'H': - *curcmd='k'; - break; - case 'K': - *curcmd='h'; - break; - case 'P': - *curcmd='j'; - break; - case 'M': - *curcmd='l'; - break; - default: - vi_error(); - state = VNORMAL; - } - break; -#else /* OS2 */ vi_error(); state = VNORMAL; -#endif /* OS2 */ break; case 0: if (state == VLIT) { @@ -657,9 +633,6 @@ vi_insert(ch) saved_inslen = 0; switch (ch) { -#ifdef OS2 - case 224: /* function key prefix */ -#endif /* OS2 */ case '\0': return -1;