un-OS/2 (sorry)

no binary change
This commit is contained in:
tg 2004-12-13 19:05:09 +00:00
parent 978a1d53a1
commit c34add61ff
19 changed files with 47 additions and 483 deletions

19
aclocal.m4 vendored
View File

@ -1,4 +1,4 @@
dnl $MirBSD: src/bin/ksh/aclocal.m4,v 2.2 2004/12/13 18:53:25 tg Exp $
dnl $MirBSD: src/bin/ksh/aclocal.m4,v 2.3 2004/12/13 19:05:08 tg Exp $
dnl-
dnl Copyright (c) 2004
dnl Thorsten "mirabile" Glaser <tg@66h.42h.de>
@ -784,7 +784,7 @@ dnl
dnl Several OSes need to be detected and symbols defined so the shell can
dnl deal with them. This is a bit kludgy, but...
dnl Currently tests for:
dnl AIX, ISC (Interactive systems corp), MINIX, OS2 using EMX library,
dnl AIX, ISC (Interactive systems corp), MINIX,
dnl SCO (santa cruz operation), NEXT, Interix/MS Services for Unix
dnl DO NOT USE with AC_AIX, AC_MINIX or AC_ISC_POSIX tests as these are
dnl incorperated in this test.
@ -796,7 +796,7 @@ AC_DEFUN(KSH_OS_TYPE,
[ ksh_cv_os_type=no
# Some tests below add -C to CPPFLAGS
saveCPPFLAGS="$CPPFLAGS"
for i in AIX ISC MINIX SCO OS2_EMX TITANOS NEXT HPUX Interix; do
for i in AIX ISC MINIX SCO TITANOS NEXT HPUX Interix; do
case $i in #((
AIX)
AC_EGREP_CPP(yes,
@ -830,14 +830,6 @@ yes
[#include <unistd.h>], ksh_cv_os_type=$i)dnl
CPPFLAGS="$saveCPPFLAGS"
;; #(
OS2_EMX)
AC_EGREP_CPP(yes,
[
#ifdef __EMX__
yes
#endif
], ksh_cv_os_type=$i)dnl
;; #(
TITANOS)
AC_EGREP_CPP(YesTitan,
[
@ -914,11 +906,6 @@ is_interix_sfu
SCO)
AC_DEFINE(OS_SCO)dnl
;; #(
OS2_EMX)
# XXX change this to OS_OS2 or OS_OS2_EMX?
AC_DEFINE(OS2)dnl
ac_exe_suffix=.exe
;; #(
TITANOS)
# Need to use cc -43 to get a shell with job control
case "$CC" in #((

29
c_ksh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/c_ksh.c,v 2.1 2004/12/10 18:09:40 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_ksh.c,v 2.2 2004/12/13 19:05:08 tg Exp $ */
/* $OpenBSD: c_ksh.c,v 1.18 2004/02/10 13:03:36 jmc Exp $ */
/*
@ -13,7 +13,7 @@
#include <sys/cygwin.h>
#endif /* __CYGWIN__ */
__RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 2.1 2004/12/10 18:09:40 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 2.2 2004/12/13 19:05:08 tg Exp $");
int
c_cd(char **wp)
@ -139,15 +139,7 @@ c_cd(char **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))))
@ -228,7 +220,6 @@ c_print(char **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;
@ -269,11 +260,7 @@ c_print(char **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 */
@ -284,11 +271,6 @@ c_print(char **wp)
case 'e':
flags |= PO_EXPAND;
break;
#ifdef OS2
case 'f':
flags |= PO_FSLASH;
break;
#endif
case 'n':
flags &= ~PO_NL;
break;
@ -334,13 +316,6 @@ c_print(char **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;

18
c_sh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/c_sh.c,v 2.2 2004/12/13 16:48:53 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_sh.c,v 2.3 2004/12/13 19:05:08 tg Exp $ */
/* $OpenBSD: c_sh.c,v 1.17 2003/03/13 09:03:07 deraadt Exp $ */
/*
@ -10,7 +10,7 @@
#include "ksh_time.h"
#include "ksh_times.h"
__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.2 2004/12/13 16:48:53 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.3 2004/12/13 19:05:08 tg Exp $");
static char *clocktos(clock_t t);
@ -320,11 +320,7 @@ c_read(char **wp)
break;
while (1) {
c = shf_getc(shf);
if (c == '\0'
#ifdef OS2
|| c == '\r'
#endif /* OS2 */
)
if (c == '\0')
continue;
if (c == EOF && shf_error(shf)
&& shf_errno(shf) == EINTR)
@ -865,13 +861,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}
};

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/config.h,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/config.h,v 2.2 2004/12/13 19:05:08 tg Exp $ */
/* $OpenBSD: config.h,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -175,9 +175,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

9
edit.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/edit.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/edit.c,v 2.2 2004/12/13 19:05:08 tg Exp $ */
/* $OpenBSD: edit.c,v 1.18 2003/08/22 18:17:10 fgsch Exp $ */
/*
@ -22,7 +22,7 @@
#include <ctype.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.1 2004/12/10 18:09:41 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 2.2 2004/12/13 19:05:08 tg Exp $");
#if defined(TIOCGWINSZ)
static RETSIGTYPE x_sigwinch(int sig);
@ -154,10 +154,6 @@ x_read(char *buf, size_t len)
int
x_getc(void)
{
#ifdef OS2
unsigned char c = _read_kbd(0, 1, 0);
return c == 0 ? 0xE0 : c;
#else /* OS2 */
char c;
int n;
@ -170,7 +166,6 @@ x_getc(void)
if (n != 1)
return -1;
return (int) (unsigned char) c;
#endif /* OS2 */
}
void

52
emacs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/emacs.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/emacs.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: emacs.c,v 1.28 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -19,7 +19,7 @@
#include <locale.h>
#include "edit.h"
__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.1 2004/12/10 18:09:41 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 2.2 2004/12/13 19:05:09 tg Exp $");
static Area aedit;
#define AEDIT &aedit /* area for kill ring and macro defns */
@ -59,17 +59,8 @@ struct x_defbindings {
#define is_cfs(c) (c == ' ' || c == '\t' || c == '"' || c == '\'')
#define is_mfs(c) (!(isalnum(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 CHARMASK 0xFF /* 8-bit character mask */
#define X_NTABS 3 /* normal, meta1, meta2 */
#define X_TABSZ (CHARMASK+1) /* size of keydef tables etc */
/* Arguments for do_complete()
@ -307,13 +298,6 @@ static struct x_defbindings const x_defbindings[] = {
{ 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.
@ -1168,15 +1152,6 @@ x_meta2(int c GCC_FUNC_ATTR(unused))
return KSTD;
}
#ifdef OS2
static int
x_meta3(int c GCC_FUNC_ATTR(unused))
{
x_curprefix = 3;
return KSTD;
}
#endif /* OS2 */
static int
x_kill(int c GCC_FUNC_ATTR(unused))
{
@ -1306,11 +1281,6 @@ x_mapin(const char *cp)
/* 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 {
@ -1332,12 +1302,6 @@ x_mapout(int c GCC_FUNC_ATTR(unused))
static char buf[8];
char *p = buf;
#ifdef OS2
if (c == 0xE0) {
*p++ = '^';
*p++ = '0';
} else
#endif /* OS2 */
if (iscntrl(c)) {
*p++ = '^';
*p++ = UNCTRL(c);
@ -1354,10 +1318,6 @@ x_print(int prefix, int 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);
@ -1410,10 +1370,6 @@ x_bind(const char *a1, const char *a2, int macro, int 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;
}

22
eval.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/eval.c,v 2.2 2004/12/13 16:48:53 tg Exp $ */
/** $MirBSD: src/bin/ksh/eval.c,v 2.3 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: eval.c,v 1.16 2004/12/08 21:23:18 millert Exp $ */
/*
@ -10,7 +10,7 @@
#include "ksh_dir.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/eval.c,v 2.2 2004/12/13 16:48:53 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/eval.c,v 2.3 2004/12/13 19:05:09 tg Exp $");
/*
* string expansion
@ -1049,17 +1049,8 @@ globit(XString *xs, char **xpp, char *sp, XPtrV *wp, int 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));
XPput(*wp, str_nsave(Xstring(*xs, xp), Xlength(*xs, xp),
ATEMP));
return;
}
@ -1233,10 +1224,6 @@ homedir(char *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;
pw = getpwnam(name);
@ -1244,7 +1231,6 @@ homedir(char *name)
return NULL;
ap->val.s = str_save(pw->pw_dir, APERM);
ap->flag |= DEFINED|ISSET|ALLOC;
#endif /* OS2 */
}
return ap->val.s;
}

157
exec.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/exec.c,v 2.2 2004/12/13 16:48:53 tg Exp $ */
/** $MirBSD: src/bin/ksh/exec.c,v 2.3 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
/*
@ -10,7 +10,7 @@
#include <ctype.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.2 2004/12/13 16:48:53 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.3 2004/12/13 19:05:09 tg Exp $");
/* Does ps4 get parameter substitutions done? */
#ifdef KSH
@ -36,9 +36,6 @@ static int dbteste_eval(Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval);
static void dbteste_error(Test_env *te, int offset, const char *msg);
#endif /* KSH */
#ifdef OS2
static int search_access1(const char *path, int mode, int *errnop);
#endif /* OS2 */
/*
@ -421,8 +418,7 @@ execute(struct op *volatile t, volatile int 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, 0);
if (errno == ENOEXEC)
scriptexec(t, ap);
else
@ -772,35 +768,16 @@ scriptexec(struct op *tp, char **ap)
buf[n] = '\0';
(void) close(fd);
}
if ((buf[0] == '#' && buf[1] == '!' && (cp = &buf[2]))
# ifdef OS2
|| (strncmp(buf, "extproc", 7) == 0 && isspace(buf[7])
&& (cp = &buf[7]))
# endif /* OS2 */
)
if ((buf[0] == '#' && buf[1] == '!' && (cp = &buf[2])))
{
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 != '\t')
cp++;
}
if (*cp && *cp != '\n') {
*cp++ = '\0';
while (*cp
@ -817,38 +794,9 @@ scriptexec(struct op *tp, char **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 */
shell = 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 = shell;
shell = str_val(global("EXECSHELL"));
if (shell && *shell)
shell = search(shell, path, X_OK, (int *) 0);
if (!shell || !*shell) {
shell = p;
*tp->args-- = "/c";
for (p = tp->str; *p; p++)
if (*p == '/')
*p = '\\';
}
# endif /* OS2 */
}
}
#endif /* SHARPBANG */
@ -1094,7 +1042,6 @@ search_access(const char *path, int mode, int *errnop)
/* set if candidate found, but not suitable */
{
#ifndef OS2
int ret, err = 0;
struct stat statb;
@ -1114,74 +1061,8 @@ search_access(const char *path, int mode, int *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 *) path;
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(path, mode, errnop)
const char *path;
int mode;
int *errnop; /* set if candidate found, but not suitable */
{
int ret, err = 0;
struct stat statb;
if (stat(path, &statb) < 0)
return -1;
ret = eaccess(path, 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
*/
@ -1199,25 +1080,6 @@ search(const char *name, const char *path, int mode, int *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 *) name;
@ -1226,7 +1088,6 @@ search(const char *name, const char *path, int mode, int *errnop)
namelen = strlen(name) + 1;
Xinit(xs, xp, 128, ATEMP);
#endif /* OS2 */
sp = path;
while (sp != NULL) {
@ -1243,11 +1104,7 @@ search(const char *name, const char *path, int mode, int *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;
}
@ -1356,10 +1213,6 @@ iosetup(struct ioword *iop, struct tbl *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 */

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/history.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/history.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: history.c,v 1.24 2004/08/03 12:44:59 danh Exp $ */
/*
@ -21,17 +21,13 @@
#include "sh.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/history.c,v 2.1 2004/12/10 18:09:41 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/history.c,v 2.2 2004/12/13 19:05:09 tg Exp $");
#ifdef HISTORY
# ifdef EASY_HISTORY
# ifndef HISTFILE
# ifdef OS2
# define HISTFILE "history.ksh"
# else /* OS2 */
# define HISTFILE ".pdksh_history"
# endif /* OS2 */
# endif
# else

17
io.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/io.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/io.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
/*
@ -308,20 +308,6 @@ check_fd(char *name, int mode, const char **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).
@ -336,7 +322,6 @@ check_fd(char *name, int mode, const char **emsgp)
: "fd not open for writing";
return -1;
}
#endif /* OS2 */
return fd;
}
#ifdef KSH

8
jobs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/jobs.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/jobs.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: jobs.c,v 1.21 2003/11/10 21:26:39 millert Exp $ */
/*
@ -31,7 +31,7 @@
#include "ksh_times.h"
#include "tty.h"
__RCSID("$MirBSD: src/bin/ksh/jobs.c,v 2.1 2004/12/10 18:09:41 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/jobs.c,v 2.2 2004/12/13 19:05:09 tg Exp $");
/* Start of system configuration stuff */
@ -641,10 +641,6 @@ exchild(struct op *t, int flags, int 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 */

10
lex.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/lex.c,v 2.2 2004/12/13 16:48:53 tg Exp $ */
/** $MirBSD: src/bin/ksh/lex.c,v 2.3 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: lex.c,v 1.18 2003/08/06 21:08:05 millert Exp $ */
/*
@ -8,7 +8,7 @@
#include "sh.h"
#include <ctype.h>
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.2 2004/12/13 16:48:53 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.3 2004/12/13 19:05:09 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state.
@ -215,12 +215,6 @@ yylex(int cf)
switch (c) {
case '\\':
c = getsc();
#ifdef OS2
if (isalnum(c)) {
*wp++ = CHAR, *wp++ = '\\';
*wp++ = CHAR, *wp++ = c;
} else
#endif
if (c) /* trailing \ is lost */
*wp++ = QCHAR, *wp++ = c;
break;

80
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/main.c,v 2.3 2004/12/13 18:53:25 tg Exp $ */
/** $MirBSD: src/bin/ksh/main.c,v 2.4 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
/*
@ -15,7 +15,7 @@
* shell version
*/
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.3 2004/12/13 18:53:25 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.4 2004/12/13 19:05:09 tg Exp $");
static const char version_param[] =
#ifdef KSH
@ -119,11 +119,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[] = {
@ -327,18 +322,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 */
@ -398,27 +382,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))
@ -442,11 +409,6 @@ 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"))))
@ -816,45 +778,9 @@ reclaim(void)
static void
remove_temps(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 */
if (tp->pid == procpid)
unlink(tp->name);
#endif /* OS2 */
}
}
/* Returns true if name refers to a restricted shell */

8
misc.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/misc.c,v 2.2 2004/12/13 18:53:25 tg Exp $ */
/** $MirBSD: src/bin/ksh/misc.c,v 2.3 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -13,7 +13,7 @@
#include <sys/ioctl.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.2 2004/12/13 18:53:25 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.3 2004/12/13 19:05:09 tg Exp $");
#ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF
@ -309,14 +309,10 @@ change_flag(enum sh_flag f, int what, int 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

10
path.c
View File

@ -1,10 +1,10 @@
/** $MirBSD: src/bin/ksh/path.c,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/path.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: path.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
#include "sh.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/path.c,v 2.1 2004/12/10 18:09:42 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/path.c,v 2.2 2004/12/13 19:05:09 tg Exp $");
/*
* Contains a routine to search a : separated list of
@ -126,10 +126,10 @@ simplify_path(char *path)
if ((isrooted = ISROOTEDPATH(path)))
very_start++;
#if defined (OS2) || defined (__CYGWIN__)
#if defined (__CYGWIN__)
if (path[0] && path[1] == ':') /* skip a: */
very_start += 2;
#endif /* OS2 || __CYGWIN__ */
#endif
/* Before After
* /foo/ /foo
@ -139,7 +139,7 @@ simplify_path(char *path)
* .. ..
* ./foo foo
* foo/../../../bar ../../bar
* OS2 and CYGWIN:
* CYGWIN:
* a:/foo/../.. a:/
* a:. a:
* a:.. a:..

32
sh.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/sh.h,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/sh.h,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: sh.h,v 1.18 2004/05/31 10:36:35 otto Exp $ */
#ifndef SH_H
@ -195,9 +195,6 @@ typedef RETSIGTYPE (*handler_t)(int); /* signal handler */
#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) \
@ -209,7 +206,6 @@ extern int ksh_execve(char *cmd, char **args, char **env, int flags);
# 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)
@ -257,19 +253,10 @@ extern int dup2(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,
@ -287,22 +274,6 @@ extern int dup2(int, int);
* 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 "/"
@ -321,7 +292,6 @@ extern char *ksh_strrchr_dirsep(const char *path);
# 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

12
shf.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/shf.c,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/shf.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: shf.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */
/*
@ -9,7 +9,7 @@
#include "ksh_stat.h"
#include "ksh_limval.h"
__RCSID("$MirBSD: src/bin/ksh/shf.c,v 2.1 2004/12/10 18:09:42 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/shf.c,v 2.2 2004/12/13 19:05:09 tg Exp $");
/* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */
@ -542,14 +542,6 @@ shf_getse(char *buf, int bsize, struct shf *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';
return buf;

3
tree.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/tree.h,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/tree.h,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: tree.h,v 1.8 2003/10/22 07:40:38 jmc Exp $ */
/* $From: tree.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */
@ -113,7 +113,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

31
vi.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/vi.c,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/vi.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
/* $OpenBSD: vi.c,v 1.13 2004/05/10 16:28:47 pvalchev Exp $ */
/*
@ -15,7 +15,7 @@
#include "ksh_stat.h" /* completion */
#include "edit.h"
__RCSID("$MirBSD: src/bin/ksh/vi.c,v 2.1 2004/12/10 18:09:42 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/vi.c,v 2.2 2004/12/13 19:05:09 tg Exp $");
#define Ctrl(c) (c&0x1f)
#define is_wordch(c) (letnum(c))
@ -267,32 +267,8 @@ vi_hook(int 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) {
@ -646,9 +622,6 @@ vi_insert(int ch)
saved_inslen = 0;
switch (ch) {
#ifdef OS2
case 224: /* function key prefix */
#endif /* OS2 */
case '\0':
return -1;