run GNU protoize
protect header files nuke some dead code regenerate configure script let silly code die
This commit is contained in:
parent
dc7da8ddbf
commit
b2de14e57c
20
aclocal.m4
vendored
20
aclocal.m4
vendored
@ -1,4 +1,4 @@
|
||||
dnl $MirBSD: aclocal.m4,v 1.9 2004/05/24 19:55:54 tg Stab $
|
||||
dnl $MirBSD: aclocal.m4,v 1.10 2004/10/28 11:53:39 tg Exp $
|
||||
dnl
|
||||
dnl Copyright (c) 2004 Thorsten Glaser
|
||||
dnl Copyright (C) 1996, Memorial University of Newfoundland.
|
||||
@ -346,24 +346,6 @@ AC_DEFUN(KSH_C_VOLATILE,
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
dnl Check if function prototypes work (including stdc vararg prototypes)
|
||||
AC_DEFUN(KSH_C_PROTOTYPES,
|
||||
[AC_CACHE_CHECK(if compiler understands prototypes, ksh_cv_c_prototypes,
|
||||
[AC_TRY_COMPILE([
|
||||
#include <stdarg.h>
|
||||
void foo(char *fmt, ...);
|
||||
int bar(int a, char b, char *c);
|
||||
int bar(a, b, c) int a; char b; char *c;
|
||||
{ foo("%d%c%s\n", a, b, c); return a + b + *c; }
|
||||
void foo(char *fmt, ...) { va_list a; va_start(a, fmt); va_end(a); }
|
||||
], , ksh_cv_c_prototypes=yes, ksh_cv_c_prototypes=no)])
|
||||
if test $ksh_cv_c_prototypes = yes; then
|
||||
AC_DEFINE(HAVE_PROTOTYPES)
|
||||
fi
|
||||
])dnl
|
||||
dnl
|
||||
dnl
|
||||
dnl
|
||||
dnl Check if C compiler understands gcc's __attribute((...)).
|
||||
dnl checks for noreturn, const, and format(type,fmt,param), also checks
|
||||
dnl that the compiler doesn't die when it sees an unknown attribute (this
|
||||
|
55
c_ksh.c
55
c_ksh.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: c_ksh.c,v 1.8 2004/10/28 11:11:16 tg Exp $ */
|
||||
/** $MirBSD: c_ksh.c,v 1.9 2004/10/28 11:53:39 tg Exp $ */
|
||||
/* $OpenBSD: c_ksh.c,v 1.18 2004/02/10 13:03:36 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -13,11 +13,10 @@
|
||||
#include <sys/cygwin.h>
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
__RCSID("$MirBSD: c_ksh.c,v 1.8 2004/10/28 11:11:16 tg Exp $");
|
||||
__RCSID("$MirBSD: c_ksh.c,v 1.9 2004/10/28 11:53:39 tg Exp $");
|
||||
|
||||
int
|
||||
c_cd(wp)
|
||||
char **wp;
|
||||
c_cd(char **wp)
|
||||
{
|
||||
int optc;
|
||||
int physical = Flag(FPHYSICAL);
|
||||
@ -178,8 +177,7 @@ c_cd(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_pwd(wp)
|
||||
char **wp;
|
||||
c_pwd(char **wp)
|
||||
{
|
||||
int optc;
|
||||
int physical = Flag(FPHYSICAL);
|
||||
@ -223,8 +221,7 @@ c_pwd(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_print(wp)
|
||||
char **wp;
|
||||
c_print(char **wp)
|
||||
{
|
||||
#define PO_NL BIT(0) /* print newline */
|
||||
#define PO_EXPAND BIT(1) /* expand backslash sequences */
|
||||
@ -447,8 +444,7 @@ c_print(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_whence(wp)
|
||||
char **wp;
|
||||
c_whence(char **wp)
|
||||
{
|
||||
struct tbl *tp;
|
||||
char *id;
|
||||
@ -570,8 +566,7 @@ c_whence(wp)
|
||||
|
||||
/* Deal with command -vV - command -p dealt with in comexec() */
|
||||
int
|
||||
c_command(wp)
|
||||
char **wp;
|
||||
c_command(char **wp)
|
||||
{
|
||||
/* Let c_whence do the work. Note that c_command() must be
|
||||
* a distinct function from c_whence() (tested in comexec()).
|
||||
@ -581,8 +576,7 @@ c_command(wp)
|
||||
|
||||
/* typeset, export, and readonly */
|
||||
int
|
||||
c_typeset(wp)
|
||||
char **wp;
|
||||
c_typeset(char **wp)
|
||||
{
|
||||
struct block *l = e->loc;
|
||||
struct tbl *vp, **p;
|
||||
@ -878,8 +872,7 @@ c_typeset(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_alias(wp)
|
||||
char **wp;
|
||||
c_alias(char **wp)
|
||||
{
|
||||
struct table *t = &aliases;
|
||||
int rv = 0, rflag = 0, tflag, Uflag = 0, pflag = 0;
|
||||
@ -1015,8 +1008,7 @@ c_alias(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_unalias(wp)
|
||||
char **wp;
|
||||
c_unalias(char **wp)
|
||||
{
|
||||
struct table *t = &aliases;
|
||||
struct tbl *ap;
|
||||
@ -1069,8 +1061,7 @@ c_unalias(wp)
|
||||
|
||||
#ifdef KSH
|
||||
int
|
||||
c_let(wp)
|
||||
char **wp;
|
||||
c_let(char **wp)
|
||||
{
|
||||
int rv = 1;
|
||||
long val;
|
||||
@ -1089,8 +1080,7 @@ c_let(wp)
|
||||
#endif /* KSH */
|
||||
|
||||
int
|
||||
c_jobs(wp)
|
||||
char **wp;
|
||||
c_jobs(char **wp)
|
||||
{
|
||||
int optc;
|
||||
int flag = 0;
|
||||
@ -1128,8 +1118,7 @@ c_jobs(wp)
|
||||
|
||||
#ifdef JOBS
|
||||
int
|
||||
c_fgbg(wp)
|
||||
char **wp;
|
||||
c_fgbg(char **wp)
|
||||
{
|
||||
int bg = strcmp(*wp, "bg") == 0;
|
||||
int UNINITIALIZED(rv);
|
||||
@ -1161,11 +1150,7 @@ static char *kill_fmt_entry(void *arg, int i, char *buf, int buflen);
|
||||
|
||||
/* format a single kill item */
|
||||
static char *
|
||||
kill_fmt_entry(arg, i, buf, buflen)
|
||||
void *arg;
|
||||
int i;
|
||||
char *buf;
|
||||
int buflen;
|
||||
kill_fmt_entry(void *arg, int i, char *buf, int buflen)
|
||||
{
|
||||
struct kill_info *ki = (struct kill_info *) arg;
|
||||
|
||||
@ -1185,8 +1170,7 @@ kill_fmt_entry(arg, i, buf, buflen)
|
||||
|
||||
|
||||
int
|
||||
c_kill(wp)
|
||||
char **wp;
|
||||
c_kill(char **wp)
|
||||
{
|
||||
Trap *t = (Trap *) 0;
|
||||
char *p;
|
||||
@ -1295,8 +1279,7 @@ c_kill(wp)
|
||||
}
|
||||
|
||||
void
|
||||
getopts_reset(val)
|
||||
int val;
|
||||
getopts_reset(int val)
|
||||
{
|
||||
if (val >= 1) {
|
||||
ksh_getopt_reset(&user_opt,
|
||||
@ -1306,8 +1289,7 @@ getopts_reset(val)
|
||||
}
|
||||
|
||||
int
|
||||
c_getopts(wp)
|
||||
char **wp;
|
||||
c_getopts(char **wp)
|
||||
{
|
||||
int argc;
|
||||
const char *options;
|
||||
@ -1406,8 +1388,7 @@ c_getopts(wp)
|
||||
|
||||
#ifdef EMACS
|
||||
int
|
||||
c_bind(wp)
|
||||
char **wp;
|
||||
c_bind(char **wp)
|
||||
{
|
||||
int rv = 0, macro = 0, list = 0;
|
||||
char *cp;
|
||||
|
63
c_sh.c
63
c_sh.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: c_sh.c,v 1.6 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: c_sh.c,v 1.7 2004/10/28 11:53:39 tg Exp $ */
|
||||
/* $OpenBSD: c_sh.c,v 1.17 2003/03/13 09:03:07 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
@ -10,22 +10,20 @@
|
||||
#include "ksh_time.h"
|
||||
#include "ksh_times.h"
|
||||
|
||||
__RCSID("$MirBSD: c_sh.c,v 1.6 2004/10/28 11:11:17 tg Exp $");
|
||||
__RCSID("$MirBSD: c_sh.c,v 1.7 2004/10/28 11:53:39 tg Exp $");
|
||||
|
||||
static char *clocktos(clock_t t);
|
||||
|
||||
|
||||
/* :, false and true */
|
||||
int
|
||||
c_label(wp)
|
||||
char **wp;
|
||||
c_label(char **wp)
|
||||
{
|
||||
return wp[0][0] == 'f' ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
c_shift(wp)
|
||||
char **wp;
|
||||
c_shift(char **wp)
|
||||
{
|
||||
struct block *l = e->loc;
|
||||
int n;
|
||||
@ -56,8 +54,7 @@ c_shift(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_umask(wp)
|
||||
char **wp;
|
||||
c_umask(char **wp)
|
||||
{
|
||||
int i;
|
||||
char *cp;
|
||||
@ -176,8 +173,7 @@ c_umask(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_dot(wp)
|
||||
char **wp;
|
||||
c_dot(char **wp)
|
||||
{
|
||||
char *file, *cp;
|
||||
char **argv;
|
||||
@ -215,8 +211,7 @@ c_dot(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_wait(wp)
|
||||
char **wp;
|
||||
c_wait(char **wp)
|
||||
{
|
||||
int UNINITIALIZED(rv);
|
||||
int sig;
|
||||
@ -238,8 +233,7 @@ c_wait(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_read(wp)
|
||||
char **wp;
|
||||
c_read(char **wp)
|
||||
{
|
||||
int c = 0;
|
||||
int expand = 1, history = 0;
|
||||
@ -424,8 +418,7 @@ c_read(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_eval(wp)
|
||||
char **wp;
|
||||
c_eval(char **wp)
|
||||
{
|
||||
struct source *s;
|
||||
|
||||
@ -465,8 +458,7 @@ c_eval(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_trap(wp)
|
||||
char **wp;
|
||||
c_trap(char **wp)
|
||||
{
|
||||
int i;
|
||||
char *s;
|
||||
@ -488,18 +480,6 @@ c_trap(wp)
|
||||
shprintf(" %s\n", p->name);
|
||||
}
|
||||
}
|
||||
#if 0 /* this is ugly and not clear POSIX needs it */
|
||||
/* POSIX may need this so output of trap can be saved and
|
||||
* used to restore trap conditions
|
||||
*/
|
||||
if (anydfl) {
|
||||
shprintf("trap -- -");
|
||||
for (p = sigtraps, i = SIGNALS+1; --i >= 0; p++)
|
||||
if (p->trap == NULL && p->name)
|
||||
shprintf(" %s", p->name);
|
||||
shprintf(newline);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -525,8 +505,7 @@ c_trap(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_exitreturn(wp)
|
||||
char **wp;
|
||||
c_exitreturn(char **wp)
|
||||
{
|
||||
int how = LEXIT;
|
||||
int n;
|
||||
@ -568,8 +547,7 @@ c_exitreturn(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_brkcont(wp)
|
||||
char **wp;
|
||||
c_brkcont(char **wp)
|
||||
{
|
||||
int n, quit;
|
||||
struct env *ep, *last_ep = (struct env *) 0;
|
||||
@ -622,8 +600,7 @@ c_brkcont(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_set(wp)
|
||||
char **wp;
|
||||
c_set(char **wp)
|
||||
{
|
||||
int argi, setargs;
|
||||
struct block *l = e->loc;
|
||||
@ -658,8 +635,7 @@ c_set(wp)
|
||||
}
|
||||
|
||||
int
|
||||
c_unset(wp)
|
||||
char **wp;
|
||||
c_unset(char **wp)
|
||||
{
|
||||
char *id;
|
||||
int optc, unset_var = 1;
|
||||
@ -713,9 +689,7 @@ c_times(char **wp GCC_FUNC_ATTR(unused))
|
||||
* time pipeline (really a statement, not a built-in command)
|
||||
*/
|
||||
int
|
||||
timex(t, f)
|
||||
struct op *t;
|
||||
int f;
|
||||
timex(struct op *t, int f)
|
||||
{
|
||||
#define TF_NOARGS BIT(0)
|
||||
#define TF_NOREAL BIT(1) /* don't report real time */
|
||||
@ -770,9 +744,7 @@ timex(t, f)
|
||||
}
|
||||
|
||||
void
|
||||
timex_hook(t, app)
|
||||
struct op *t;
|
||||
char ** volatile *app;
|
||||
timex_hook(struct op *t, char **volatile *app)
|
||||
{
|
||||
char **wp = *app;
|
||||
int optc;
|
||||
@ -805,8 +777,7 @@ timex_hook(t, app)
|
||||
}
|
||||
|
||||
static char *
|
||||
clocktos(t)
|
||||
clock_t t;
|
||||
clocktos(clock_t t)
|
||||
{
|
||||
static char temp[22]; /* enough for 64 bit clock_t */
|
||||
int i;
|
||||
|
62
c_test.c
62
c_test.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: c_test.c,v 1.6 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: c_test.c,v 1.7 2004/10/28 11:53:39 tg Exp $ */
|
||||
/* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -14,7 +14,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include "c_test.h"
|
||||
|
||||
__RCSID("$MirBSD: c_test.c,v 1.6 2004/10/28 11:11:17 tg Exp $");
|
||||
__RCSID("$MirBSD: c_test.c,v 1.7 2004/10/28 11:53:39 tg Exp $");
|
||||
|
||||
/* test(1) accepts the following grammar:
|
||||
oexpr ::= aexpr | aexpr "-o" oexpr ;
|
||||
@ -103,8 +103,7 @@ static int ptest_eval(Test_env *te, Test_op op, const char *opnd1,
|
||||
static void ptest_error(Test_env *te, int offset, const char *msg);
|
||||
|
||||
int
|
||||
c_test(wp)
|
||||
char **wp;
|
||||
c_test(char **wp)
|
||||
{
|
||||
int argc;
|
||||
int res;
|
||||
@ -188,10 +187,7 @@ c_test(wp)
|
||||
*/
|
||||
|
||||
Test_op
|
||||
test_isop(te, meta, s)
|
||||
Test_env *te;
|
||||
Test_meta meta;
|
||||
const char *s;
|
||||
test_isop(Test_env *te, Test_meta meta, const char *s)
|
||||
{
|
||||
char sc1;
|
||||
const struct t_op *otab;
|
||||
@ -211,12 +207,7 @@ test_isop(te, meta, s)
|
||||
}
|
||||
|
||||
int
|
||||
test_eval(te, op, opnd1, opnd2, do_eval)
|
||||
Test_env *te;
|
||||
Test_op op;
|
||||
const char *opnd1;
|
||||
const char *opnd2;
|
||||
int do_eval;
|
||||
test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, int do_eval)
|
||||
{
|
||||
int res;
|
||||
int not;
|
||||
@ -421,9 +412,7 @@ test_eval(te, op, opnd1, opnd2, do_eval)
|
||||
|
||||
/* Nasty kludge to handle Korn's bizarre /dev/fd hack */
|
||||
static int
|
||||
test_stat(path, statb)
|
||||
const char *path;
|
||||
struct stat *statb;
|
||||
test_stat(const char *path, struct stat *statb)
|
||||
{
|
||||
#if !defined(HAVE_DEV_FD)
|
||||
int fd;
|
||||
@ -439,9 +428,7 @@ test_stat(path, statb)
|
||||
* non-directories when running as root.
|
||||
*/
|
||||
static int
|
||||
test_eaccess(path, mode)
|
||||
const char *path;
|
||||
int mode;
|
||||
test_eaccess(const char *path, int mode)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -482,8 +469,7 @@ test_eaccess(path, mode)
|
||||
}
|
||||
|
||||
int
|
||||
test_parse(te)
|
||||
Test_env *te;
|
||||
test_parse(Test_env *te)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -496,9 +482,7 @@ test_parse(te)
|
||||
}
|
||||
|
||||
static int
|
||||
test_oexpr(te, do_eval)
|
||||
Test_env *te;
|
||||
int do_eval;
|
||||
test_oexpr(Test_env *te, int do_eval)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -511,9 +495,7 @@ test_oexpr(te, do_eval)
|
||||
}
|
||||
|
||||
static int
|
||||
test_aexpr(te, do_eval)
|
||||
Test_env *te;
|
||||
int do_eval;
|
||||
test_aexpr(Test_env *te, int do_eval)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -526,9 +508,7 @@ test_aexpr(te, do_eval)
|
||||
}
|
||||
|
||||
static int
|
||||
test_nexpr(te, do_eval)
|
||||
Test_env *te;
|
||||
int do_eval;
|
||||
test_nexpr(Test_env *te, int do_eval)
|
||||
{
|
||||
if (!(te->flags & TEF_ERROR) && (*te->isa)(te, TM_NOT))
|
||||
return !test_nexpr(te, do_eval);
|
||||
@ -536,9 +516,7 @@ test_nexpr(te, do_eval)
|
||||
}
|
||||
|
||||
static int
|
||||
test_primary(te, do_eval)
|
||||
Test_env *te;
|
||||
int do_eval;
|
||||
test_primary(Test_env *te, int do_eval)
|
||||
{
|
||||
const char *opnd1, *opnd2;
|
||||
int res;
|
||||
@ -597,9 +575,7 @@ test_primary(te, do_eval)
|
||||
* TM_UNOP and TM_BINOP, the returned value is a Test_op).
|
||||
*/
|
||||
static int
|
||||
ptest_isa(te, meta)
|
||||
Test_env *te;
|
||||
Test_meta meta;
|
||||
ptest_isa(Test_env *te, Test_meta meta)
|
||||
{
|
||||
/* Order important - indexed by Test_meta values */
|
||||
static const char *const tokens[] = {
|
||||
@ -633,21 +609,13 @@ ptest_getopnd(Test_env *te, Test_op op, int do_eval GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static int
|
||||
ptest_eval(te, op, opnd1, opnd2, do_eval)
|
||||
Test_env *te;
|
||||
Test_op op;
|
||||
const char *opnd1;
|
||||
const char *opnd2;
|
||||
int do_eval;
|
||||
ptest_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, int do_eval)
|
||||
{
|
||||
return test_eval(te, op, opnd1, opnd2, do_eval);
|
||||
}
|
||||
|
||||
static void
|
||||
ptest_error(te, offset, msg)
|
||||
Test_env *te;
|
||||
int offset;
|
||||
const char *msg;
|
||||
ptest_error(Test_env *te, int offset, const char *msg)
|
||||
{
|
||||
const char *op = te->pos.wp + offset >= te->wp_end ?
|
||||
(const char *) 0 : te->pos.wp[offset];
|
||||
|
7
c_test.h
7
c_test.h
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: c_test.h,v 1.4 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: c_test.h,v 1.5 2004/10/28 11:53:40 tg Exp $ */
|
||||
/* $OpenBSD: c_test.h,v 1.2 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
#ifndef C_TEST_H
|
||||
#define C_TEST_H
|
||||
|
||||
/* Various types of operations. Keeping things grouped nicely
|
||||
* (unary,binary) makes switch() statements more efficient.
|
||||
*/
|
||||
@ -54,3 +57,5 @@ Test_op test_isop(Test_env *te, Test_meta meta, const char *s);
|
||||
int test_eval(Test_env *te, Test_op op, const char *opnd1,
|
||||
const char *opnd2, int do_eval);
|
||||
int test_parse(Test_env *te);
|
||||
|
||||
#endif /* ndef C_TEST_H */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: c_ulimit.c,v 1.7 2004/10/28 11:03:22 tg Exp $ */
|
||||
/** $MirBSD: c_ulimit.c,v 1.8 2004/10/28 11:53:40 tg Exp $ */
|
||||
/* $OpenBSD: c_ulimit.c,v 1.10 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -32,7 +32,7 @@ extern long ulimit();
|
||||
# endif /* HAVE_ULIMIT */
|
||||
#endif /* HAVE_ULIMIT_H */
|
||||
|
||||
__RCSID("$MirBSD: c_ulimit.c,v 1.7 2004/10/28 11:03:22 tg Exp $");
|
||||
__RCSID("$MirBSD: c_ulimit.c,v 1.8 2004/10/28 11:53:40 tg Exp $");
|
||||
|
||||
#define SOFT 0x1
|
||||
#define HARD 0x2
|
||||
@ -44,8 +44,7 @@ __RCSID("$MirBSD: c_ulimit.c,v 1.7 2004/10/28 11:03:22 tg Exp $");
|
||||
#endif /* RLIM_INFINITY */
|
||||
|
||||
int
|
||||
c_ulimit(wp)
|
||||
char **wp;
|
||||
c_ulimit(char **wp)
|
||||
{
|
||||
static const struct limits {
|
||||
const char *name;
|
||||
|
20
conf-end.h
20
conf-end.h
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: conf-end.h,v 1.7 2004/09/21 11:57:07 tg Exp $ */
|
||||
/** $MirBSD: conf-end.h,v 1.8 2004/10/28 11:53:40 tg Exp $ */
|
||||
/* $OpenBSD: conf-end.h,v 1.2 1996/08/25 12:37:58 downsj Exp $ */
|
||||
|
||||
#ifndef CONF_END_H
|
||||
#define CONF_END_H
|
||||
|
||||
/* Include ksh features? */
|
||||
/* #define KSH 1 */
|
||||
|
||||
@ -23,17 +26,11 @@
|
||||
#define COMPLEX_HISTORY
|
||||
|
||||
/* Strict POSIX behaviour? */
|
||||
/* #undef POSIXLY_CORRECT */
|
||||
#undef POSIXLY_CORRECT
|
||||
|
||||
/* Specify default $ENV? */
|
||||
/* #undef DEFAULT_ENV */
|
||||
|
||||
/* Include shl(1) support? */
|
||||
/* #undef SWTCH */
|
||||
|
||||
/* Include game-of-life? */
|
||||
/* #undef SILLY */
|
||||
|
||||
/*
|
||||
* The above are defined for mirbsdksh via external
|
||||
* means, such as this header ;-)
|
||||
@ -58,11 +55,6 @@
|
||||
# define HISTORY
|
||||
#endif /* EDIT */
|
||||
|
||||
/* It's there, use it */
|
||||
#if defined(KSH) && defined(EDIT)
|
||||
# define SILLY
|
||||
#endif
|
||||
|
||||
/*
|
||||
* if you don't have mmap() you can't use Peter Collinson's history
|
||||
* mechanism. If that is the case, then define EASY_HISTORY
|
||||
@ -113,3 +105,5 @@
|
||||
# define GCC_FUNC_ATTR(x)
|
||||
# define GCC_FUNC_ATTR2(x,y)
|
||||
#endif /* HAVE_GCC_FUNC_ATTR */
|
||||
|
||||
#endif /* ndef CONF_END_H */
|
||||
|
5
config.h
5
config.h
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: config.h,v 1.12 2004/09/21 11:57:08 tg Exp $ */
|
||||
/** $MirBSD: config.h,v 1.13 2004/10/28 11:53:40 tg Exp $ */
|
||||
/* $OpenBSD: config.h,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -118,9 +118,6 @@
|
||||
/* Define to nothing if compiler doesn't like the volatile keyword */
|
||||
/* #undef volatile */
|
||||
|
||||
/* Define if C compiler groks function prototypes */
|
||||
#define HAVE_PROTOTYPES 1
|
||||
|
||||
/* Define if C compiler groks __attribute__((...)) (const, noreturn, format) */
|
||||
#define HAVE_GCC_FUNC_ATTR 1
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
dnl $MirBSD: configure.in,v 1.7 2004/05/24 19:08:52 tg Stab $
|
||||
dnl $MirBSD: configure.in,v 1.8 2004/10/28 11:53:41 tg Exp $
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script
|
||||
dnl
|
||||
@ -91,7 +91,6 @@ dnl
|
||||
AC_C_CONST
|
||||
KSH_C_VOID
|
||||
KSH_C_VOLATILE
|
||||
KSH_C_PROTOTYPES
|
||||
KSH_C_FUNC_ATTR
|
||||
dnl
|
||||
dnl System services
|
||||
|
136
edit.c
136
edit.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: edit.c,v 1.9 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: edit.c,v 1.10 2004/10/28 11:53:41 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: edit.c,v 1.9 2004/10/28 11:11:17 tg Exp $");
|
||||
__RCSID("$MirBSD: edit.c,v 1.10 2004/10/28 11:53:41 tg Exp $");
|
||||
|
||||
#if defined(TIOCGWINSZ)
|
||||
static RETSIGTYPE x_sigwinch(int sig);
|
||||
@ -42,7 +42,7 @@ static char vdisable_c;
|
||||
|
||||
/* Called from main */
|
||||
void
|
||||
x_init()
|
||||
x_init(void)
|
||||
{
|
||||
/* set to -2 to force initial binding */
|
||||
edchars.erase = edchars.kill = edchars.intr = edchars.quit
|
||||
@ -124,9 +124,7 @@ check_sigwinch(void)
|
||||
* read an edited command line
|
||||
*/
|
||||
int
|
||||
x_read(buf, len)
|
||||
char *buf;
|
||||
size_t len;
|
||||
x_read(char *buf, size_t len)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -154,7 +152,7 @@ x_read(buf, len)
|
||||
/* tty I/O */
|
||||
|
||||
int
|
||||
x_getc()
|
||||
x_getc(void)
|
||||
{
|
||||
#ifdef OS2
|
||||
unsigned char c = _read_kbd(0, 1, 0);
|
||||
@ -176,29 +174,26 @@ x_getc()
|
||||
}
|
||||
|
||||
void
|
||||
x_flush()
|
||||
x_flush(void)
|
||||
{
|
||||
shf_flush(shl_out);
|
||||
}
|
||||
|
||||
void
|
||||
x_putc(c)
|
||||
int c;
|
||||
x_putc(int c)
|
||||
{
|
||||
shf_putc(c, shl_out);
|
||||
}
|
||||
|
||||
void
|
||||
x_puts(s)
|
||||
const char *s;
|
||||
x_puts(const char *s)
|
||||
{
|
||||
while (*s != 0)
|
||||
shf_putc(*s++, shl_out);
|
||||
}
|
||||
|
||||
bool_t
|
||||
x_mode(onoff)
|
||||
bool_t onoff;
|
||||
x_mode(bool_t onoff)
|
||||
{
|
||||
static bool_t x_cur_mode;
|
||||
bool_t prev;
|
||||
@ -232,14 +227,7 @@ x_mode(onoff)
|
||||
# ifdef _BSD_SYSV /* need to force CBREAK instead of RAW (need CRMOD on output) */
|
||||
cb.c_lflag &= ~(ICANON|ECHO);
|
||||
# else
|
||||
# ifdef SWTCH /* need CBREAK to handle swtch char */
|
||||
cb.c_lflag &= ~(ICANON|ECHO);
|
||||
cb.c_lflag |= ISIG;
|
||||
cb.c_cc[VINTR] = vdisable_c;
|
||||
cb.c_cc[VQUIT] = vdisable_c;
|
||||
# else
|
||||
cb.c_lflag &= ~(ISIG|ICANON|ECHO);
|
||||
# endif
|
||||
# endif
|
||||
# ifdef VLNEXT
|
||||
/* osf/1 processes lnext when ~icanon */
|
||||
@ -331,9 +319,7 @@ x_mode(onoff)
|
||||
* length
|
||||
*/
|
||||
int
|
||||
promptlen(cp, spp)
|
||||
const char *cp;
|
||||
const char **spp;
|
||||
promptlen(const char *cp, const char **spp)
|
||||
{
|
||||
int count = 0;
|
||||
const char *sp = cp;
|
||||
@ -373,8 +359,7 @@ promptlen(cp, spp)
|
||||
}
|
||||
|
||||
void
|
||||
set_editmode(ed)
|
||||
const char *ed;
|
||||
set_editmode(const char *ed)
|
||||
{
|
||||
static const enum sh_flag edit_flags[] = {
|
||||
#ifdef EMACS
|
||||
@ -408,10 +393,7 @@ set_editmode(ed)
|
||||
* moved to the start of the line after (un)commenting.
|
||||
*/
|
||||
int
|
||||
x_do_comment(buf, bsize, lenp)
|
||||
char *buf;
|
||||
int bsize;
|
||||
int *lenp;
|
||||
x_do_comment(char *buf, int bsize, int *lenp)
|
||||
{
|
||||
int i, j;
|
||||
int len = *lenp;
|
||||
@ -460,41 +442,8 @@ static void glob_table(const char *pat, XPtrV *wp, struct table *tp);
|
||||
static void glob_path(int flags, const char *pat, XPtrV *wp,
|
||||
const char *path);
|
||||
|
||||
#if 0 /* not used... */
|
||||
int x_complete_word(const char *str, int slen, int is_command,
|
||||
int *multiple, char **ret);
|
||||
int
|
||||
x_complete_word(str, slen, is_command, nwordsp, ret)
|
||||
const char *str;
|
||||
int slen;
|
||||
int is_command;
|
||||
int *nwordsp;
|
||||
char **ret;
|
||||
{
|
||||
int nwords;
|
||||
int prefix_len;
|
||||
char **words;
|
||||
|
||||
nwords = (is_command ? x_command_glob : x_file_glob)(XCF_FULLPATH,
|
||||
str, slen, &words);
|
||||
*nwordsp = nwords;
|
||||
if (nwords == 0) {
|
||||
*ret = (char *) 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
prefix_len = x_longest_prefix(nwords, words);
|
||||
*ret = str_nsave(words[0], prefix_len, ATEMP);
|
||||
x_free_words(nwords, words);
|
||||
return prefix_len;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
void
|
||||
x_print_expansions(nwords, words, is_command)
|
||||
int nwords;
|
||||
char *const *words;
|
||||
int is_command;
|
||||
x_print_expansions(int nwords, char *const *words, int is_command)
|
||||
{
|
||||
int use_copy = 0;
|
||||
int prefix_len;
|
||||
@ -632,9 +581,7 @@ static int path_order_cmp(const void *aa, const void *bb);
|
||||
|
||||
/* Compare routine used in x_command_glob() */
|
||||
static int
|
||||
path_order_cmp(aa, bb)
|
||||
const void *aa;
|
||||
const void *bb;
|
||||
path_order_cmp(const void *aa, const void *bb)
|
||||
{
|
||||
const struct path_order_info *a = (const struct path_order_info *) aa;
|
||||
const struct path_order_info *b = (const struct path_order_info *) bb;
|
||||
@ -645,11 +592,7 @@ path_order_cmp(aa, bb)
|
||||
}
|
||||
|
||||
static int
|
||||
x_command_glob(flags, str, slen, wordsp)
|
||||
int flags;
|
||||
const char *str;
|
||||
int slen;
|
||||
char ***wordsp;
|
||||
x_command_glob(int flags, const char *str, int slen, char ***wordsp)
|
||||
{
|
||||
char *toglob;
|
||||
char *pat;
|
||||
@ -743,12 +686,7 @@ x_command_glob(flags, str, slen, wordsp)
|
||||
|| (c) == '`' || (c) == '=' || (c) == ':' )
|
||||
|
||||
static int
|
||||
x_locate_word(buf, buflen, pos, startp, is_commandp)
|
||||
const char *buf;
|
||||
int buflen;
|
||||
int pos;
|
||||
int *startp;
|
||||
int *is_commandp;
|
||||
x_locate_word(const char *buf, int buflen, int pos, int *startp, int *is_commandp)
|
||||
{
|
||||
int p;
|
||||
int start, end;
|
||||
@ -800,15 +738,7 @@ x_locate_word(buf, buflen, pos, startp, is_commandp)
|
||||
}
|
||||
|
||||
int
|
||||
x_cf_glob(flags, buf, buflen, pos, startp, endp, wordsp, is_commandp)
|
||||
int flags;
|
||||
const char *buf;
|
||||
int buflen;
|
||||
int pos;
|
||||
int *startp;
|
||||
int *endp;
|
||||
char ***wordsp;
|
||||
int *is_commandp;
|
||||
x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp, int *endp, char ***wordsp, int *is_commandp)
|
||||
{
|
||||
int len;
|
||||
int nwords;
|
||||
@ -844,9 +774,7 @@ x_cf_glob(flags, buf, buflen, pos, startp, endp, wordsp, is_commandp)
|
||||
* new string is returned.
|
||||
*/
|
||||
static char *
|
||||
add_glob(str, slen)
|
||||
const char *str;
|
||||
int slen;
|
||||
add_glob(const char *str, int slen)
|
||||
{
|
||||
char *toglob;
|
||||
char *s;
|
||||
@ -885,9 +813,7 @@ add_glob(str, slen)
|
||||
* Find longest common prefix
|
||||
*/
|
||||
int
|
||||
x_longest_prefix(nwords, words)
|
||||
int nwords;
|
||||
char *const *words;
|
||||
x_longest_prefix(int nwords, char *const *words)
|
||||
{
|
||||
int i, j;
|
||||
int prefix_len;
|
||||
@ -907,9 +833,7 @@ x_longest_prefix(nwords, words)
|
||||
}
|
||||
|
||||
void
|
||||
x_free_words(nwords, words)
|
||||
int nwords;
|
||||
char **words;
|
||||
x_free_words(int nwords, char **words)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -932,9 +856,7 @@ x_free_words(nwords, words)
|
||||
* 0
|
||||
*/
|
||||
int
|
||||
x_basename(s, se)
|
||||
const char *s;
|
||||
const char *se;
|
||||
x_basename(const char *s, const char *se)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
@ -959,10 +881,7 @@ x_basename(s, se)
|
||||
* are added to wp.
|
||||
*/
|
||||
static void
|
||||
glob_table(pat, wp, tp)
|
||||
const char *pat;
|
||||
XPtrV *wp;
|
||||
struct table *tp;
|
||||
glob_table(const char *pat, XPtrV *wp, struct table *tp)
|
||||
{
|
||||
struct tstate ts;
|
||||
struct tbl *te;
|
||||
@ -974,11 +893,7 @@ glob_table(pat, wp, tp)
|
||||
}
|
||||
|
||||
static void
|
||||
glob_path(flags, pat, wp, path)
|
||||
int flags;
|
||||
const char *pat;
|
||||
XPtrV *wp;
|
||||
const char *path;
|
||||
glob_path(int flags, const char *pat, XPtrV *wp, const char *path)
|
||||
{
|
||||
const char *sp, *p;
|
||||
char *xp;
|
||||
@ -1048,10 +963,7 @@ glob_path(flags, pat, wp, path)
|
||||
* keybinding-specific function
|
||||
*/
|
||||
int
|
||||
x_escape(s, len, putbuf_func)
|
||||
const char *s;
|
||||
size_t len;
|
||||
int putbuf_func(const char *s, size_t len);
|
||||
x_escape(const char *s, size_t len, int (*putbuf_func) (const char *, size_t))
|
||||
{
|
||||
size_t add, wlen;
|
||||
const char *ifs = str_val(local("IFS", 0));
|
||||
|
13
edit.h
13
edit.h
@ -1,7 +1,10 @@
|
||||
/** $MirBSD: edit.h,v 1.4 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: edit.h,v 1.5 2004/10/28 11:53:41 tg Exp $ */
|
||||
/* $OpenBSD: edit.h,v 1.3 1999/11/14 22:04:02 d Exp $ */
|
||||
/* $From: edit.h,v 1.2 1994/05/19 18:32:40 michael Exp michael $ */
|
||||
|
||||
#ifndef EDIT_H
|
||||
#define EDIT_H
|
||||
|
||||
/* some useful #defines */
|
||||
#ifdef EXTERN
|
||||
# define I__(i) = i
|
||||
@ -67,9 +70,5 @@ int x_vi(char *buf, size_t len);
|
||||
# undef EXTERN
|
||||
#endif
|
||||
#undef I__
|
||||
/*
|
||||
* Local Variables:
|
||||
* version-control:t
|
||||
* comment-column:40
|
||||
* End:
|
||||
*/
|
||||
|
||||
#endif /* ndef EDIT_H */
|
||||
|
162
emacs.c
162
emacs.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: emacs.c,v 1.11 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: emacs.c,v 1.12 2004/10/28 11:53:41 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: emacs.c,v 1.11 2004/10/28 11:11:17 tg Exp $");
|
||||
__RCSID("$MirBSD: emacs.c,v 1.12 2004/10/28 11:53:41 tg Exp $");
|
||||
|
||||
static Area aedit;
|
||||
#define AEDIT &aedit /* area for kill ring and macro defns */
|
||||
@ -220,11 +220,6 @@ static const struct x_ftab x_ftab[] = {
|
||||
{ x_fold_upper, "upcase-word", XF_ARG },
|
||||
{ x_set_arg, "set-arg", XF_NOBIND },
|
||||
{ x_comment, "comment", 0 },
|
||||
#ifdef SILLY
|
||||
{ x_game_of_life, "play-game-of-life", 0 },
|
||||
#else
|
||||
{ 0, 0, 0 },
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
{ x_debug_info, "debug-info", 0 },
|
||||
#else
|
||||
@ -332,9 +327,7 @@ static struct x_defbindings const x_defbindings[] = {
|
||||
};
|
||||
|
||||
int
|
||||
x_emacs(buf, len)
|
||||
char *buf;
|
||||
size_t len;
|
||||
x_emacs(char *buf, size_t len)
|
||||
{
|
||||
int c;
|
||||
const char *p;
|
||||
@ -441,9 +434,7 @@ x_ins_string(int c GCC_FUNC_ATTR(unused))
|
||||
static int x_do_ins(const char *cp, int len);
|
||||
|
||||
static int
|
||||
x_do_ins(cp, len)
|
||||
const char *cp;
|
||||
int len;
|
||||
x_do_ins(const char *cp, int len)
|
||||
{
|
||||
if (xep+len >= xend) {
|
||||
x_e_putc(BEL);
|
||||
@ -458,8 +449,7 @@ x_do_ins(cp, len)
|
||||
}
|
||||
|
||||
static int
|
||||
x_ins(s)
|
||||
char *s;
|
||||
x_ins(char *s)
|
||||
{
|
||||
char *cp = xcp;
|
||||
int adj = x_adj_done;
|
||||
@ -489,9 +479,7 @@ x_ins(s)
|
||||
* this is used for x_escape() in do_complete()
|
||||
*/
|
||||
static int
|
||||
x_emacs_putbuf(s, len)
|
||||
const char *s;
|
||||
size_t len;
|
||||
x_emacs_putbuf(const char *s, size_t len)
|
||||
{
|
||||
int rval;
|
||||
|
||||
@ -533,9 +521,7 @@ x_del_char(int c GCC_FUNC_ATTR(unused))
|
||||
|
||||
/* Delete nc chars to the right of the cursor (including cursor position) */
|
||||
static void
|
||||
x_delete(nc, push)
|
||||
int nc;
|
||||
int push;
|
||||
x_delete(int nc, int push)
|
||||
{
|
||||
int i,j;
|
||||
char *cp;
|
||||
@ -618,7 +604,7 @@ x_del_fword(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static int
|
||||
x_bword()
|
||||
x_bword(void)
|
||||
{
|
||||
int nc = 0;
|
||||
char *cp = xcp;
|
||||
@ -645,7 +631,7 @@ x_bword()
|
||||
}
|
||||
|
||||
static int
|
||||
x_fword()
|
||||
x_fword(void)
|
||||
{
|
||||
int nc = 0;
|
||||
char *cp = xcp;
|
||||
@ -671,8 +657,7 @@ x_fword()
|
||||
}
|
||||
|
||||
static void
|
||||
x_goto(cp)
|
||||
char *cp;
|
||||
x_goto(char *cp)
|
||||
{
|
||||
if (cp < xbp || cp >= (xbp + x_displen))
|
||||
{
|
||||
@ -708,8 +693,7 @@ x_bs(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static int
|
||||
x_size_str(cp)
|
||||
char *cp;
|
||||
x_size_str(char *cp)
|
||||
{
|
||||
int size = 0;
|
||||
while (*cp)
|
||||
@ -728,8 +712,7 @@ x_size(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static void
|
||||
x_zots(str)
|
||||
char *str;
|
||||
x_zots(char *str)
|
||||
{
|
||||
int adj = x_adj_done;
|
||||
|
||||
@ -881,8 +864,7 @@ x_goto_hist(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static void
|
||||
x_load_hist(hp)
|
||||
char **hp;
|
||||
x_load_hist(char **hp)
|
||||
{
|
||||
int oldsize;
|
||||
|
||||
@ -903,16 +885,14 @@ x_load_hist(hp)
|
||||
}
|
||||
|
||||
static int
|
||||
x_nl_next_com(c)
|
||||
int c;
|
||||
x_nl_next_com(int c)
|
||||
{
|
||||
x_nextcmd = source->line - (histptr - x_histp) + 1;
|
||||
return (x_newline(c));
|
||||
}
|
||||
|
||||
static int
|
||||
x_eot_del(c)
|
||||
int c;
|
||||
x_eot_del(int c)
|
||||
{
|
||||
if (xep == xbuf && x_arg_defaulted)
|
||||
return (x_end_of_text(c));
|
||||
@ -984,10 +964,7 @@ x_search_hist(int c GCC_FUNC_ATTR(unused))
|
||||
|
||||
/* search backward from current line */
|
||||
static int
|
||||
x_search(pat, sameline, offset)
|
||||
char *pat;
|
||||
int sameline;
|
||||
int offset;
|
||||
x_search(char *pat, int sameline, int offset)
|
||||
{
|
||||
char **hp;
|
||||
int i;
|
||||
@ -1009,8 +986,7 @@ x_search(pat, sameline, offset)
|
||||
|
||||
/* return position of first match of pattern in string, else -1 */
|
||||
static int
|
||||
x_match(str, pat)
|
||||
char *str, *pat;
|
||||
x_match(char *str, char *pat)
|
||||
{
|
||||
if (*pat == '^') {
|
||||
return (strncmp(str, pat+1, strlen(pat+1)) == 0) ? 0 : -1;
|
||||
@ -1065,8 +1041,7 @@ x_draw_line(int c GCC_FUNC_ATTR(unused))
|
||||
* redrawing.
|
||||
*/
|
||||
static void
|
||||
x_redraw(limit)
|
||||
int limit;
|
||||
x_redraw(int limit)
|
||||
{
|
||||
int i, j;
|
||||
char *cp;
|
||||
@ -1223,8 +1198,7 @@ x_kill(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static void
|
||||
x_push(nchars)
|
||||
int nchars;
|
||||
x_push(int nchars)
|
||||
{
|
||||
char *cp = str_nsave(xcp, nchars, AEDIT);
|
||||
if (killstack[killsp])
|
||||
@ -1311,7 +1285,7 @@ x_stuffreset(int c GCC_FUNC_ATTR(unused))
|
||||
static int
|
||||
x_stuff(int c GCC_FUNC_ATTR(unused))
|
||||
{
|
||||
#if 0 || defined TIOCSTI
|
||||
#if defined(TIOCSTI)
|
||||
char ch = c;
|
||||
bool_t savmode = x_mode(FALSE);
|
||||
|
||||
@ -1323,8 +1297,7 @@ x_stuff(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static char *
|
||||
x_mapin(cp)
|
||||
const char *cp;
|
||||
x_mapin(const char *cp)
|
||||
{
|
||||
char *new, *op;
|
||||
|
||||
@ -1375,8 +1348,7 @@ x_mapout(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static void
|
||||
x_print(prefix, key)
|
||||
int prefix, key;
|
||||
x_print(int prefix, int key)
|
||||
{
|
||||
if (prefix == 1)
|
||||
shprintf("%s", x_mapout(x_prefix1));
|
||||
@ -1394,10 +1366,10 @@ x_print(prefix, key)
|
||||
}
|
||||
|
||||
int
|
||||
x_bind(a1, a2, macro, list)
|
||||
const char *a1, *a2;
|
||||
int macro; /* bind -m */
|
||||
int list; /* bind -l */
|
||||
x_bind(const char *a1, const char *a2, int macro, int list)
|
||||
|
||||
/* bind -m */
|
||||
/* bind -l */
|
||||
{
|
||||
Findex f;
|
||||
int prefix, key;
|
||||
@ -1462,12 +1434,6 @@ x_bind(a1, a2, macro, list)
|
||||
bi_errorf("%s: no such function", a2);
|
||||
return 1;
|
||||
}
|
||||
#if 0 /* This breaks the bind commands that map arrow keys */
|
||||
if (f == XFUNC_meta1)
|
||||
x_prefix1 = key;
|
||||
if (f == XFUNC_meta2)
|
||||
x_prefix2 = key;
|
||||
#endif /* 0 */
|
||||
} else {
|
||||
f = XFUNC_ins_string;
|
||||
m2 = x_mapin(a2);
|
||||
@ -1491,7 +1457,7 @@ x_bind(a1, a2, macro, list)
|
||||
}
|
||||
|
||||
void
|
||||
x_init_emacs()
|
||||
x_init_emacs(void)
|
||||
{
|
||||
unsigned i;
|
||||
int j;
|
||||
@ -1527,9 +1493,7 @@ x_init_emacs()
|
||||
static void bind_if_not_bound(int p, int k, int func);
|
||||
|
||||
static void
|
||||
bind_if_not_bound(p, k, func)
|
||||
int p, k;
|
||||
int func;
|
||||
bind_if_not_bound(int p, int k, int func)
|
||||
{
|
||||
/* Has user already bound this key? If so, don't override it */
|
||||
if (x_bound[((p) * X_TABSZ + (k)) / 8]
|
||||
@ -1540,8 +1504,7 @@ bind_if_not_bound(p, k, func)
|
||||
}
|
||||
|
||||
void
|
||||
x_emacs_keys(ec)
|
||||
X_chars *ec;
|
||||
x_emacs_keys(X_chars *ec)
|
||||
{
|
||||
if (ec->erase >= 0) {
|
||||
bind_if_not_bound(0, ec->erase, XFUNC_del_back);
|
||||
@ -1637,58 +1600,6 @@ x_noop(int c GCC_FUNC_ATTR(unused))
|
||||
return KSTD;
|
||||
}
|
||||
|
||||
#ifdef SILLY
|
||||
static int
|
||||
x_game_of_life(int c GCC_FUNC_ATTR(unused))
|
||||
{
|
||||
char newbuf [256+1];
|
||||
char *ip, *op;
|
||||
int i, len;
|
||||
|
||||
i = xep - xbuf;
|
||||
*xep = 0;
|
||||
len = x_size_str(xbuf);
|
||||
xcp = xbp = xbuf;
|
||||
memmove(newbuf+1, xbuf, i);
|
||||
newbuf[0] = 'A';
|
||||
newbuf[i] = 'A';
|
||||
for (ip = newbuf+1, op = xbuf; --i >= 0; ip++, op++) {
|
||||
/* Empty space */
|
||||
if (*ip < '@' || *ip == '_' || *ip == 0x7F) {
|
||||
/* Two adults, make whoopee */
|
||||
if (ip[-1] < '_' && ip[1] < '_') {
|
||||
/* Make kid look like parents. */
|
||||
*op = '`' + ((ip[-1] + ip[1])/2)%32;
|
||||
if (*op == 0x7F) /* Birth defect */
|
||||
*op = '`';
|
||||
}
|
||||
else
|
||||
*op = ' '; /* nothing happens */
|
||||
continue;
|
||||
}
|
||||
/* Child */
|
||||
if (*ip > '`') {
|
||||
/* All alone, dies */
|
||||
if (ip[-1] == ' ' && ip[1] == ' ')
|
||||
*op = ' ';
|
||||
else /* Gets older */
|
||||
*op = *ip-'`'+'@';
|
||||
continue;
|
||||
}
|
||||
/* Adult */
|
||||
/* Overcrowded, dies */
|
||||
if (ip[-1] >= '@' && ip[1] >= '@') {
|
||||
*op = ' ';
|
||||
continue;
|
||||
}
|
||||
*op = *ip;
|
||||
}
|
||||
*op = 0;
|
||||
x_redraw(len);
|
||||
return KSTD;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* File/command name completion routines
|
||||
*/
|
||||
@ -1771,9 +1682,9 @@ x_expand(int c GCC_FUNC_ATTR(unused))
|
||||
|
||||
/* type == 0 for list, 1 for complete and 2 for complete-list */
|
||||
static void
|
||||
do_complete(flags, type)
|
||||
int flags; /* XCF_{COMMAND,FILE,COMMAND_FILE} */
|
||||
Comp_type type;
|
||||
do_complete(int flags, Comp_type type)
|
||||
/* XCF_{COMMAND,FILE,COMMAND_FILE} */
|
||||
|
||||
{
|
||||
char **words;
|
||||
int nwords;
|
||||
@ -1838,7 +1749,7 @@ do_complete(flags, type)
|
||||
*/
|
||||
|
||||
static void
|
||||
x_adjust()
|
||||
x_adjust(void)
|
||||
{
|
||||
x_adj_done++; /* flag the fact that we were called. */
|
||||
/*
|
||||
@ -1860,7 +1771,7 @@ x_e_ungetc(int c GCC_FUNC_ATTR(unused))
|
||||
}
|
||||
|
||||
static int
|
||||
x_e_getc()
|
||||
x_e_getc(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -1927,8 +1838,7 @@ x_debug_info(int c GCC_FUNC_ATTR(unused))
|
||||
#endif
|
||||
|
||||
static void
|
||||
x_e_puts(s)
|
||||
const char *s;
|
||||
x_e_puts(const char *s)
|
||||
{
|
||||
int adj = x_adj_done;
|
||||
|
||||
@ -2153,7 +2063,7 @@ x_fold_case(int c GCC_FUNC_ATTR(unused))
|
||||
*/
|
||||
|
||||
static char *
|
||||
x_lastcp()
|
||||
x_lastcp(void)
|
||||
{
|
||||
char *rcp;
|
||||
int i;
|
||||
|
138
eval.c
138
eval.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: eval.c,v 1.5 2004/10/28 11:11:17 tg Exp $ */
|
||||
/** $MirBSD: eval.c,v 1.6 2004/10/28 11:53:41 tg Exp $ */
|
||||
/* $OpenBSD: eval.c,v 1.14 2003/11/10 21:26:39 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -10,7 +10,7 @@
|
||||
#include "ksh_dir.h"
|
||||
#include "ksh_stat.h"
|
||||
|
||||
__RCSID("$MirBSD: eval.c,v 1.5 2004/10/28 11:11:17 tg Exp $");
|
||||
__RCSID("$MirBSD: eval.c,v 1.6 2004/10/28 11:53:41 tg Exp $");
|
||||
|
||||
/*
|
||||
* string expansion
|
||||
@ -60,9 +60,7 @@ static void alt_expand(XPtrV *wp, char *start, char *exp_start,
|
||||
|
||||
/* compile and expand word */
|
||||
char *
|
||||
substitute(cp, f)
|
||||
const char *cp;
|
||||
int f;
|
||||
substitute(const char *cp, int f)
|
||||
{
|
||||
struct source *s, *sold;
|
||||
|
||||
@ -81,9 +79,7 @@ substitute(cp, f)
|
||||
* expand arg-list
|
||||
*/
|
||||
char **
|
||||
eval(ap, f)
|
||||
char **ap;
|
||||
int f;
|
||||
eval(char **ap, int f)
|
||||
{
|
||||
XPtrV w;
|
||||
|
||||
@ -108,9 +104,7 @@ eval(ap, f)
|
||||
* expand string
|
||||
*/
|
||||
char *
|
||||
evalstr(cp, f)
|
||||
char *cp;
|
||||
int f;
|
||||
evalstr(char *cp, int f)
|
||||
{
|
||||
XPtrV w;
|
||||
|
||||
@ -126,9 +120,7 @@ evalstr(cp, f)
|
||||
* used from iosetup to expand redirection files
|
||||
*/
|
||||
char *
|
||||
evalonestr(cp, f)
|
||||
char *cp;
|
||||
int f;
|
||||
evalonestr(char *cp, int f)
|
||||
{
|
||||
XPtrV w;
|
||||
|
||||
@ -161,10 +153,10 @@ typedef struct SubType {
|
||||
} SubType;
|
||||
|
||||
void
|
||||
expand(cp, wp, f)
|
||||
char *cp; /* input word */
|
||||
XPtrV *wp; /* output words */
|
||||
int f; /* DO* flags */
|
||||
expand(char *cp, XPtrV *wp, int f)
|
||||
/* input word */
|
||||
/* output words */
|
||||
/* DO* flags */
|
||||
{
|
||||
int UNINITIALIZED(c);
|
||||
int type; /* expansion type */
|
||||
@ -691,12 +683,12 @@ expand(cp, wp, f)
|
||||
* Prepare to generate the string returned by ${} substitution.
|
||||
*/
|
||||
static int
|
||||
varsub(xp, sp, word, stypep, slenp)
|
||||
Expand *xp;
|
||||
char *sp;
|
||||
char *word;
|
||||
int *stypep; /* becomes qualifier type */
|
||||
int *slenp; /* " " len (=, :=, etc.) valid iff *stypep != 0 */
|
||||
varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp)
|
||||
|
||||
|
||||
|
||||
/* becomes qualifier type */
|
||||
/* " " len (=, :=, etc.) valid iff *stypep != 0 */
|
||||
{
|
||||
int c;
|
||||
int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */
|
||||
@ -842,9 +834,7 @@ varsub(xp, sp, word, stypep, slenp)
|
||||
* Run the command in $(...) and read its output.
|
||||
*/
|
||||
static int
|
||||
comsub(xp, cp)
|
||||
Expand *xp;
|
||||
char *cp;
|
||||
comsub(Expand *xp, char *cp)
|
||||
{
|
||||
Source *s, *sold;
|
||||
struct op *t;
|
||||
@ -896,10 +886,7 @@ comsub(xp, cp)
|
||||
*/
|
||||
|
||||
static char *
|
||||
trimsub(str, pat, how)
|
||||
char *str;
|
||||
char *pat;
|
||||
int how;
|
||||
trimsub(char *str, char *pat, int how)
|
||||
{
|
||||
char *end = strchr(str, 0);
|
||||
char *p, c;
|
||||
@ -949,10 +936,7 @@ trimsub(str, pat, how)
|
||||
|
||||
/* XXX cp not const 'cause slashes are temporarily replaced with nulls... */
|
||||
static void
|
||||
glob(cp, wp, markdirs)
|
||||
char *cp;
|
||||
XPtrV *wp;
|
||||
int markdirs;
|
||||
glob(char *cp, XPtrV *wp, int markdirs)
|
||||
{
|
||||
int oldsize = XPsize(*wp);
|
||||
|
||||
@ -972,10 +956,7 @@ glob(cp, wp, markdirs)
|
||||
* the number of matches found.
|
||||
*/
|
||||
int
|
||||
glob_str(cp, wp, markdirs)
|
||||
char *cp;
|
||||
XPtrV *wp;
|
||||
int markdirs;
|
||||
glob_str(char *cp, XPtrV *wp, int markdirs)
|
||||
{
|
||||
int oldsize = XPsize(*wp);
|
||||
XString xs;
|
||||
@ -989,12 +970,12 @@ glob_str(cp, wp, markdirs)
|
||||
}
|
||||
|
||||
static void
|
||||
globit(xs, xpp, sp, wp, check)
|
||||
XString *xs; /* dest string */
|
||||
char **xpp; /* ptr to dest end */
|
||||
char *sp; /* source path */
|
||||
XPtrV *wp; /* output list */
|
||||
int check; /* GF_* flags */
|
||||
globit(XString *xs, char **xpp, char *sp, XPtrV *wp, int check)
|
||||
/* dest string */
|
||||
/* ptr to dest end */
|
||||
/* source path */
|
||||
/* output list */
|
||||
/* GF_* flags */
|
||||
{
|
||||
char *np; /* next source component */
|
||||
char *xp = *xpp;
|
||||
@ -1135,56 +1116,9 @@ globit(xs, xpp, sp, wp, check)
|
||||
*--np = odirsep;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Check if p contains something that needs globbing; if it does, 0 is
|
||||
* returned; if not, p is copied into xs/xp after stripping any MAGICs
|
||||
*/
|
||||
static int copy_non_glob(XString *xs, char **xpp, char *p);
|
||||
static int
|
||||
copy_non_glob(xs, xpp, p)
|
||||
XString *xs;
|
||||
char **xpp;
|
||||
char *p;
|
||||
{
|
||||
char *xp;
|
||||
int len = strlen(p);
|
||||
|
||||
XcheckN(*xs, *xpp, len);
|
||||
xp = *xpp;
|
||||
for (; *p; p++) {
|
||||
if (ISMAGIC(*p)) {
|
||||
int c = *++p;
|
||||
|
||||
if (c == '*' || c == '?')
|
||||
return 0;
|
||||
if (*p == '[') {
|
||||
char *q = p + 1;
|
||||
|
||||
if (ISMAGIC(*q) && q[1] == NOT)
|
||||
q += 2;
|
||||
if (ISMAGIC(*q) && q[1] == ']')
|
||||
q += 2;
|
||||
for (; *q; q++)
|
||||
if (ISMAGIC(*q) && *++q == ']')
|
||||
return 0;
|
||||
/* pass a literal [ through */
|
||||
}
|
||||
/* must be a MAGIC-MAGIC, or MAGIC-!, MAGIC--, etc. */
|
||||
}
|
||||
*xp++ = *p;
|
||||
}
|
||||
*xp = '\0';
|
||||
*xpp = xp;
|
||||
return 1;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
/* remove MAGIC from string */
|
||||
char *
|
||||
debunk(dp, sp, dlen)
|
||||
char *dp;
|
||||
const char *sp;
|
||||
size_t dlen;
|
||||
debunk(char *dp, const char *sp, size_t dlen)
|
||||
{
|
||||
char *d, *s;
|
||||
|
||||
@ -1214,11 +1148,7 @@ debunk(dp, sp, dlen)
|
||||
* past the name, otherwise returns 0.
|
||||
*/
|
||||
static char *
|
||||
maybe_expand_tilde(p, dsp, dpp, isassign)
|
||||
char *p;
|
||||
XString *dsp;
|
||||
char **dpp;
|
||||
int isassign;
|
||||
maybe_expand_tilde(char *p, XString *dsp, char **dpp, int isassign)
|
||||
{
|
||||
XString ts;
|
||||
char *dp = *dpp;
|
||||
@ -1256,8 +1186,7 @@ maybe_expand_tilde(p, dsp, dpp, isassign)
|
||||
*/
|
||||
|
||||
static char *
|
||||
tilde(cp)
|
||||
char *cp;
|
||||
tilde(char *cp)
|
||||
{
|
||||
char *dp;
|
||||
|
||||
@ -1283,8 +1212,7 @@ tilde(cp)
|
||||
*/
|
||||
|
||||
static char *
|
||||
homedir(name)
|
||||
char *name;
|
||||
homedir(char *name)
|
||||
{
|
||||
struct tbl *ap;
|
||||
|
||||
@ -1308,11 +1236,7 @@ homedir(name)
|
||||
|
||||
#ifdef BRACE_EXPAND
|
||||
static void
|
||||
alt_expand(wp, start, exp_start, end, fdo)
|
||||
XPtrV *wp;
|
||||
char *start, *exp_start;
|
||||
char *end;
|
||||
int fdo;
|
||||
alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo)
|
||||
{
|
||||
int UNINITIALIZED(count);
|
||||
char *brace_start, *brace_end, *UNINITIALIZED(comma);
|
||||
|
122
exec.c
122
exec.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: exec.c,v 1.5 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: exec.c,v 1.6 2004/10/28 11:53:41 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: exec.c,v 1.5 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: exec.c,v 1.6 2004/10/28 11:53:41 tg Exp $");
|
||||
|
||||
/* Does ps4 get parameter substitutions done? */
|
||||
#ifdef KSH
|
||||
@ -56,8 +56,7 @@ static char clexec_tab[MAXFD+1];
|
||||
* we now use this function always.
|
||||
*/
|
||||
int
|
||||
fd_clexec(fd)
|
||||
int fd;
|
||||
fd_clexec(int fd)
|
||||
{
|
||||
#ifndef F_SETFD
|
||||
if (fd >= 0 && fd < sizeof(clexec_tab)) {
|
||||
@ -75,9 +74,9 @@ fd_clexec(fd)
|
||||
* execute command tree
|
||||
*/
|
||||
int
|
||||
execute(t, flags)
|
||||
struct op * volatile t;
|
||||
volatile int flags; /* if XEXEC don't fork */
|
||||
execute(struct op *volatile t, volatile int flags)
|
||||
|
||||
/* if XEXEC don't fork */
|
||||
{
|
||||
int i;
|
||||
volatile int rv = 0;
|
||||
@ -448,11 +447,7 @@ execute(t, flags)
|
||||
*/
|
||||
|
||||
static int
|
||||
comexec(t, tp, ap, flags)
|
||||
struct op *t;
|
||||
struct tbl *volatile tp;
|
||||
char **ap;
|
||||
int volatile flags;
|
||||
comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
|
||||
{
|
||||
int i;
|
||||
volatile int rv = 0;
|
||||
@ -754,9 +749,7 @@ comexec(t, tp, ap, flags)
|
||||
}
|
||||
|
||||
static void
|
||||
scriptexec(tp, ap)
|
||||
struct op *tp;
|
||||
char **ap;
|
||||
scriptexec(struct op *tp, char **ap)
|
||||
{
|
||||
char *shell;
|
||||
|
||||
@ -868,8 +861,7 @@ scriptexec(tp, ap)
|
||||
}
|
||||
|
||||
int
|
||||
shcomexec(wp)
|
||||
char **wp;
|
||||
shcomexec(char **wp)
|
||||
{
|
||||
struct tbl *tp;
|
||||
|
||||
@ -884,10 +876,7 @@ shcomexec(wp)
|
||||
* is created if none is found.
|
||||
*/
|
||||
struct tbl *
|
||||
findfunc(name, h, create)
|
||||
const char *name;
|
||||
unsigned int h;
|
||||
int create;
|
||||
findfunc(const char *name, unsigned int h, int create)
|
||||
{
|
||||
struct block *l;
|
||||
struct tbl *tp = (struct tbl *) 0;
|
||||
@ -912,9 +901,7 @@ findfunc(name, h, create)
|
||||
* function did not exist, returns 0 otherwise.
|
||||
*/
|
||||
int
|
||||
define(name, t)
|
||||
const char *name;
|
||||
struct op *t;
|
||||
define(const char *name, struct op *t)
|
||||
{
|
||||
struct tbl *tp;
|
||||
int was_set = 0;
|
||||
@ -957,9 +944,7 @@ define(name, t)
|
||||
* add builtin
|
||||
*/
|
||||
void
|
||||
builtin(name, func)
|
||||
const char *name;
|
||||
int (*func)(char **);
|
||||
builtin(const char *name, int (*func) (char **))
|
||||
{
|
||||
struct tbl *tp;
|
||||
Tflag flag;
|
||||
@ -987,9 +972,9 @@ builtin(name, func)
|
||||
* either function, hashed command, or built-in (in that order)
|
||||
*/
|
||||
struct tbl *
|
||||
findcom(name, flags)
|
||||
const char *name;
|
||||
int flags; /* FC_* */
|
||||
findcom(const char *name, int flags)
|
||||
|
||||
/* FC_* */
|
||||
{
|
||||
static struct tbl temp;
|
||||
unsigned int h = hash(name);
|
||||
@ -1086,8 +1071,8 @@ findcom(name, flags)
|
||||
* flush executable commands with relative paths
|
||||
*/
|
||||
void
|
||||
flushcom(all)
|
||||
int all; /* just relative or all */
|
||||
flushcom(int all)
|
||||
/* just relative or all */
|
||||
{
|
||||
struct tbl *tp;
|
||||
struct tstate ts;
|
||||
@ -1104,10 +1089,10 @@ flushcom(all)
|
||||
|
||||
/* Check if path is something we want to find. Returns -1 for failure. */
|
||||
int
|
||||
search_access(path, mode, errnop)
|
||||
const char *path;
|
||||
int mode;
|
||||
int *errnop; /* set if candidate found, but not suitable */
|
||||
search_access(const char *path, int mode, int *errnop)
|
||||
|
||||
|
||||
/* set if candidate found, but not suitable */
|
||||
{
|
||||
#ifndef OS2
|
||||
int ret, err = 0;
|
||||
@ -1201,11 +1186,11 @@ search_access1(path, mode, errnop)
|
||||
* search for command with PATH
|
||||
*/
|
||||
char *
|
||||
search(name, path, mode, errnop)
|
||||
const char *name;
|
||||
const char *path;
|
||||
int mode; /* R_OK or X_OK */
|
||||
int *errnop; /* set if candidate found, but not suitable */
|
||||
search(const char *name, const char *path, int mode, int *errnop)
|
||||
|
||||
|
||||
/* R_OK or X_OK */
|
||||
/* set if candidate found, but not suitable */
|
||||
{
|
||||
const char *sp, *p;
|
||||
char *xp;
|
||||
@ -1271,9 +1256,7 @@ search(name, path, mode, errnop)
|
||||
}
|
||||
|
||||
static int
|
||||
call_builtin(tp, wp)
|
||||
struct tbl *tp;
|
||||
char **wp;
|
||||
call_builtin(struct tbl *tp, char **wp)
|
||||
{
|
||||
int rv;
|
||||
|
||||
@ -1294,9 +1277,7 @@ call_builtin(tp, wp)
|
||||
* set up redirection, saving old fd's in e->savefd
|
||||
*/
|
||||
static int
|
||||
iosetup(iop, tp)
|
||||
struct ioword *iop;
|
||||
struct tbl *tp;
|
||||
iosetup(struct ioword *iop, struct tbl *tp)
|
||||
{
|
||||
int u = -1;
|
||||
char *cp = iop->name;
|
||||
@ -1440,9 +1421,7 @@ iosetup(iop, tp)
|
||||
* if unquoted here, expand here temp file into second temp file.
|
||||
*/
|
||||
static int
|
||||
herein(content, sub)
|
||||
const char *content;
|
||||
int sub;
|
||||
herein(const char *content, int sub)
|
||||
{
|
||||
volatile int fd = -1;
|
||||
struct source *s, *volatile osource;
|
||||
@ -1509,9 +1488,7 @@ herein(content, sub)
|
||||
* print the args in column form - assuming that we can
|
||||
*/
|
||||
static char *
|
||||
do_selectargs(ap, print_menu)
|
||||
char **ap;
|
||||
bool_t print_menu;
|
||||
do_selectargs(char **ap, bool_t print_menu)
|
||||
{
|
||||
static const char *const read_args[] = {
|
||||
"read", "-r", "REPLY", (char *) 0
|
||||
@ -1551,11 +1528,7 @@ static char *select_fmt_entry(void *arg, int i, char *buf, int buflen);
|
||||
|
||||
/* format a single select menu item */
|
||||
static char *
|
||||
select_fmt_entry(arg, i, buf, buflen)
|
||||
void *arg;
|
||||
int i;
|
||||
char *buf;
|
||||
int buflen;
|
||||
select_fmt_entry(void *arg, int i, char *buf, int buflen)
|
||||
{
|
||||
struct select_menu_info *smi = (struct select_menu_info *) arg;
|
||||
|
||||
@ -1568,8 +1541,7 @@ select_fmt_entry(arg, i, buf, buflen)
|
||||
* print a select style menu
|
||||
*/
|
||||
int
|
||||
pr_menu(ap)
|
||||
char *const *ap;
|
||||
pr_menu(char *const *ap)
|
||||
{
|
||||
struct select_menu_info smi;
|
||||
char *const *pp;
|
||||
@ -1612,19 +1584,14 @@ pr_menu(ap)
|
||||
static char *plain_fmt_entry(void *arg, int i, char *buf, int buflen);
|
||||
|
||||
static char *
|
||||
plain_fmt_entry(arg, i, buf, buflen)
|
||||
void *arg;
|
||||
int i;
|
||||
char *buf;
|
||||
int buflen;
|
||||
plain_fmt_entry(void *arg, int i, char *buf, int buflen)
|
||||
{
|
||||
shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]);
|
||||
return buf;
|
||||
}
|
||||
|
||||
int
|
||||
pr_list(ap)
|
||||
char *const *ap;
|
||||
pr_list(char *const *ap)
|
||||
{
|
||||
char *const *pp;
|
||||
int nwidth;
|
||||
@ -1653,9 +1620,7 @@ extern const char db_close[];
|
||||
* TM_UNOP and TM_BINOP, the returned value is a Test_op).
|
||||
*/
|
||||
static int
|
||||
dbteste_isa(te, meta)
|
||||
Test_env *te;
|
||||
Test_meta meta;
|
||||
dbteste_isa(Test_env *te, Test_meta meta)
|
||||
{
|
||||
int ret = 0;
|
||||
int uqword;
|
||||
@ -1694,10 +1659,7 @@ dbteste_isa(te, meta)
|
||||
}
|
||||
|
||||
static const char *
|
||||
dbteste_getopnd(te, op, do_eval)
|
||||
Test_env *te;
|
||||
Test_op op;
|
||||
int do_eval;
|
||||
dbteste_getopnd(Test_env *te, Test_op op, int do_eval)
|
||||
{
|
||||
char *s = *te->pos.wp;
|
||||
|
||||
@ -1718,21 +1680,13 @@ dbteste_getopnd(te, op, do_eval)
|
||||
}
|
||||
|
||||
static int
|
||||
dbteste_eval(te, op, opnd1, opnd2, do_eval)
|
||||
Test_env *te;
|
||||
Test_op op;
|
||||
const char *opnd1;
|
||||
const char *opnd2;
|
||||
int do_eval;
|
||||
dbteste_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, int do_eval)
|
||||
{
|
||||
return test_eval(te, op, opnd1, opnd2, do_eval);
|
||||
}
|
||||
|
||||
static void
|
||||
dbteste_error(te, offset, msg)
|
||||
Test_env *te;
|
||||
int offset;
|
||||
const char *msg;
|
||||
dbteste_error(Test_env *te, int offset, const char *msg)
|
||||
{
|
||||
te->flags |= TEF_ERROR;
|
||||
internal_errorf(0, "dbteste_error: %s (offset %d)", msg, offset);
|
||||
|
7
expand.h
7
expand.h
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: expand.h,v 1.5 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: expand.h,v 1.6 2004/10/28 11:53:41 tg Exp $ */
|
||||
/* $OpenBSD: expand.h,v 1.3 2001/03/26 16:19:45 todd Exp $ */
|
||||
|
||||
#ifndef EXPAND_H
|
||||
#define EXPAND_H
|
||||
|
||||
/*
|
||||
* Expanding strings
|
||||
*/
|
||||
@ -106,3 +109,5 @@ typedef struct XPtrV {
|
||||
sizeofN(void*, XPsize(x)), ATEMP)
|
||||
|
||||
#define XPfree(x) afree((void*) (x).beg, ATEMP)
|
||||
|
||||
#endif /* ndef EXPAND_H */
|
||||
|
45
expr.c
45
expr.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: expr.c,v 1.6 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: expr.c,v 1.7 2004/10/28 11:53:41 tg Exp $ */
|
||||
/* $OpenBSD: expr.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -8,7 +8,7 @@
|
||||
#include "sh.h"
|
||||
#include <ctype.h>
|
||||
|
||||
__RCSID("$MirBSD: expr.c,v 1.6 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: expr.c,v 1.7 2004/10/28 11:53:41 tg Exp $");
|
||||
|
||||
/* The order of these enums is constrained by the order of opinfo[] */
|
||||
enum token {
|
||||
@ -142,10 +142,7 @@ static struct tbl *intvar(Expr_state *es, struct tbl *vp);
|
||||
* parse and evaluate expression
|
||||
*/
|
||||
int
|
||||
evaluate(expr, rval, error_ok)
|
||||
const char *expr;
|
||||
long *rval;
|
||||
int error_ok;
|
||||
evaluate(const char *expr, long int *rval, int error_ok)
|
||||
{
|
||||
struct tbl v;
|
||||
int ret;
|
||||
@ -161,10 +158,7 @@ evaluate(expr, rval, error_ok)
|
||||
* parse and evaluate expression, storing result in vp.
|
||||
*/
|
||||
int
|
||||
v_evaluate(vp, expr, error_ok)
|
||||
struct tbl *vp;
|
||||
const char *expr;
|
||||
volatile int error_ok;
|
||||
v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok)
|
||||
{
|
||||
struct tbl *v;
|
||||
Expr_state curstate;
|
||||
@ -193,12 +187,10 @@ v_evaluate(vp, expr, error_ok)
|
||||
}
|
||||
|
||||
token(es);
|
||||
#if 1 /* ifdef-out to disallow empty expressions to be treated as 0 */
|
||||
if (es->tok == END) {
|
||||
es->tok = LIT;
|
||||
es->val = tempvar();
|
||||
}
|
||||
#endif /* 0 */
|
||||
v = intvar(es, evalexpr(es, MAX_PREC));
|
||||
|
||||
if (es->tok != END)
|
||||
@ -216,10 +208,7 @@ v_evaluate(vp, expr, error_ok)
|
||||
}
|
||||
|
||||
static void
|
||||
evalerr(es, type, str)
|
||||
Expr_state *es;
|
||||
enum error_type type;
|
||||
const char *str;
|
||||
evalerr(Expr_state *es, enum error_type type, const char *str)
|
||||
{
|
||||
char tbuf[2];
|
||||
const char *s;
|
||||
@ -275,9 +264,7 @@ evalerr(es, type, str)
|
||||
}
|
||||
|
||||
static struct tbl *
|
||||
evalexpr(es, prec)
|
||||
Expr_state *es;
|
||||
enum prec prec;
|
||||
evalexpr(Expr_state *es, enum prec prec)
|
||||
{
|
||||
struct tbl *vl, UNINITIALIZED(*vr), *vasn;
|
||||
enum token op;
|
||||
@ -456,8 +443,7 @@ evalexpr(es, prec)
|
||||
}
|
||||
|
||||
static void
|
||||
token(es)
|
||||
Expr_state *es;
|
||||
token(Expr_state *es)
|
||||
{
|
||||
const char *cp;
|
||||
int c;
|
||||
@ -530,11 +516,7 @@ token(es)
|
||||
|
||||
/* Do a ++ or -- operation */
|
||||
static struct tbl *
|
||||
do_ppmm(es, op, vasn, is_prefix)
|
||||
Expr_state *es;
|
||||
enum token op;
|
||||
struct tbl *vasn;
|
||||
bool_t is_prefix;
|
||||
do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool_t is_prefix)
|
||||
{
|
||||
struct tbl *vl;
|
||||
int oval;
|
||||
@ -554,10 +536,7 @@ do_ppmm(es, op, vasn, is_prefix)
|
||||
}
|
||||
|
||||
static void
|
||||
assign_check(es, op, vasn)
|
||||
Expr_state *es;
|
||||
enum token op;
|
||||
struct tbl *vasn;
|
||||
assign_check(Expr_state *es, enum token op, struct tbl *vasn)
|
||||
{
|
||||
if (vasn->name[0] == '\0' && !(vasn->flag & EXPRLVALUE))
|
||||
evalerr(es, ET_LVALUE, opinfo[(int) op].name);
|
||||
@ -566,7 +545,7 @@ assign_check(es, op, vasn)
|
||||
}
|
||||
|
||||
static struct tbl *
|
||||
tempvar()
|
||||
tempvar(void)
|
||||
{
|
||||
struct tbl *vp;
|
||||
|
||||
@ -581,9 +560,7 @@ tempvar()
|
||||
|
||||
/* cast (string) variable to temporary integer variable */
|
||||
static struct tbl *
|
||||
intvar(es, vp)
|
||||
Expr_state *es;
|
||||
struct tbl *vp;
|
||||
intvar(Expr_state *es, struct tbl *vp)
|
||||
{
|
||||
struct tbl *vq;
|
||||
|
||||
|
117
history.c
117
history.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: history.c,v 1.13 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: history.c,v 1.14 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: history.c,v 1.24 2004/08/03 12:44:59 danh Exp $ */
|
||||
|
||||
/*
|
||||
@ -21,7 +21,7 @@
|
||||
#include "sh.h"
|
||||
#include "ksh_stat.h"
|
||||
|
||||
__RCSID("$MirBSD: history.c,v 1.13 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: history.c,v 1.14 2004/10/28 11:53:42 tg Exp $");
|
||||
|
||||
#ifdef HISTORY
|
||||
# ifdef EASY_HISTORY
|
||||
@ -78,8 +78,7 @@ static Source *hist_source;
|
||||
|
||||
|
||||
int
|
||||
c_fc(wp)
|
||||
char **wp;
|
||||
c_fc(char **wp)
|
||||
{
|
||||
struct shf *shf;
|
||||
struct temp UNINITIALIZED(*tf);
|
||||
@ -296,8 +295,7 @@ c_fc(wp)
|
||||
|
||||
/* Save cmd in history, execute cmd (cmd gets trashed) */
|
||||
static int
|
||||
hist_execute(cmd)
|
||||
char *cmd;
|
||||
hist_execute(char *cmd)
|
||||
{
|
||||
Source *sold;
|
||||
int ret;
|
||||
@ -337,11 +335,7 @@ hist_execute(cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
hist_replace(hp, pat, rep, global)
|
||||
char **hp;
|
||||
const char *pat;
|
||||
const char *rep;
|
||||
int global;
|
||||
hist_replace(char **hp, const char *pat, const char *rep, int global)
|
||||
{
|
||||
char *line;
|
||||
|
||||
@ -386,10 +380,7 @@ hist_replace(hp, pat, rep, global)
|
||||
* pattern is a number or string
|
||||
*/
|
||||
static char **
|
||||
hist_get(str, approx, allow_cur)
|
||||
const char *str;
|
||||
int approx;
|
||||
int allow_cur;
|
||||
hist_get(const char *str, int approx, int allow_cur)
|
||||
{
|
||||
char **hp = (char **) 0;
|
||||
int n;
|
||||
@ -430,8 +421,7 @@ hist_get(str, approx, allow_cur)
|
||||
|
||||
/* Return a pointer to the newest command in the history */
|
||||
static char **
|
||||
hist_get_newest(allow_cur)
|
||||
int allow_cur;
|
||||
hist_get_newest(int allow_cur)
|
||||
{
|
||||
if (histptr < history || (!allow_cur && histptr == history)) {
|
||||
bi_errorf("no history (yet)");
|
||||
@ -444,7 +434,7 @@ hist_get_newest(allow_cur)
|
||||
|
||||
/* Return a pointer to the newest command in the history */
|
||||
static char **
|
||||
hist_get_oldest()
|
||||
hist_get_oldest(void)
|
||||
{
|
||||
if (histptr <= history) {
|
||||
bi_errorf("no history (yet)");
|
||||
@ -457,7 +447,7 @@ hist_get_oldest()
|
||||
/* Back up over last histsave */
|
||||
/******************************/
|
||||
static void
|
||||
histbackup()
|
||||
histbackup(void)
|
||||
{
|
||||
static int last_line = -1;
|
||||
|
||||
@ -473,20 +463,19 @@ histbackup()
|
||||
* Return the current position.
|
||||
*/
|
||||
char **
|
||||
histpos()
|
||||
histpos(void)
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
int
|
||||
histN()
|
||||
histN(void)
|
||||
{
|
||||
return curpos;
|
||||
}
|
||||
|
||||
int
|
||||
histnum(n)
|
||||
int n;
|
||||
histnum(int n)
|
||||
{
|
||||
int last = histptr - history;
|
||||
|
||||
@ -507,11 +496,7 @@ histnum(n)
|
||||
* direction.
|
||||
*/
|
||||
int
|
||||
findhist(start, fwd, str, anchored)
|
||||
int start;
|
||||
int fwd;
|
||||
const char *str;
|
||||
int anchored;
|
||||
findhist(int start, int fwd, const char *str, int anchored)
|
||||
{
|
||||
char **hp;
|
||||
int maxhist = histptr - history;
|
||||
@ -535,8 +520,7 @@ findhist(start, fwd, str, anchored)
|
||||
* this means reallocating the dataspace
|
||||
*/
|
||||
void
|
||||
sethistsize(n)
|
||||
int n;
|
||||
sethistsize(int n)
|
||||
{
|
||||
if (n > 0 && n != histsize) {
|
||||
int cursize = histptr - history;
|
||||
@ -560,8 +544,7 @@ sethistsize(n)
|
||||
* maintenance
|
||||
*/
|
||||
void
|
||||
sethistfile(name)
|
||||
const char *name;
|
||||
sethistfile(const char *name)
|
||||
{
|
||||
/* if not started then nothing to do */
|
||||
if (hstarted == 0)
|
||||
@ -600,7 +583,7 @@ sethistfile(name)
|
||||
* initialise the history vector
|
||||
*/
|
||||
void
|
||||
init_histvec()
|
||||
init_histvec(void)
|
||||
{
|
||||
if (history == (char **)NULL) {
|
||||
histsize = HISTORYSIZE;
|
||||
@ -614,10 +597,10 @@ init_histvec()
|
||||
* save command in history
|
||||
*/
|
||||
void
|
||||
histsave(lno, cmd, dowrite)
|
||||
int lno; /* ignored (compatibility with COMPLEX_HISTORY) */
|
||||
const char *cmd;
|
||||
int dowrite; /* ignored (compatibility with COMPLEX_HISTORY) */
|
||||
histsave(int lno, const char *cmd, int dowrite)
|
||||
/* ignored (compatibility with COMPLEX_HISTORY) */
|
||||
|
||||
/* ignored (compatibility with COMPLEX_HISTORY) */
|
||||
{
|
||||
char **hp = histptr;
|
||||
char *cp;
|
||||
@ -641,9 +624,7 @@ histsave(lno, cmd, dowrite)
|
||||
* commands
|
||||
*/
|
||||
void
|
||||
histappend(cmd, nl_separate)
|
||||
const char *cmd;
|
||||
int nl_separate;
|
||||
histappend(const char *cmd, int nl_separate)
|
||||
{
|
||||
int hlen, clen;
|
||||
char *p;
|
||||
@ -669,8 +650,7 @@ histappend(cmd, nl_separate)
|
||||
* to save its history.
|
||||
*/
|
||||
void
|
||||
hist_init(s)
|
||||
Source *s;
|
||||
hist_init(Source *s)
|
||||
{
|
||||
char *f;
|
||||
FILE *fh;
|
||||
@ -683,19 +663,8 @@ hist_init(s)
|
||||
hist_source = s;
|
||||
|
||||
if ((f = str_val(global("HISTFILE"))) == NULL || *f == '\0') {
|
||||
# if 1 /* Don't use history file unless the user asks for it */
|
||||
hname = NULL;
|
||||
return;
|
||||
# else
|
||||
char *home = str_val(global("HOME"));
|
||||
int len;
|
||||
|
||||
if (home == NULL)
|
||||
home = null;
|
||||
f = HISTFILE;
|
||||
hname = alloc(len = strlen(home) + strlen(f) + 2, APERM);
|
||||
shf_snprintf(hname, len, "%s/%s", home, f);
|
||||
# endif
|
||||
} else
|
||||
hname = str_save(f, APERM);
|
||||
|
||||
@ -735,7 +704,7 @@ hist_init(s)
|
||||
*/
|
||||
|
||||
void
|
||||
hist_finish()
|
||||
hist_finish(void)
|
||||
{
|
||||
static int once;
|
||||
FILE *fh;
|
||||
@ -773,10 +742,7 @@ hist_finish()
|
||||
* save command in history
|
||||
*/
|
||||
void
|
||||
histsave(lno, cmd, dowrite)
|
||||
int lno;
|
||||
const char *cmd;
|
||||
int dowrite;
|
||||
histsave(int lno, const char *cmd, int dowrite)
|
||||
{
|
||||
char **hp;
|
||||
char *c, *cp;
|
||||
@ -824,8 +790,7 @@ histsave(lno, cmd, dowrite)
|
||||
# define COMMAND 0xff
|
||||
|
||||
void
|
||||
hist_init(s)
|
||||
Source *s;
|
||||
hist_init(Source *s)
|
||||
{
|
||||
unsigned char *base;
|
||||
int lines;
|
||||
@ -902,9 +867,7 @@ typedef enum state {
|
||||
} State;
|
||||
|
||||
static int
|
||||
hist_count_lines(base, bytes)
|
||||
unsigned char *base;
|
||||
int bytes;
|
||||
hist_count_lines(unsigned char *base, int bytes)
|
||||
{
|
||||
State state = shdr;
|
||||
int lines = 0;
|
||||
@ -937,9 +900,7 @@ hist_count_lines(base, bytes)
|
||||
* Shrink the history file to histsize lines
|
||||
*/
|
||||
static int
|
||||
hist_shrink(oldbase, oldbytes)
|
||||
unsigned char *oldbase;
|
||||
int oldbytes;
|
||||
hist_shrink(unsigned char *oldbase, int oldbytes)
|
||||
{
|
||||
int fd;
|
||||
char nfile[PATH_MAX];
|
||||
@ -991,10 +952,7 @@ hist_shrink(oldbase, oldbytes)
|
||||
* return the pointer and the number of bytes left
|
||||
*/
|
||||
static unsigned char *
|
||||
hist_skip_back(base, bytes, no)
|
||||
unsigned char *base;
|
||||
int *bytes;
|
||||
int no;
|
||||
hist_skip_back(unsigned char *base, int *bytes, int no)
|
||||
{
|
||||
int lines = 0;
|
||||
unsigned char *ep;
|
||||
@ -1020,10 +978,7 @@ hist_skip_back(base, bytes, no)
|
||||
* load the history structure from the stored data
|
||||
*/
|
||||
static void
|
||||
histload(s, base, bytes)
|
||||
Source *s;
|
||||
unsigned char *base;
|
||||
int bytes;
|
||||
histload(Source *s, unsigned char *base, int bytes)
|
||||
{
|
||||
State state;
|
||||
int lno = 0;
|
||||
@ -1073,10 +1028,7 @@ histload(s, base, bytes)
|
||||
* Insert a line into the history at a specified number
|
||||
*/
|
||||
static void
|
||||
histinsert(s, lno, line)
|
||||
Source *s;
|
||||
int lno;
|
||||
unsigned char *line;
|
||||
histinsert(Source *s, int lno, unsigned char *line)
|
||||
{
|
||||
char **hp;
|
||||
|
||||
@ -1096,9 +1048,7 @@ histinsert(s, lno, line)
|
||||
* and we should read those commands to update our history
|
||||
*/
|
||||
static void
|
||||
writehistfile(lno, cmd)
|
||||
int lno;
|
||||
char *cmd;
|
||||
writehistfile(int lno, char *cmd)
|
||||
{
|
||||
int sizenow;
|
||||
unsigned char *base;
|
||||
@ -1154,7 +1104,7 @@ bad:
|
||||
}
|
||||
|
||||
void
|
||||
hist_finish()
|
||||
hist_finish(void)
|
||||
{
|
||||
(void) flock(histfd, LOCK_UN);
|
||||
(void) close(histfd);
|
||||
@ -1165,8 +1115,7 @@ hist_finish()
|
||||
* add magic to the history file
|
||||
*/
|
||||
static int
|
||||
sprinkle(fd)
|
||||
int fd;
|
||||
sprinkle(int fd)
|
||||
{
|
||||
static unsigned char mag[] = { HMAGIC1, HMAGIC2 };
|
||||
|
||||
|
100
io.c
100
io.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: io.c,v 1.6 2004/10/28 11:03:23 tg Exp $ */
|
||||
/** $MirBSD: io.c,v 1.7 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -18,13 +18,7 @@ static int initio_done;
|
||||
|
||||
/* A shell error occurred (eg, syntax error, etc.) */
|
||||
void
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
errorf(const char *fmt, ...)
|
||||
#else
|
||||
errorf(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -43,14 +37,7 @@ errorf(fmt, va_alist)
|
||||
|
||||
/* like errorf(), but no unwind is done */
|
||||
void
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
warningf(int fileline, const char *fmt, ...)
|
||||
#else
|
||||
warningf(fileline, fmt, va_alist)
|
||||
int fileline;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -66,13 +53,7 @@ warningf(fileline, fmt, va_alist)
|
||||
* (also unwinds environments for special builtins).
|
||||
*/
|
||||
void
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
bi_errorf(const char *fmt, ...)
|
||||
#else
|
||||
bi_errorf(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -103,14 +84,7 @@ bi_errorf(fmt, va_alist)
|
||||
|
||||
/* Called when something that shouldn't happen does */
|
||||
void
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
internal_errorf(int jump, const char *fmt, ...)
|
||||
#else
|
||||
internal_errorf(jump, fmt, va_alist)
|
||||
int jump;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -127,8 +101,7 @@ internal_errorf(jump, fmt, va_alist)
|
||||
|
||||
/* used by error reporting functions to print "ksh: .kshrc[25]: " */
|
||||
void
|
||||
error_prefix(fileline)
|
||||
int fileline;
|
||||
error_prefix(int fileline)
|
||||
{
|
||||
/* Avoid foo: foo[2]: ... */
|
||||
if (!fileline || !source || !source->file
|
||||
@ -143,13 +116,7 @@ error_prefix(fileline)
|
||||
|
||||
/* printf to shl_out (stderr) with flush */
|
||||
void
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shellf(const char *fmt, ...)
|
||||
#else
|
||||
shellf(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -163,13 +130,7 @@ shellf(fmt, va_alist)
|
||||
|
||||
/* printf to shl_stdout (stdout) */
|
||||
void
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shprintf(const char *fmt, ...)
|
||||
#else
|
||||
shprintf(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -199,13 +160,7 @@ kshdebug_init_()
|
||||
|
||||
/* print to debugging log */
|
||||
void
|
||||
# ifdef HAVE_PROTOTYPES
|
||||
kshdebug_printf_(const char *fmt, ...)
|
||||
# else
|
||||
kshdebug_printf_(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
# endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -245,8 +200,7 @@ kshdebug_dump_(str, mem, nbytes)
|
||||
|
||||
/* test if we can seek backwards fd (returns 0 or SHF_UNBUF) */
|
||||
int
|
||||
can_seek(fd)
|
||||
int fd;
|
||||
can_seek(int fd)
|
||||
{
|
||||
struct stat statb;
|
||||
|
||||
@ -257,7 +211,7 @@ can_seek(fd)
|
||||
struct shf shf_iob[3];
|
||||
|
||||
void
|
||||
initio()
|
||||
initio(void)
|
||||
{
|
||||
shf_fdopen(1, SHF_WR, shl_stdout); /* force buffer allocation */
|
||||
shf_fdopen(2, SHF_WR, shl_out);
|
||||
@ -268,10 +222,7 @@ initio()
|
||||
|
||||
/* A dup2() with error checking */
|
||||
int
|
||||
ksh_dup2(ofd, nfd, errok)
|
||||
int ofd;
|
||||
int nfd;
|
||||
int errok;
|
||||
ksh_dup2(int ofd, int nfd, int errok)
|
||||
{
|
||||
int ret = dup2(ofd, nfd);
|
||||
|
||||
@ -292,9 +243,7 @@ ksh_dup2(ofd, nfd, errok)
|
||||
* set close-on-exec flag.
|
||||
*/
|
||||
int
|
||||
savefd(fd, noclose)
|
||||
int fd;
|
||||
int noclose;
|
||||
savefd(int fd, int noclose)
|
||||
{
|
||||
int nfd;
|
||||
|
||||
@ -315,8 +264,7 @@ savefd(fd, noclose)
|
||||
}
|
||||
|
||||
void
|
||||
restfd(fd, ofd)
|
||||
int fd, ofd;
|
||||
restfd(int fd, int ofd)
|
||||
{
|
||||
if (fd == 2)
|
||||
shf_flush(&shf_iob[fd]);
|
||||
@ -329,8 +277,7 @@ restfd(fd, ofd)
|
||||
}
|
||||
|
||||
void
|
||||
openpipe(pv)
|
||||
int *pv;
|
||||
openpipe(int *pv)
|
||||
{
|
||||
if (pipe(pv) < 0)
|
||||
errorf("can't create pipe - try again");
|
||||
@ -339,8 +286,7 @@ openpipe(pv)
|
||||
}
|
||||
|
||||
void
|
||||
closepipe(pv)
|
||||
int *pv;
|
||||
closepipe(int *pv)
|
||||
{
|
||||
close(pv[0]);
|
||||
close(pv[1]);
|
||||
@ -350,10 +296,7 @@ closepipe(pv)
|
||||
* a string (the X in 2>&X, read -uX, print -uX) into a file descriptor.
|
||||
*/
|
||||
int
|
||||
check_fd(name, mode, emsgp)
|
||||
char *name;
|
||||
int mode;
|
||||
const char **emsgp;
|
||||
check_fd(char *name, int mode, const char **emsgp)
|
||||
{
|
||||
int fd, fl;
|
||||
|
||||
@ -408,7 +351,7 @@ check_fd(name, mode, emsgp)
|
||||
#ifdef KSH
|
||||
/* Called once from main */
|
||||
void
|
||||
coproc_init()
|
||||
coproc_init(void)
|
||||
{
|
||||
coproc.read = coproc.readw = coproc.write = -1;
|
||||
coproc.njobs = 0;
|
||||
@ -417,8 +360,7 @@ coproc_init()
|
||||
|
||||
/* Called by c_read() when eof is read - close fd if it is the co-process fd */
|
||||
void
|
||||
coproc_read_close(fd)
|
||||
int fd;
|
||||
coproc_read_close(int fd)
|
||||
{
|
||||
if (coproc.read >= 0 && fd == coproc.read) {
|
||||
coproc_readw_close(fd);
|
||||
@ -431,8 +373,7 @@ coproc_read_close(fd)
|
||||
* read pipe, so reads will actually terminate.
|
||||
*/
|
||||
void
|
||||
coproc_readw_close(fd)
|
||||
int fd;
|
||||
coproc_readw_close(int fd)
|
||||
{
|
||||
if (coproc.readw >= 0 && coproc.read >= 0 && fd == coproc.read) {
|
||||
close(coproc.readw);
|
||||
@ -444,8 +385,7 @@ coproc_readw_close(fd)
|
||||
* when co-process input is dup'd
|
||||
*/
|
||||
void
|
||||
coproc_write_close(fd)
|
||||
int fd;
|
||||
coproc_write_close(int fd)
|
||||
{
|
||||
if (coproc.write >= 0 && fd == coproc.write) {
|
||||
close(coproc.write);
|
||||
@ -457,9 +397,7 @@ coproc_write_close(fd)
|
||||
* (Used by check_fd() and by c_read/c_print to deal with -p option).
|
||||
*/
|
||||
int
|
||||
coproc_getfd(mode, emsgp)
|
||||
int mode;
|
||||
const char **emsgp;
|
||||
coproc_getfd(int mode, const char **emsgp)
|
||||
{
|
||||
int fd = (mode & R_OK) ? coproc.read : coproc.write;
|
||||
|
||||
@ -474,8 +412,7 @@ coproc_getfd(mode, emsgp)
|
||||
* Should be called with SIGCHLD blocked.
|
||||
*/
|
||||
void
|
||||
coproc_cleanup(reuse)
|
||||
int reuse;
|
||||
coproc_cleanup(int reuse)
|
||||
{
|
||||
/* This to allow co-processes to share output pipe */
|
||||
if (!reuse || coproc.readw < 0 || coproc.read < 0) {
|
||||
@ -501,10 +438,7 @@ coproc_cleanup(reuse)
|
||||
*/
|
||||
|
||||
struct temp *
|
||||
maketemp(ap, type, tlist)
|
||||
Area *ap;
|
||||
Temp_type type;
|
||||
struct temp **tlist;
|
||||
maketemp(Area *ap, Temp_type type, struct temp **tlist)
|
||||
{
|
||||
#ifndef HAVE_MKSTEMP
|
||||
static unsigned int inc;
|
||||
|
98
jobs.c
98
jobs.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: jobs.c,v 1.7 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: jobs.c,v 1.8 2004/10/28 11:53:42 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: jobs.c,v 1.7 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: jobs.c,v 1.8 2004/10/28 11:53:42 tg Exp $");
|
||||
|
||||
/* Start of system configuration stuff */
|
||||
|
||||
@ -63,16 +63,13 @@ int tcsetpgrp(int fd, pid_t grp);
|
||||
int tcgetpgrp(int fd);
|
||||
|
||||
int
|
||||
tcsetpgrp(fd, grp)
|
||||
int fd;
|
||||
pid_t grp;
|
||||
tcsetpgrp(int fd, pid_t grp)
|
||||
{
|
||||
return ioctl(fd, TIOCSPGRP, &grp);
|
||||
}
|
||||
|
||||
int
|
||||
tcgetpgrp(fd)
|
||||
int fd;
|
||||
tcgetpgrp(int fd)
|
||||
{
|
||||
int r, grp;
|
||||
|
||||
@ -228,8 +225,7 @@ static int kill_job(Job *j, int sig);
|
||||
|
||||
/* initialize job control */
|
||||
void
|
||||
j_init(mflagset)
|
||||
int mflagset;
|
||||
j_init(int mflagset)
|
||||
{
|
||||
child_max = CHILD_MAX; /* so syscon() isn't always being called */
|
||||
|
||||
@ -283,7 +279,7 @@ j_init(mflagset)
|
||||
|
||||
/* job cleanup before shell exit */
|
||||
void
|
||||
j_exit()
|
||||
j_exit(void)
|
||||
{
|
||||
/* kill stopped, and possibly running, jobs */
|
||||
Job *j;
|
||||
@ -340,7 +336,7 @@ j_exit()
|
||||
#ifdef JOBS
|
||||
/* turn job control on or off according to Flag(FMONITOR) */
|
||||
void
|
||||
j_change()
|
||||
j_change(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -435,10 +431,10 @@ j_change()
|
||||
|
||||
/* execute tree in child subprocess */
|
||||
int
|
||||
exchild(t, flags, close_fd)
|
||||
struct op *t;
|
||||
int flags;
|
||||
int close_fd; /* used if XPCLOSE or XCCLOSE */
|
||||
exchild(struct op *t, int flags, int close_fd)
|
||||
|
||||
|
||||
/* used if XPCLOSE or XCCLOSE */
|
||||
{
|
||||
static Proc *last_proc; /* for pipelines */
|
||||
|
||||
@ -697,7 +693,7 @@ exchild(t, flags, close_fd)
|
||||
|
||||
/* start the last job: only used for `command` jobs */
|
||||
void
|
||||
startlast()
|
||||
startlast(void)
|
||||
{
|
||||
#ifdef JOB_SIGS
|
||||
sigset_t omask;
|
||||
@ -717,7 +713,7 @@ startlast()
|
||||
|
||||
/* wait for last job: only used for `command` jobs */
|
||||
int
|
||||
waitlast()
|
||||
waitlast(void)
|
||||
{
|
||||
int rv;
|
||||
Job *j;
|
||||
@ -750,9 +746,7 @@ waitlast()
|
||||
|
||||
/* wait for child, interruptable. */
|
||||
int
|
||||
waitfor(cp, sigp)
|
||||
const char *cp;
|
||||
int *sigp;
|
||||
waitfor(const char *cp, int *sigp)
|
||||
{
|
||||
int rv;
|
||||
Job *j;
|
||||
@ -813,9 +807,7 @@ waitfor(cp, sigp)
|
||||
|
||||
/* kill (built-in) a job */
|
||||
int
|
||||
j_kill(cp, sig)
|
||||
const char *cp;
|
||||
int sig;
|
||||
j_kill(const char *cp, int sig)
|
||||
{
|
||||
Job *j;
|
||||
int rv = 0;
|
||||
@ -860,9 +852,7 @@ j_kill(cp, sig)
|
||||
#ifdef JOBS
|
||||
/* fg and bg built-ins: called only if Flag(FMONITOR) set */
|
||||
int
|
||||
j_resume(cp, bg)
|
||||
const char *cp;
|
||||
int bg;
|
||||
j_resume(const char *cp, int bg)
|
||||
{
|
||||
Job *j;
|
||||
Proc *p;
|
||||
@ -968,7 +958,7 @@ j_resume(cp, bg)
|
||||
|
||||
/* are there any running or stopped jobs ? */
|
||||
int
|
||||
j_stopped_running()
|
||||
j_stopped_running(void)
|
||||
{
|
||||
Job *j;
|
||||
int which = 0;
|
||||
@ -995,10 +985,10 @@ j_stopped_running()
|
||||
|
||||
/* list jobs for jobs built-in */
|
||||
int
|
||||
j_jobs(cp, slp, nflag)
|
||||
const char *cp;
|
||||
int slp; /* 0: short, 1: long, 2: pgrp */
|
||||
int nflag;
|
||||
j_jobs(const char *cp, int slp, int nflag)
|
||||
|
||||
/* 0: short, 1: long, 2: pgrp */
|
||||
|
||||
{
|
||||
Job *j, *tmp;
|
||||
int how;
|
||||
@ -1051,7 +1041,7 @@ j_jobs(cp, slp, nflag)
|
||||
|
||||
/* list jobs for top-level notification */
|
||||
void
|
||||
j_notify()
|
||||
j_notify(void)
|
||||
{
|
||||
Job *j, *tmp;
|
||||
#ifdef JOB_SIGS
|
||||
@ -1083,7 +1073,7 @@ j_notify()
|
||||
|
||||
/* Return pid of last process in last asynchronous job */
|
||||
pid_t
|
||||
j_async()
|
||||
j_async(void)
|
||||
{
|
||||
#ifdef JOB_SIGS
|
||||
sigset_t omask;
|
||||
@ -1106,8 +1096,7 @@ j_async()
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static void
|
||||
j_set_async(j)
|
||||
Job *j;
|
||||
j_set_async(Job *j)
|
||||
{
|
||||
Job *jl, *oldest;
|
||||
|
||||
@ -1142,8 +1131,7 @@ j_set_async(j)
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static void
|
||||
j_startjob(j)
|
||||
Job *j;
|
||||
j_startjob(Job *j)
|
||||
{
|
||||
Proc *p;
|
||||
|
||||
@ -1173,10 +1161,10 @@ j_startjob(j)
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static int
|
||||
j_waitj(j, flags, where)
|
||||
Job *j;
|
||||
int flags; /* see JW_* */
|
||||
const char *where;
|
||||
j_waitj(Job *j, int flags, const char *where)
|
||||
|
||||
/* see JW_* */
|
||||
|
||||
{
|
||||
int rv;
|
||||
|
||||
@ -1397,8 +1385,7 @@ found:
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static void
|
||||
check_job(j)
|
||||
Job *j;
|
||||
check_job(Job *j)
|
||||
{
|
||||
int jstate;
|
||||
Proc *p;
|
||||
@ -1506,10 +1493,7 @@ check_job(j)
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static void
|
||||
j_print(j, how, shf)
|
||||
Job *j;
|
||||
int how;
|
||||
struct shf *shf;
|
||||
j_print(Job *j, int how, struct shf *shf)
|
||||
{
|
||||
Proc *p;
|
||||
int state;
|
||||
@ -1618,9 +1602,7 @@ j_print(j, how, shf)
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static Job *
|
||||
j_lookup(cp, ecodep)
|
||||
const char *cp;
|
||||
int *ecodep;
|
||||
j_lookup(const char *cp, int *ecodep)
|
||||
{
|
||||
Job *j, *last_match;
|
||||
Proc *p;
|
||||
@ -1713,7 +1695,7 @@ static Proc *free_procs;
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static Job *
|
||||
new_job()
|
||||
new_job(void)
|
||||
{
|
||||
int i;
|
||||
Job *newj, *j;
|
||||
@ -1741,7 +1723,7 @@ new_job()
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static Proc *
|
||||
new_proc()
|
||||
new_proc(void)
|
||||
{
|
||||
Proc *p;
|
||||
|
||||
@ -1760,9 +1742,7 @@ new_proc()
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static void
|
||||
remove_job(j, where)
|
||||
Job *j;
|
||||
const char *where;
|
||||
remove_job(Job *j, const char *where)
|
||||
{
|
||||
Proc *p, *tmp;
|
||||
Job **prev, *curr;
|
||||
@ -1802,9 +1782,7 @@ remove_job(j, where)
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static void
|
||||
put_job(j, where)
|
||||
Job *j;
|
||||
int where;
|
||||
put_job(Job *j, int where)
|
||||
{
|
||||
Job **prev, *curr;
|
||||
|
||||
@ -1839,9 +1817,7 @@ put_job(j, where)
|
||||
* If jobs are compiled in then this routine expects sigchld to be blocked.
|
||||
*/
|
||||
static int
|
||||
kill_job(j, sig)
|
||||
Job *j;
|
||||
int sig;
|
||||
kill_job(Job *j, int sig)
|
||||
{
|
||||
Proc *p;
|
||||
int rval = 0;
|
||||
|
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: ksh_dir.h,v 1.4 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: ksh_dir.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: ksh_dir.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */
|
||||
|
||||
#ifndef KSH_DIR_H
|
||||
#define KSH_DIR_H
|
||||
|
||||
/* Wrapper around the ugly dir includes/ifdefs */
|
||||
|
||||
#if defined(HAVE_DIRENT_H)
|
||||
@ -25,3 +28,5 @@ extern DIR *ksh_opendir(const char *d);
|
||||
#else /* OPENDIR_DOES_NONDIR */
|
||||
# define ksh_opendir(d) opendir(d)
|
||||
#endif /* OPENDIR_DOES_NONDIR */
|
||||
|
||||
#endif /* ndef KSH_DIR_H */
|
||||
|
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: ksh_limval.h,v 1.3 2004/09/21 11:57:10 tg Exp $ */
|
||||
/** $MirBSD: ksh_limval.h,v 1.4 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: ksh_limval.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */
|
||||
|
||||
#ifndef KSH_LIMVAL_H
|
||||
#define KSH_LIMVAL_H
|
||||
|
||||
/* Wrapper around the values.h/limits.h includes/ifdefs */
|
||||
|
||||
#ifdef HAVE_VALUES_H
|
||||
@ -23,3 +26,5 @@
|
||||
#ifndef BITS
|
||||
# define BITS(t) (BITSPERBYTE * sizeof(t))
|
||||
#endif
|
||||
|
||||
#endif /* ndef KSH_LIMVAL_H */
|
||||
|
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: ksh_stat.h,v 1.4 2004/09/21 11:57:11 tg Exp $ */
|
||||
/** $MirBSD: ksh_stat.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: ksh_stat.h,v 1.3 1996/10/01 02:05:39 downsj Exp $ */
|
||||
|
||||
#ifndef KSH_STAT_H
|
||||
#define KSH_STAT_H
|
||||
|
||||
/* Wrapper around the ugly sys/stat includes/ifdefs */
|
||||
|
||||
/* assumes <sys/types.h> already included */
|
||||
@ -64,3 +67,5 @@
|
||||
#ifndef S_IXOTH
|
||||
# define S_IXOTH 00001 /* user execute bit */
|
||||
#endif /* S_IXOTH */
|
||||
|
||||
#endif /* ndef KSH_STAT_H */
|
||||
|
@ -1,8 +1,8 @@
|
||||
/** $MirBSD: ksh_time.h,v 1.4 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: ksh_time.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: ksh_time.h,v 1.2 1996/10/01 02:05:40 downsj Exp $ */
|
||||
|
||||
#ifndef KSH_TIME_H
|
||||
# define KSH_TIME_H
|
||||
#define KSH_TIME_H
|
||||
|
||||
/* Wrapper around the ugly time.h,sys/time.h includes/ifdefs */
|
||||
|
||||
@ -24,4 +24,5 @@ extern time_t time(time_t *);
|
||||
#ifndef CLK_TCK
|
||||
# define CLK_TCK 60 /* 60HZ */
|
||||
#endif
|
||||
|
||||
#endif /* KSH_TIME_H */
|
||||
|
@ -1,8 +1,8 @@
|
||||
/** $MirBSD: ksh_times.h,v 1.4 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: ksh_times.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: ksh_times.h,v 1.2 1996/10/01 02:05:41 downsj Exp $ */
|
||||
|
||||
#ifndef KSH_TIMES_H
|
||||
# define KSH_TIMES_H
|
||||
#define KSH_TIMES_H
|
||||
|
||||
/* Needed for clock_t on some systems (ie, NeXT in non-posix mode) */
|
||||
#include "ksh_time.h"
|
||||
@ -18,4 +18,5 @@ extern clock_t ksh_times(struct tms *);
|
||||
#ifdef HAVE_TIMES
|
||||
extern clock_t times(struct tms *);
|
||||
#endif /* HAVE_TIMES */
|
||||
|
||||
#endif /* KSH_TIMES_H */
|
||||
|
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: ksh_wait.h,v 1.3 2004/09/21 11:57:12 tg Exp $ */
|
||||
/** $MirBSD: ksh_wait.h,v 1.4 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: ksh_wait.h,v 1.3 1997/06/19 13:58:43 kstailey Exp $ */
|
||||
|
||||
#ifndef KSH_WAIT_H
|
||||
#define KSH_WAIT_H
|
||||
|
||||
/* Wrapper around the ugly sys/wait includes/ifdefs */
|
||||
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
@ -50,3 +53,5 @@ typedef int WAIT_T;
|
||||
#else /* !HAVE_WAITPID && HAVE_WAIT3 */
|
||||
# define ksh_waitpid(p, s, o) waitpid((p), (s), (o))
|
||||
#endif /* !HAVE_WAITPID && HAVE_WAIT3 */
|
||||
|
||||
#endif /* ndef KSH_WAIT_H */
|
||||
|
87
lex.c
87
lex.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: lex.c,v 1.6 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: lex.c,v 1.7 2004/10/28 11:53:42 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: lex.c,v 1.6 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: lex.c,v 1.7 2004/10/28 11:53:42 tg Exp $");
|
||||
|
||||
/* Structure to keep track of the lexing state and the various pieces of info
|
||||
* needed for each particular state.
|
||||
@ -99,8 +99,7 @@ static int ignore_backslash_newline;
|
||||
*/
|
||||
|
||||
int
|
||||
yylex(cf)
|
||||
int cf;
|
||||
yylex(int cf)
|
||||
{
|
||||
Lex_state states[STATE_BSIZE], *statep;
|
||||
State_info state_info;
|
||||
@ -771,7 +770,7 @@ Done:
|
||||
}
|
||||
|
||||
static void
|
||||
gethere()
|
||||
gethere(void)
|
||||
{
|
||||
struct ioword **p;
|
||||
|
||||
@ -785,8 +784,7 @@ gethere()
|
||||
*/
|
||||
|
||||
static void
|
||||
readhere(iop)
|
||||
struct ioword *iop;
|
||||
readhere(struct ioword *iop)
|
||||
{
|
||||
int c;
|
||||
char *volatile eof;
|
||||
@ -844,13 +842,7 @@ readhere(iop)
|
||||
}
|
||||
|
||||
void
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
yyerror(const char *fmt, ...)
|
||||
#else
|
||||
yyerror(fmt, va_alist)
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -871,9 +863,7 @@ yyerror(fmt, va_alist)
|
||||
*/
|
||||
|
||||
Source *
|
||||
pushs(type, areap)
|
||||
int type;
|
||||
Area *areap;
|
||||
pushs(int type, Area *areap)
|
||||
{
|
||||
Source *s;
|
||||
|
||||
@ -896,7 +886,7 @@ pushs(type, areap)
|
||||
}
|
||||
|
||||
static int
|
||||
getsc__()
|
||||
getsc__(void)
|
||||
{
|
||||
Source *s = source;
|
||||
int c;
|
||||
@ -997,8 +987,7 @@ getsc__()
|
||||
}
|
||||
|
||||
static void
|
||||
getsc_line(s)
|
||||
Source *s;
|
||||
getsc_line(Source *s)
|
||||
{
|
||||
char *xp = Xstring(s->xs, xp);
|
||||
int interactive = Flag(FTALKING) && s->type == SSTDIN;
|
||||
@ -1110,9 +1099,7 @@ getsc_line(s)
|
||||
}
|
||||
|
||||
void
|
||||
set_prompt(to, s)
|
||||
int to;
|
||||
Source *s;
|
||||
set_prompt(int to, Source *s)
|
||||
{
|
||||
cur_prompt = to;
|
||||
|
||||
@ -1168,44 +1155,8 @@ set_prompt(to, s)
|
||||
|
||||
/* See also related routine, promptlen() in edit.c */
|
||||
void
|
||||
pprompt(cp, ntruncate)
|
||||
const char *cp;
|
||||
int ntruncate;
|
||||
pprompt(const char *cp, int ntruncate)
|
||||
{
|
||||
#if 0
|
||||
char nbuf[32];
|
||||
int c;
|
||||
|
||||
while (*cp != 0) {
|
||||
if (*cp != '!')
|
||||
c = *cp++;
|
||||
else if (*++cp == '!')
|
||||
c = *cp++;
|
||||
else {
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
shf_snprintf(p = nbuf, sizeof(nbuf), "%d",
|
||||
source->line + 1);
|
||||
len = strlen(nbuf);
|
||||
if (ntruncate) {
|
||||
if (ntruncate >= len) {
|
||||
ntruncate -= len;
|
||||
continue;
|
||||
}
|
||||
p += ntruncate;
|
||||
len -= ntruncate;
|
||||
ntruncate = 0;
|
||||
}
|
||||
shf_write(p, len, shl_out);
|
||||
continue;
|
||||
}
|
||||
if (ntruncate)
|
||||
--ntruncate;
|
||||
else
|
||||
shf_putc(c, shl_out);
|
||||
}
|
||||
#endif /* 0 */
|
||||
shf_puts(cp + ntruncate, shl_out);
|
||||
shf_flush(shl_out);
|
||||
}
|
||||
@ -1214,9 +1165,7 @@ pprompt(cp, ntruncate)
|
||||
* the :[-+?=#%] or close-brace.
|
||||
*/
|
||||
static char *
|
||||
get_brace_var(wsp, wp)
|
||||
XString *wsp;
|
||||
char *wp;
|
||||
get_brace_var(XString *wsp, char *wp)
|
||||
{
|
||||
enum parse_state {
|
||||
PS_INITIAL, PS_SAW_HASH, PS_IDENT,
|
||||
@ -1291,8 +1240,7 @@ get_brace_var(wsp, wp)
|
||||
* (Returned string double null terminated)
|
||||
*/
|
||||
static int
|
||||
arraysub(strp)
|
||||
char **strp;
|
||||
arraysub(char **strp)
|
||||
{
|
||||
XString ws;
|
||||
char *wp;
|
||||
@ -1319,8 +1267,7 @@ arraysub(strp)
|
||||
|
||||
/* Unget a char: handles case when we are already at the start of the buffer */
|
||||
static const char *
|
||||
ungetsc(c)
|
||||
int c;
|
||||
ungetsc(int c)
|
||||
{
|
||||
if (backslash_skip)
|
||||
backslash_skip--;
|
||||
@ -1372,9 +1319,7 @@ getsc_bn(void)
|
||||
}
|
||||
|
||||
static Lex_state *
|
||||
push_state_(si, old_end)
|
||||
State_info *si;
|
||||
Lex_state *old_end;
|
||||
push_state_(State_info *si, Lex_state *old_end)
|
||||
{
|
||||
Lex_state *new = alloc(sizeof(Lex_state) * STATE_BSIZE, ATEMP);
|
||||
|
||||
@ -1385,9 +1330,7 @@ push_state_(si, old_end)
|
||||
}
|
||||
|
||||
static Lex_state *
|
||||
pop_state_(si, old_end)
|
||||
State_info *si;
|
||||
Lex_state *old_end;
|
||||
pop_state_(State_info *si, Lex_state *old_end)
|
||||
{
|
||||
Lex_state *old_base = si->base;
|
||||
|
||||
|
7
lex.h
7
lex.h
@ -1,7 +1,10 @@
|
||||
/** $MirBSD: lex.h,v 1.3 2004/09/21 11:57:13 tg Exp $ */
|
||||
/** $MirBSD: lex.h,v 1.4 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: lex.h,v 1.7 2003/02/28 09:45:09 jmc Exp $ */
|
||||
/* $From: lex.h,v 1.4 1994/05/31 13:34:34 michael Exp $ */
|
||||
|
||||
#ifndef LEX_H
|
||||
#define LEX_H
|
||||
|
||||
/*
|
||||
* Source input, lexer and parser
|
||||
*/
|
||||
@ -130,3 +133,5 @@ EXTERN char **history; /* saved commands */
|
||||
EXTERN char **histptr; /* last history item */
|
||||
EXTERN int histsize; /* history size */
|
||||
#endif /* HISTORY */
|
||||
|
||||
#endif /* ndef LEX_H */
|
||||
|
27
mail.c
27
mail.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: mail.c,v 1.5 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: mail.c,v 1.6 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: mail.c,v 1.9 1999/06/15 01:18:35 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -13,7 +13,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include "ksh_time.h"
|
||||
|
||||
__RCSID("$MirBSD: mail.c,v 1.5 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: mail.c,v 1.6 2004/10/28 11:53:42 tg Exp $");
|
||||
|
||||
#define MBMESSAGE "you have mail in $_"
|
||||
|
||||
@ -40,14 +40,14 @@ static mbox_t * mballoc(char *p, char *m); /* allocate a new mbox */
|
||||
static void mprintit(mbox_t *mbp);
|
||||
|
||||
void
|
||||
mcheck()
|
||||
mcheck(void)
|
||||
{
|
||||
mbox_t *mbp;
|
||||
time_t now;
|
||||
struct tbl *vp;
|
||||
struct stat stbuf;
|
||||
|
||||
now = time((time_t *) 0);
|
||||
now = time(NULL);
|
||||
if (mlastchkd == 0)
|
||||
mlastchkd = now;
|
||||
if (now - mlastchkd >= mailcheck_interval) {
|
||||
@ -84,15 +84,13 @@ mcheck()
|
||||
}
|
||||
|
||||
void
|
||||
mcset(interval)
|
||||
long interval;
|
||||
mcset(long int interval)
|
||||
{
|
||||
mailcheck_interval = interval;
|
||||
}
|
||||
|
||||
void
|
||||
mbset(p)
|
||||
char *p;
|
||||
mbset(char *p)
|
||||
{
|
||||
struct stat stbuf;
|
||||
|
||||
@ -110,8 +108,7 @@ mbset(p)
|
||||
}
|
||||
|
||||
void
|
||||
mpset(mptoparse)
|
||||
char *mptoparse;
|
||||
mpset(char *mptoparse)
|
||||
{
|
||||
mbox_t *mbp;
|
||||
char *mpath, *mmsg, *mval;
|
||||
@ -150,8 +147,7 @@ mpset(mptoparse)
|
||||
}
|
||||
|
||||
static void
|
||||
munset(mlist)
|
||||
mbox_t *mlist;
|
||||
munset(mbox_t *mlist)
|
||||
{
|
||||
mbox_t *mbp;
|
||||
|
||||
@ -165,9 +161,7 @@ mbox_t *mlist;
|
||||
}
|
||||
|
||||
static mbox_t *
|
||||
mballoc(p, m)
|
||||
char *p;
|
||||
char *m;
|
||||
mballoc(char *p, char *m)
|
||||
{
|
||||
struct stat stbuf;
|
||||
mbox_t *mbp;
|
||||
@ -184,8 +178,7 @@ mballoc(p, m)
|
||||
}
|
||||
|
||||
static void
|
||||
mprintit( mbp )
|
||||
mbox_t *mbp;
|
||||
mprintit(mbox_t *mbp)
|
||||
{
|
||||
struct tbl *vp;
|
||||
|
||||
|
42
main.c
42
main.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: main.c,v 1.11 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: main.c,v 1.12 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -11,7 +11,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include "ksh_time.h"
|
||||
|
||||
__RCSID("$MirBSD: main.c,v 1.11 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: main.c,v 1.12 2004/10/28 11:53:42 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -69,9 +69,6 @@ static const char *const initcoms [] = {
|
||||
#ifdef KSH
|
||||
/* Aliases that are builtin commands in at&t */
|
||||
"login=exec login",
|
||||
#ifndef __OpenBSD__
|
||||
"newgrp=exec newgrp",
|
||||
#endif /* __OpenBSD__ */
|
||||
#endif /* KSH */
|
||||
NULL,
|
||||
/* this is what at&t ksh seems to track, with the addition of emacs */
|
||||
@ -454,11 +451,7 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
int
|
||||
include(name, argc, argv, intr_ok)
|
||||
const char *name;
|
||||
int argc;
|
||||
char **argv;
|
||||
int intr_ok;
|
||||
include(const char *name, int argc, char **argv, int intr_ok)
|
||||
{
|
||||
Source *volatile s = NULL;
|
||||
struct shf *shf;
|
||||
@ -526,8 +519,7 @@ include(name, argc, argv, intr_ok)
|
||||
}
|
||||
|
||||
int
|
||||
command(comm)
|
||||
const char *comm;
|
||||
command(const char *comm)
|
||||
{
|
||||
Source *s;
|
||||
|
||||
@ -540,9 +532,9 @@ command(comm)
|
||||
* run the commands from the input source, returning status.
|
||||
*/
|
||||
int
|
||||
shell(s, toplevel)
|
||||
Source *volatile s; /* input source */
|
||||
int volatile toplevel;
|
||||
shell(Source *volatile s, volatile int toplevel)
|
||||
/* input source */
|
||||
|
||||
{
|
||||
struct op *t;
|
||||
volatile int wastty = s->flags & SF_TTY;
|
||||
@ -651,8 +643,7 @@ shell(s, toplevel)
|
||||
|
||||
/* return to closest error handler or shell(), exit if none found */
|
||||
void
|
||||
unwind(i)
|
||||
int i;
|
||||
unwind(int i)
|
||||
{
|
||||
/* ordering for EXIT vs ERR is a bit odd (this is what at&t ksh does) */
|
||||
if (i == LEXIT || (Flag(FERREXIT) && (i == LERROR || i == LINTR)
|
||||
@ -686,8 +677,7 @@ unwind(i)
|
||||
}
|
||||
|
||||
void
|
||||
newenv(type)
|
||||
int type;
|
||||
newenv(int type)
|
||||
{
|
||||
struct env *ep;
|
||||
|
||||
@ -703,7 +693,7 @@ newenv(type)
|
||||
}
|
||||
|
||||
void
|
||||
quitenv()
|
||||
quitenv(void)
|
||||
{
|
||||
struct env *ep = e;
|
||||
int fd;
|
||||
@ -756,7 +746,7 @@ quitenv()
|
||||
|
||||
/* Called after a fork to cleanup stuff left over from parents environment */
|
||||
void
|
||||
cleanup_parents_env()
|
||||
cleanup_parents_env(void)
|
||||
{
|
||||
struct env *ep;
|
||||
int fd;
|
||||
@ -781,7 +771,7 @@ cleanup_parents_env()
|
||||
|
||||
/* Called just before an execve cleanup stuff temporary files */
|
||||
void
|
||||
cleanup_proc_env()
|
||||
cleanup_proc_env(void)
|
||||
{
|
||||
struct env *ep;
|
||||
|
||||
@ -791,7 +781,7 @@ cleanup_proc_env()
|
||||
|
||||
/* remove temp files and free ATEMP Area */
|
||||
static void
|
||||
reclaim()
|
||||
reclaim(void)
|
||||
{
|
||||
remove_temps(e->temps);
|
||||
e->temps = NULL;
|
||||
@ -799,8 +789,7 @@ reclaim()
|
||||
}
|
||||
|
||||
static void
|
||||
remove_temps(tp)
|
||||
struct temp *tp;
|
||||
remove_temps(struct temp *tp)
|
||||
{
|
||||
#ifdef OS2
|
||||
static struct temp *delayed_remove;
|
||||
@ -845,8 +834,7 @@ remove_temps(tp)
|
||||
|
||||
/* Returns true if name refers to a restricted shell */
|
||||
static int
|
||||
is_restricted(name)
|
||||
char *name;
|
||||
is_restricted(char *name)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
143
misc.c
143
misc.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: misc.c,v 1.11 2004/10/28 11:11:18 tg Exp $ */
|
||||
/** $MirBSD: misc.c,v 1.12 2004/10/28 11:53:42 tg Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -11,7 +11,7 @@
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirBSD: misc.c,v 1.11 2004/10/28 11:11:18 tg Exp $");
|
||||
__RCSID("$MirBSD: misc.c,v 1.12 2004/10/28 11:53:42 tg Exp $");
|
||||
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX 0xFF
|
||||
@ -28,9 +28,7 @@ static const unsigned char *cclass(const unsigned char *p, int sub);
|
||||
* Fast character classes
|
||||
*/
|
||||
void
|
||||
setctypes(s, t)
|
||||
const char *s;
|
||||
int t;
|
||||
setctypes(const char *s, int t)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -44,7 +42,7 @@ setctypes(s, t)
|
||||
}
|
||||
|
||||
void
|
||||
initctypes()
|
||||
initctypes(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -65,9 +63,7 @@ initctypes()
|
||||
/* convert unsigned long to base N string */
|
||||
|
||||
char *
|
||||
ulton(n, base)
|
||||
unsigned long n;
|
||||
int base;
|
||||
ulton(long unsigned int n, int base)
|
||||
{
|
||||
char *p;
|
||||
static char buf [20];
|
||||
@ -82,9 +78,7 @@ ulton(n, base)
|
||||
}
|
||||
|
||||
char *
|
||||
str_save(s, ap)
|
||||
const char *s;
|
||||
Area *ap;
|
||||
str_save(const char *s, Area *ap)
|
||||
{
|
||||
size_t len;
|
||||
char *p;
|
||||
@ -102,10 +96,7 @@ str_save(s, ap)
|
||||
* (unless n < 0).
|
||||
*/
|
||||
char *
|
||||
str_nsave(s, n, ap)
|
||||
const char *s;
|
||||
int n;
|
||||
Area *ap;
|
||||
str_nsave(const char *s, int n, Area *ap)
|
||||
{
|
||||
char *ns;
|
||||
|
||||
@ -118,10 +109,7 @@ str_nsave(s, n, ap)
|
||||
|
||||
/* called from expand.h:XcheckN() to grow buffer */
|
||||
char *
|
||||
Xcheck_grow_(xsp, xp, more)
|
||||
XString *xsp;
|
||||
char *xp;
|
||||
size_t more;
|
||||
Xcheck_grow_(XString *xsp, char *xp, size_t more)
|
||||
{
|
||||
char *old_beg = xsp->beg;
|
||||
|
||||
@ -195,8 +183,7 @@ const struct option options[] = {
|
||||
* translate -o option into F* constant (also used for test -o option)
|
||||
*/
|
||||
int
|
||||
option(n)
|
||||
const char *n;
|
||||
option(const char *n)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -220,11 +207,7 @@ static void printoptions(int verbose);
|
||||
|
||||
/* format a single select menu item */
|
||||
static char *
|
||||
options_fmt_entry(arg, i, buf, buflen)
|
||||
void *arg;
|
||||
int i;
|
||||
char *buf;
|
||||
int buflen;
|
||||
options_fmt_entry(void *arg, int i, char *buf, int buflen)
|
||||
{
|
||||
struct options_info *oi = (struct options_info *) arg;
|
||||
|
||||
@ -235,8 +218,7 @@ options_fmt_entry(arg, i, buf, buflen)
|
||||
}
|
||||
|
||||
static void
|
||||
printoptions(verbose)
|
||||
int verbose;
|
||||
printoptions(int verbose)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@ -268,7 +250,7 @@ printoptions(verbose)
|
||||
}
|
||||
|
||||
char *
|
||||
getoptions()
|
||||
getoptions(void)
|
||||
{
|
||||
unsigned i;
|
||||
char m[(int) FNFLAGS + 1];
|
||||
@ -283,10 +265,10 @@ getoptions()
|
||||
|
||||
/* change a Flag(*) value; takes care of special actions */
|
||||
void
|
||||
change_flag(f, what, newval)
|
||||
enum sh_flag f; /* flag to change */
|
||||
int what; /* what is changing the flag (command line vs set) */
|
||||
int newval;
|
||||
change_flag(enum sh_flag f, int what, int newval)
|
||||
/* flag to change */
|
||||
/* what is changing the flag (command line vs set) */
|
||||
|
||||
{
|
||||
int oldval;
|
||||
|
||||
@ -346,10 +328,10 @@ change_flag(f, what, newval)
|
||||
* non-option arguments, -1 if there is an error.
|
||||
*/
|
||||
int
|
||||
parse_args(argv, what, setargsp)
|
||||
char **argv;
|
||||
int what; /* OF_CMDLINE or OF_SET */
|
||||
int *setargsp;
|
||||
parse_args(char **argv, int what, int *setargsp)
|
||||
|
||||
/* OF_CMDLINE or OF_SET */
|
||||
|
||||
{
|
||||
static char cmd_opts[NELEM(options) + 3]; /* o:\0 */
|
||||
static char set_opts[NELEM(options) + 5]; /* Ao;s\0 */
|
||||
@ -487,9 +469,7 @@ parse_args(argv, what, setargsp)
|
||||
|
||||
/* parse a decimal number: returns 0 if string isn't a number, 1 otherwise */
|
||||
int
|
||||
getn(as, ai)
|
||||
const char *as;
|
||||
int *ai;
|
||||
getn(const char *as, int *ai)
|
||||
{
|
||||
char *p;
|
||||
long n;
|
||||
@ -505,9 +485,7 @@ getn(as, ai)
|
||||
|
||||
/* getn() that prints error */
|
||||
int
|
||||
bi_getn(as, ai)
|
||||
const char *as;
|
||||
int *ai;
|
||||
bi_getn(const char *as, int *ai)
|
||||
{
|
||||
int rv = getn(as, ai);
|
||||
|
||||
@ -527,9 +505,7 @@ bi_getn(as, ai)
|
||||
*/
|
||||
|
||||
int
|
||||
gmatch(s, p, isfile)
|
||||
const char *s, *p;
|
||||
int isfile;
|
||||
gmatch(const char *s, const char *p, int isfile)
|
||||
{
|
||||
const char *se, *pe;
|
||||
|
||||
@ -570,8 +546,7 @@ gmatch(s, p, isfile)
|
||||
- return ?
|
||||
*/
|
||||
int
|
||||
has_globbing(xp, xpe)
|
||||
const char *xp, *xpe;
|
||||
has_globbing(const char *xp, const char *xpe)
|
||||
{
|
||||
const unsigned char *p = (const unsigned char *) xp;
|
||||
const unsigned char *pe = (const unsigned char *) xpe;
|
||||
@ -625,10 +600,7 @@ has_globbing(xp, xpe)
|
||||
|
||||
/* Function must return either 0 or 1 (assumed by code for 0x80|'!') */
|
||||
static int
|
||||
do_gmatch(s, se, p, pe, isfile)
|
||||
const unsigned char *s, *p;
|
||||
const unsigned char *se, *pe;
|
||||
int isfile;
|
||||
do_gmatch(const unsigned char *s, const unsigned char *se, const unsigned char *p, const unsigned char *pe, int isfile)
|
||||
{
|
||||
int sc, pc;
|
||||
const unsigned char *prest, *psub, *pnext;
|
||||
@ -760,9 +732,7 @@ do_gmatch(s, se, p, pe, isfile)
|
||||
}
|
||||
|
||||
static const unsigned char *
|
||||
cclass(p, sub)
|
||||
const unsigned char *p;
|
||||
int sub;
|
||||
cclass(const unsigned char *p, int sub)
|
||||
{
|
||||
int c, d, not, found = 0;
|
||||
const unsigned char *orig_p = p;
|
||||
@ -807,10 +777,7 @@ cclass(p, sub)
|
||||
|
||||
/* Look for next ) or | (if match_sep) in *(foo|bar) pattern */
|
||||
const unsigned char *
|
||||
pat_scan(p, pe, match_sep)
|
||||
const unsigned char *p;
|
||||
const unsigned char *pe;
|
||||
int match_sep;
|
||||
pat_scan(const unsigned char *p, const unsigned char *pe, int match_sep)
|
||||
{
|
||||
int nest = 0;
|
||||
|
||||
@ -835,10 +802,10 @@ pat_scan(p, pe, match_sep)
|
||||
static void qsort1(void **base, void **lim, int (*f)(void *, void *));
|
||||
|
||||
void
|
||||
qsortp(base, n, f)
|
||||
void **base; /* base address */
|
||||
size_t n; /* elements */
|
||||
int (*f)(void *, void *); /* compare function */
|
||||
qsortp(void **base, size_t n, int (*f) (void *, void *))
|
||||
/* base address */
|
||||
/* elements */
|
||||
/* compare function */
|
||||
{
|
||||
qsort1(base, base + n, f);
|
||||
}
|
||||
@ -851,9 +818,7 @@ qsortp(base, n, f)
|
||||
}
|
||||
|
||||
static void
|
||||
qsort1(base, lim, f)
|
||||
void **base, **lim;
|
||||
int (*f)(void *, void *);
|
||||
qsort1(void **base, void **lim, int (*f) (void *, void *))
|
||||
{
|
||||
void **i, **j;
|
||||
void **lptr, **hptr;
|
||||
@ -922,17 +887,14 @@ qsort1(base, lim, f)
|
||||
}
|
||||
|
||||
int
|
||||
xstrcmp(p1, p2)
|
||||
void *p1, *p2;
|
||||
xstrcmp(void *p1, void *p2)
|
||||
{
|
||||
return (strcmp((char *)p1, (char *)p2));
|
||||
}
|
||||
|
||||
/* Initialize a Getopt structure */
|
||||
void
|
||||
ksh_getopt_reset(go, flags)
|
||||
Getopt *go;
|
||||
int flags;
|
||||
ksh_getopt_reset(Getopt *go, int flags)
|
||||
{
|
||||
go->optind = 1;
|
||||
go->optarg = (char *) 0;
|
||||
@ -968,10 +930,7 @@ ksh_getopt_reset(go, flags)
|
||||
* in go->info.
|
||||
*/
|
||||
int
|
||||
ksh_getopt(argv, go, options)
|
||||
char **argv;
|
||||
Getopt *go;
|
||||
const char *options;
|
||||
ksh_getopt(char **argv, Getopt *go, const char *options)
|
||||
{
|
||||
char c;
|
||||
char *o;
|
||||
@ -1071,8 +1030,7 @@ ksh_getopt(argv, go, options)
|
||||
* No trailing newline is printed.
|
||||
*/
|
||||
void
|
||||
print_value_quoted(s)
|
||||
const char *s;
|
||||
print_value_quoted(const char *s)
|
||||
{
|
||||
const char *p;
|
||||
int inquote = 0;
|
||||
@ -1105,13 +1063,7 @@ print_value_quoted(s)
|
||||
* element
|
||||
*/
|
||||
void
|
||||
print_columns(shf, n, func, arg, max_width, prefcol)
|
||||
struct shf *shf;
|
||||
int n;
|
||||
char *(*func)(void *, int, char *, int);
|
||||
void *arg;
|
||||
int max_width;
|
||||
int prefcol;
|
||||
print_columns(struct shf *shf, int n, char *(*func) (void *, int, char *, int), void *arg, int max_width, int prefcol)
|
||||
{
|
||||
char *str = (char *) alloc(max_width + 1, ATEMP);
|
||||
int i;
|
||||
@ -1157,9 +1109,7 @@ print_columns(shf, n, func, arg, max_width, prefcol)
|
||||
|
||||
/* Strip any nul bytes from buf - returns new length (nbytes - # of nuls) */
|
||||
int
|
||||
strip_nuls(buf, nbytes)
|
||||
char *buf;
|
||||
int nbytes;
|
||||
strip_nuls(char *buf, int nbytes)
|
||||
{
|
||||
char *dst;
|
||||
|
||||
@ -1190,10 +1140,7 @@ strip_nuls(buf, nbytes)
|
||||
* Returns dst.
|
||||
*/
|
||||
char *
|
||||
str_zcpy(dst, src, dsize)
|
||||
char *dst;
|
||||
const char *src;
|
||||
int dsize;
|
||||
str_zcpy(char *dst, const char *src, int dsize)
|
||||
{
|
||||
if (dsize > 0) {
|
||||
int len = strlen(src);
|
||||
@ -1210,10 +1157,7 @@ str_zcpy(dst, src, dsize)
|
||||
* and restarts read.
|
||||
*/
|
||||
int
|
||||
blocking_read(fd, buf, nbytes)
|
||||
int fd;
|
||||
char *buf;
|
||||
int nbytes;
|
||||
blocking_read(int fd, char *buf, int nbytes)
|
||||
{
|
||||
int ret;
|
||||
int tried_reset = 0;
|
||||
@ -1242,8 +1186,7 @@ blocking_read(fd, buf, nbytes)
|
||||
* 1 if it was.
|
||||
*/
|
||||
int
|
||||
reset_nonblock(fd)
|
||||
int fd;
|
||||
reset_nonblock(int fd)
|
||||
{
|
||||
int flags;
|
||||
int blocking_flags;
|
||||
@ -1296,9 +1239,7 @@ reset_nonblock(fd)
|
||||
|
||||
/* Like getcwd(), except bsize is ignored if buf is 0 (MAXPATHLEN is used) */
|
||||
char *
|
||||
ksh_get_wd(buf, bsize)
|
||||
char *buf;
|
||||
int bsize;
|
||||
ksh_get_wd(char *buf, int bsize)
|
||||
{
|
||||
#ifdef HAVE_GETCWD
|
||||
char *b;
|
||||
|
30
path.c
30
path.c
@ -1,10 +1,10 @@
|
||||
/** $MirBSD: path.c,v 1.6 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: path.c,v 1.7 2004/10/28 11:53:43 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: path.c,v 1.6 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: path.c,v 1.7 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
/*
|
||||
* Contains a routine to search a : separated list of
|
||||
@ -35,12 +35,12 @@ static char *do_phys_path(XString *xsp, char *xp, const char *path);
|
||||
* was appended to result.
|
||||
*/
|
||||
int
|
||||
make_path(cwd, file, cdpathp, xsp, phys_pathp)
|
||||
const char *cwd;
|
||||
const char *file;
|
||||
char **cdpathp; /* & of : separated list */
|
||||
XString *xsp;
|
||||
int *phys_pathp;
|
||||
make_path(const char *cwd, const char *file, char **cdpathp, XString *xsp, int *phys_pathp)
|
||||
|
||||
|
||||
/* & of : separated list */
|
||||
|
||||
|
||||
{
|
||||
int rval = 0;
|
||||
int use_cdpath = 1;
|
||||
@ -113,8 +113,7 @@ make_path(cwd, file, cdpathp, xsp, phys_pathp)
|
||||
* ie, simplify_path("/a/b/c/./../d/..") returns "/a/b"
|
||||
*/
|
||||
void
|
||||
simplify_path(path)
|
||||
char *path;
|
||||
simplify_path(char *path)
|
||||
{
|
||||
char *cur;
|
||||
char *t;
|
||||
@ -196,8 +195,7 @@ simplify_path(path)
|
||||
|
||||
|
||||
void
|
||||
set_current_wd(path)
|
||||
char *path;
|
||||
set_current_wd(char *path)
|
||||
{
|
||||
int len;
|
||||
char *p = path;
|
||||
@ -216,8 +214,7 @@ set_current_wd(path)
|
||||
|
||||
#ifdef S_ISLNK
|
||||
char *
|
||||
get_phys_path(path)
|
||||
const char *path;
|
||||
get_phys_path(const char *path)
|
||||
{
|
||||
XString xs;
|
||||
char *xp;
|
||||
@ -237,10 +234,7 @@ get_phys_path(path)
|
||||
}
|
||||
|
||||
static char *
|
||||
do_phys_path(xsp, xp, path)
|
||||
XString *xsp;
|
||||
char *xp;
|
||||
const char *path;
|
||||
do_phys_path(XString *xsp, char *xp, const char *path)
|
||||
{
|
||||
const char *p, *q;
|
||||
size_t len;
|
||||
|
7
proto.h
7
proto.h
@ -1,7 +1,10 @@
|
||||
/** $MirBSD: proto.h,v 1.7 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: proto.h,v 1.8 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: proto.h,v 1.11 2003/05/16 19:58:57 jsyn Exp $ */
|
||||
/* $From: proto.h,v 1.3 1994/05/19 18:32:40 michael Exp michael $ */
|
||||
|
||||
#ifndef PROTO_H
|
||||
#define PROTO_H
|
||||
|
||||
/*
|
||||
* prototypes for PD-KSH
|
||||
* originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang"
|
||||
@ -305,3 +308,5 @@ extern int gettimeofday( /* struct timeval *tv, struct timezone *tz */ );
|
||||
extern int setrlimit( /* int resource, struct rlimit *rlp */ );
|
||||
extern int lstat( /* const char *path, struct stat *buf */ );
|
||||
#endif
|
||||
|
||||
#endif /* ndef PROTO_H */
|
||||
|
12
sh.h
12
sh.h
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: sh.h,v 1.14 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: sh.h,v 1.15 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: sh.h,v 1.18 2004/05/31 10:36:35 otto Exp $ */
|
||||
|
||||
#ifndef SH_H
|
||||
#define SH_H
|
||||
|
||||
/*
|
||||
* mirbsdksh - MirOS Project Korn-Shell
|
||||
* from: Public Domain Bourne/Korn shell
|
||||
@ -102,13 +105,8 @@ void *memmove(void *d, const void *s, size_t n);
|
||||
# endif
|
||||
#endif /* HAVE_MEMMOVE */
|
||||
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
# include <stdarg.h>
|
||||
# define SH_VA_START(va, argn) va_start(va, argn)
|
||||
#else
|
||||
# include <varargs.h>
|
||||
# define SH_VA_START(va, argn) va_start(va)
|
||||
#endif /* HAVE_PROTOTYPES */
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
@ -722,3 +720,5 @@ EXTERN int x_cols I__(80); /* tty columns */
|
||||
# undef EXTERN
|
||||
#endif
|
||||
#undef I__
|
||||
|
||||
#endif /* ndef SH_H */
|
||||
|
109
shf.c
109
shf.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: shf.c,v 1.5 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: shf.c,v 1.6 2004/10/28 11:53:43 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: shf.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: shf.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
/* flags to shf_emptybuf() */
|
||||
#define EB_READSW 0x01 /* about to switch to reading */
|
||||
@ -29,11 +29,7 @@ static int shf_emptybuf(struct shf *shf, int flags);
|
||||
* fails.
|
||||
*/
|
||||
struct shf *
|
||||
shf_open(name, oflags, mode, sflags)
|
||||
const char *name;
|
||||
int oflags;
|
||||
int mode;
|
||||
int sflags;
|
||||
shf_open(const char *name, int oflags, int mode, int sflags)
|
||||
{
|
||||
struct shf *shf;
|
||||
int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
|
||||
@ -73,10 +69,7 @@ shf_open(name, oflags, mode, sflags)
|
||||
|
||||
/* Set up the shf structure for a file descriptor. Doesn't fail. */
|
||||
struct shf *
|
||||
shf_fdopen(fd, sflags, shf)
|
||||
int fd;
|
||||
int sflags;
|
||||
struct shf *shf;
|
||||
shf_fdopen(int fd, int sflags, struct shf *shf)
|
||||
{
|
||||
int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
|
||||
|
||||
@ -126,10 +119,7 @@ shf_fdopen(fd, sflags, shf)
|
||||
|
||||
/* Set up an existing shf (and buffer) to use the given fd */
|
||||
struct shf *
|
||||
shf_reopen(fd, sflags, shf)
|
||||
int fd;
|
||||
int sflags;
|
||||
struct shf *shf;
|
||||
shf_reopen(int fd, int sflags, struct shf *shf)
|
||||
{
|
||||
int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE;
|
||||
|
||||
@ -176,11 +166,7 @@ shf_reopen(fd, sflags, shf)
|
||||
* When writing, a byte is reserved for a trailing null - see shf_sclose().
|
||||
*/
|
||||
struct shf *
|
||||
shf_sopen(buf, bsize, sflags, shf)
|
||||
char *buf;
|
||||
int bsize;
|
||||
int sflags;
|
||||
struct shf *shf;
|
||||
shf_sopen(char *buf, int bsize, int sflags, struct shf *shf)
|
||||
{
|
||||
/* can't have a read+write string */
|
||||
if (!(sflags & (SHF_RD | SHF_WR))
|
||||
@ -213,8 +199,7 @@ shf_sopen(buf, bsize, sflags, shf)
|
||||
|
||||
/* Flush and close file descriptor, free the shf structure */
|
||||
int
|
||||
shf_close(shf)
|
||||
struct shf *shf;
|
||||
shf_close(struct shf *shf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@ -233,8 +218,7 @@ shf_close(shf)
|
||||
|
||||
/* Flush and close file descriptor, don't free file structure */
|
||||
int
|
||||
shf_fdclose(shf)
|
||||
struct shf *shf;
|
||||
shf_fdclose(struct shf *shf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@ -256,8 +240,7 @@ shf_fdclose(shf)
|
||||
* (does not free string if it was allocated).
|
||||
*/
|
||||
char *
|
||||
shf_sclose(shf)
|
||||
struct shf *shf;
|
||||
shf_sclose(struct shf *shf)
|
||||
{
|
||||
unsigned char *s = shf->buf;
|
||||
|
||||
@ -273,8 +256,7 @@ shf_sclose(shf)
|
||||
|
||||
/* Flush and free file structure, don't close file descriptor */
|
||||
int
|
||||
shf_finish(shf)
|
||||
struct shf *shf;
|
||||
shf_finish(struct shf *shf)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@ -292,8 +274,7 @@ shf_finish(shf)
|
||||
* buffered. Returns 0 for success, EOF for (write) error.
|
||||
*/
|
||||
int
|
||||
shf_flush(shf)
|
||||
struct shf *shf;
|
||||
shf_flush(struct shf *shf)
|
||||
{
|
||||
if (shf->flags & SHF_STRING)
|
||||
return (shf->flags & SHF_WR) ? EOF : 0;
|
||||
@ -324,9 +305,7 @@ shf_flush(shf)
|
||||
* buffer. Returns 0 for success, EOF for (write) error.
|
||||
*/
|
||||
static int
|
||||
shf_emptybuf(shf, flags)
|
||||
struct shf *shf;
|
||||
int flags;
|
||||
shf_emptybuf(struct shf *shf, int flags)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@ -406,8 +385,7 @@ shf_emptybuf(shf, flags)
|
||||
|
||||
/* Fill up a read buffer. Returns EOF for a read error, 0 otherwise. */
|
||||
static int
|
||||
shf_fillbuf(shf)
|
||||
struct shf *shf;
|
||||
shf_fillbuf(struct shf *shf)
|
||||
{
|
||||
if (shf->flags & SHF_STRING)
|
||||
return 0;
|
||||
@ -453,10 +431,7 @@ shf_fillbuf(shf)
|
||||
* buffer. Returns 0 for success, EOF otherwise.
|
||||
*/
|
||||
int
|
||||
shf_seek(shf, where, from)
|
||||
struct shf *shf;
|
||||
off_t where;
|
||||
int from;
|
||||
shf_seek(struct shf *shf, off_t where, int from)
|
||||
{
|
||||
if (shf->fd < 0) {
|
||||
errno = EINVAL;
|
||||
@ -501,10 +476,7 @@ shf_seek(shf, where, from)
|
||||
* a read error occurred.
|
||||
*/
|
||||
int
|
||||
shf_read(buf, bsize, shf)
|
||||
char *buf;
|
||||
int bsize;
|
||||
struct shf *shf;
|
||||
shf_read(char *buf, int bsize, struct shf *shf)
|
||||
{
|
||||
int orig_bsize = bsize;
|
||||
int ncopy;
|
||||
@ -538,10 +510,7 @@ shf_read(buf, bsize, shf)
|
||||
* end of file, returns a pointer to the null byte in buf otherwise.
|
||||
*/
|
||||
char *
|
||||
shf_getse(buf, bsize, shf)
|
||||
char *buf;
|
||||
int bsize;
|
||||
struct shf *shf;
|
||||
shf_getse(char *buf, int bsize, struct shf *shf)
|
||||
{
|
||||
unsigned char *end;
|
||||
int ncopy;
|
||||
@ -588,8 +557,7 @@ shf_getse(buf, bsize, shf)
|
||||
|
||||
/* Returns the char read. Returns EOF for error and end of file. */
|
||||
int
|
||||
shf_getchar(shf)
|
||||
struct shf *shf;
|
||||
shf_getchar(struct shf *shf)
|
||||
{
|
||||
if (!(shf->flags & SHF_RD))
|
||||
internal_errorf(1, "shf_getchar: flags %x", shf->flags);
|
||||
@ -604,9 +572,7 @@ shf_getchar(shf)
|
||||
* successful, EOF if there is no room.
|
||||
*/
|
||||
int
|
||||
shf_ungetc(c, shf)
|
||||
int c;
|
||||
struct shf *shf;
|
||||
shf_ungetc(int c, struct shf *shf)
|
||||
{
|
||||
if (!(shf->flags & SHF_RD))
|
||||
internal_errorf(1, "shf_ungetc: flags %x", shf->flags);
|
||||
@ -641,9 +607,7 @@ shf_ungetc(c, shf)
|
||||
* the char could not be written.
|
||||
*/
|
||||
int
|
||||
shf_putchar(c, shf)
|
||||
int c;
|
||||
struct shf *shf;
|
||||
shf_putchar(int c, struct shf *shf)
|
||||
{
|
||||
if (!(shf->flags & SHF_WR))
|
||||
internal_errorf(1, "shf_putchar: flags %x", shf->flags);
|
||||
@ -685,9 +649,7 @@ shf_putchar(c, shf)
|
||||
* the string could not be written.
|
||||
*/
|
||||
int
|
||||
shf_puts(s, shf)
|
||||
const char *s;
|
||||
struct shf *shf;
|
||||
shf_puts(const char *s, struct shf *shf)
|
||||
{
|
||||
if (!s)
|
||||
return EOF;
|
||||
@ -697,10 +659,7 @@ shf_puts(s, shf)
|
||||
|
||||
/* Write a buffer. Returns nbytes if successful, EOF if there is an error. */
|
||||
int
|
||||
shf_write(buf, nbytes, shf)
|
||||
const char *buf;
|
||||
int nbytes;
|
||||
struct shf *shf;
|
||||
shf_write(const char *buf, int nbytes, struct shf *shf)
|
||||
{
|
||||
int orig_nbytes = nbytes;
|
||||
int n;
|
||||
@ -761,14 +720,7 @@ shf_write(buf, nbytes, shf)
|
||||
}
|
||||
|
||||
int
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shf_fprintf(struct shf *shf, const char *fmt, ...)
|
||||
#else
|
||||
shf_fprintf(shf, fmt, va_alist)
|
||||
struct shf *shf;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list args;
|
||||
int n;
|
||||
@ -781,15 +733,7 @@ shf_fprintf(shf, fmt, va_alist)
|
||||
}
|
||||
|
||||
int
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shf_snprintf(char *buf, int bsize, const char *fmt, ...)
|
||||
#else
|
||||
shf_snprintf(buf, bsize, fmt, va_alist)
|
||||
char *buf;
|
||||
int bsize;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
struct shf shf;
|
||||
va_list args;
|
||||
@ -808,13 +752,7 @@ shf_snprintf(buf, bsize, fmt, va_alist)
|
||||
}
|
||||
|
||||
char *
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
shf_smprintf(const char *fmt, ...)
|
||||
#else
|
||||
shf_smprintf(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
struct shf shf;
|
||||
va_list args;
|
||||
@ -884,10 +822,7 @@ my_ceil(d)
|
||||
#endif /* FP */
|
||||
|
||||
int
|
||||
shf_vfprintf(shf, fmt, args)
|
||||
struct shf *shf;
|
||||
const char *fmt;
|
||||
va_list args;
|
||||
shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
||||
{
|
||||
char c, *s;
|
||||
int UNINITIALIZED(tmp);
|
||||
|
4
shf.h
4
shf.h
@ -1,8 +1,8 @@
|
||||
/** $MirBSD: shf.h,v 1.4 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: shf.h,v 1.5 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: shf.h,v 1.2 1999/01/08 20:25:02 millert Exp $ */
|
||||
|
||||
#ifndef SHF_H
|
||||
# define SHF_H
|
||||
#define SHF_H
|
||||
|
||||
/*
|
||||
* Shell file I/O routines
|
||||
|
83
syn.c
83
syn.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: syn.c,v 1.6 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: syn.c,v 1.7 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: syn.c,v 1.14 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -8,7 +8,7 @@
|
||||
#include "sh.h"
|
||||
#include "c_test.h"
|
||||
|
||||
__RCSID("$MirBSD: syn.c,v 1.6 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: syn.c,v 1.7 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
struct nesting_state {
|
||||
int start_token; /* token than began nesting (eg, FOR) */
|
||||
@ -63,7 +63,7 @@ static int symbol; /* yylex value */
|
||||
((reject) ? (symbol) : (REJECT, symbol = yylex(cf)))
|
||||
|
||||
static void
|
||||
yyparse()
|
||||
yyparse(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -78,8 +78,7 @@ yyparse()
|
||||
}
|
||||
|
||||
static struct op *
|
||||
pipeline(cf)
|
||||
int cf;
|
||||
pipeline(int cf)
|
||||
{
|
||||
struct op *t, *p, *tl = NULL;
|
||||
|
||||
@ -99,7 +98,7 @@ pipeline(cf)
|
||||
}
|
||||
|
||||
static struct op *
|
||||
andor()
|
||||
andor(void)
|
||||
{
|
||||
struct op *t, *p;
|
||||
int c;
|
||||
@ -117,8 +116,7 @@ andor()
|
||||
}
|
||||
|
||||
static struct op *
|
||||
c_list(multi)
|
||||
int multi;
|
||||
c_list(int multi)
|
||||
{
|
||||
struct op *t = NULL, *p, *tl = NULL;
|
||||
int c;
|
||||
@ -155,8 +153,7 @@ c_list(multi)
|
||||
}
|
||||
|
||||
static struct ioword *
|
||||
synio(cf)
|
||||
int cf;
|
||||
synio(int cf)
|
||||
{
|
||||
struct ioword *iop;
|
||||
int ishere;
|
||||
@ -180,16 +177,14 @@ synio(cf)
|
||||
}
|
||||
|
||||
static void
|
||||
musthave(c, cf)
|
||||
int c, cf;
|
||||
musthave(int c, int cf)
|
||||
{
|
||||
if ((token(cf)) != c)
|
||||
syntaxerr((char *) 0);
|
||||
}
|
||||
|
||||
static struct op *
|
||||
nested(type, smark, emark)
|
||||
int type, smark, emark;
|
||||
nested(int type, int smark, int emark)
|
||||
{
|
||||
struct op *t;
|
||||
struct nesting_state old_nesting;
|
||||
@ -202,8 +197,7 @@ nested(type, smark, emark)
|
||||
}
|
||||
|
||||
static struct op *
|
||||
get_command(cf)
|
||||
int cf;
|
||||
get_command(int cf)
|
||||
{
|
||||
struct op *t;
|
||||
int c, iopn = 0, syniocf;
|
||||
@ -419,7 +413,7 @@ get_command(cf)
|
||||
}
|
||||
|
||||
static struct op *
|
||||
dogroup()
|
||||
dogroup(void)
|
||||
{
|
||||
int c;
|
||||
struct op *list;
|
||||
@ -442,7 +436,7 @@ dogroup()
|
||||
}
|
||||
|
||||
static struct op *
|
||||
thenpart()
|
||||
thenpart(void)
|
||||
{
|
||||
struct op *t;
|
||||
|
||||
@ -456,7 +450,7 @@ thenpart()
|
||||
}
|
||||
|
||||
static struct op *
|
||||
elsepart()
|
||||
elsepart(void)
|
||||
{
|
||||
struct op *t;
|
||||
|
||||
@ -479,7 +473,7 @@ elsepart()
|
||||
}
|
||||
|
||||
static struct op *
|
||||
caselist()
|
||||
caselist(void)
|
||||
{
|
||||
struct op *t, *tl;
|
||||
int c;
|
||||
@ -505,8 +499,7 @@ caselist()
|
||||
}
|
||||
|
||||
static struct op *
|
||||
casepart(endtok)
|
||||
int endtok;
|
||||
casepart(int endtok)
|
||||
{
|
||||
struct op *t;
|
||||
int c;
|
||||
@ -534,9 +527,9 @@ casepart(endtok)
|
||||
}
|
||||
|
||||
static struct op *
|
||||
function_body(name, ksh_func)
|
||||
char *name;
|
||||
int ksh_func; /* function foo { ... } vs foo() { .. } */
|
||||
function_body(char *name, int ksh_func)
|
||||
|
||||
/* function foo { ... } vs foo() { .. } */
|
||||
{
|
||||
char *sname, *p;
|
||||
struct op *t;
|
||||
@ -595,7 +588,7 @@ function_body(name, ksh_func)
|
||||
}
|
||||
|
||||
static char **
|
||||
wordlist()
|
||||
wordlist(void)
|
||||
{
|
||||
int c;
|
||||
XPtrV args;
|
||||
@ -625,10 +618,7 @@ wordlist()
|
||||
*/
|
||||
|
||||
static struct op *
|
||||
block(type, t1, t2, wp)
|
||||
int type;
|
||||
struct op *t1, *t2;
|
||||
char **wp;
|
||||
block(int type, struct op *t1, struct op *t2, char **wp)
|
||||
{
|
||||
struct op *t;
|
||||
|
||||
@ -683,7 +673,7 @@ const struct tokeninfo {
|
||||
};
|
||||
|
||||
void
|
||||
initkeywords()
|
||||
initkeywords(void)
|
||||
{
|
||||
struct tokeninfo const *tt;
|
||||
struct tbl *p;
|
||||
@ -700,8 +690,7 @@ initkeywords()
|
||||
}
|
||||
|
||||
static void
|
||||
syntaxerr(what)
|
||||
const char *what;
|
||||
syntaxerr(const char *what)
|
||||
{
|
||||
char redir[6]; /* 2<<- is the longest redirection, I think */
|
||||
const char *s;
|
||||
@ -753,9 +742,7 @@ syntaxerr(what)
|
||||
}
|
||||
|
||||
static void
|
||||
nesting_push(save, tok)
|
||||
struct nesting_state *save;
|
||||
int tok;
|
||||
nesting_push(struct nesting_state *save, int tok)
|
||||
{
|
||||
*save = nesting;
|
||||
nesting.start_token = tok;
|
||||
@ -763,15 +750,13 @@ nesting_push(save, tok)
|
||||
}
|
||||
|
||||
static void
|
||||
nesting_pop(saved)
|
||||
struct nesting_state *saved;
|
||||
nesting_pop(struct nesting_state *saved)
|
||||
{
|
||||
nesting = *saved;
|
||||
}
|
||||
|
||||
static struct op *
|
||||
newtp(type)
|
||||
int type;
|
||||
newtp(int type)
|
||||
{
|
||||
struct op *t;
|
||||
|
||||
@ -786,8 +771,7 @@ newtp(type)
|
||||
}
|
||||
|
||||
struct op *
|
||||
compile(s)
|
||||
Source *s;
|
||||
compile(Source *s)
|
||||
{
|
||||
nesting.start_token = 0;
|
||||
nesting.start_line = 0;
|
||||
@ -808,8 +792,7 @@ compile(s)
|
||||
* $
|
||||
*/
|
||||
static int
|
||||
assign_command(s)
|
||||
char *s;
|
||||
assign_command(char *s)
|
||||
{
|
||||
char c = *s;
|
||||
|
||||
@ -823,8 +806,7 @@ assign_command(s)
|
||||
|
||||
/* Check if we are in the middle of reading an alias */
|
||||
static int
|
||||
inalias(s)
|
||||
struct source *s;
|
||||
inalias(struct source *s)
|
||||
{
|
||||
for (; s && s->type == SALIAS; s = s->next)
|
||||
if (!(s->flags & SF_ALIASEND))
|
||||
@ -857,9 +839,7 @@ const char db_gthan[] = { CHAR, '>', EOS };
|
||||
* TM_UNOP and TM_BINOP, the returned value is a Test_op).
|
||||
*/
|
||||
static int
|
||||
dbtestp_isa(te, meta)
|
||||
Test_env *te;
|
||||
Test_meta meta;
|
||||
dbtestp_isa(Test_env *te, Test_meta meta)
|
||||
{
|
||||
int c = tpeek(ARRAYVAR | (meta == TM_BINOP ? 0 : CONTIN));
|
||||
int uqword = 0;
|
||||
@ -928,10 +908,7 @@ dbtestp_eval(Test_env *te GCC_FUNC_ATTR(unused),
|
||||
}
|
||||
|
||||
static void
|
||||
dbtestp_error(te, offset, msg)
|
||||
Test_env *te;
|
||||
int offset;
|
||||
const char *msg;
|
||||
dbtestp_error(Test_env *te, int offset, const char *msg)
|
||||
{
|
||||
te->flags |= TEF_ERROR;
|
||||
|
||||
|
48
table.c
48
table.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: table.c,v 1.5 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: table.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: table.c,v 1.5 1999/01/10 17:55:03 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirBSD: table.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: table.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
#define INIT_TBLS 8 /* initial table size (power of 2) */
|
||||
|
||||
@ -16,8 +16,7 @@ static int tnamecmp(void *p1, void *p2);
|
||||
|
||||
|
||||
unsigned int
|
||||
hash(n)
|
||||
const char * n;
|
||||
hash(const char *n)
|
||||
{
|
||||
unsigned int h = 0;
|
||||
|
||||
@ -27,10 +26,7 @@ hash(n)
|
||||
}
|
||||
|
||||
void
|
||||
tinit(tp, ap, tsize)
|
||||
struct table *tp;
|
||||
Area *ap;
|
||||
int tsize;
|
||||
tinit(struct table *tp, Area *ap, int tsize)
|
||||
{
|
||||
tp->areap = ap;
|
||||
tp->tbls = NULL;
|
||||
@ -40,9 +36,7 @@ tinit(tp, ap, tsize)
|
||||
}
|
||||
|
||||
static void
|
||||
texpand(tp, nsize)
|
||||
struct table *tp;
|
||||
int nsize;
|
||||
texpand(struct table *tp, int nsize)
|
||||
{
|
||||
int i;
|
||||
struct tbl *tblp, **p;
|
||||
@ -75,10 +69,10 @@ texpand(tp, nsize)
|
||||
}
|
||||
|
||||
struct tbl *
|
||||
tsearch(tp, n, h)
|
||||
struct table *tp; /* table */
|
||||
const char *n; /* name to enter */
|
||||
unsigned int h; /* hash(n) */
|
||||
tsearch(struct table *tp, const char *n, unsigned int h)
|
||||
/* table */
|
||||
/* name to enter */
|
||||
/* hash(n) */
|
||||
{
|
||||
struct tbl **pp, *p;
|
||||
|
||||
@ -98,10 +92,10 @@ tsearch(tp, n, h)
|
||||
}
|
||||
|
||||
struct tbl *
|
||||
tenter(tp, n, h)
|
||||
struct table *tp; /* table */
|
||||
const char *n; /* name to enter */
|
||||
unsigned int h; /* hash(n) */
|
||||
tenter(struct table *tp, const char *n, unsigned int h)
|
||||
/* table */
|
||||
/* name to enter */
|
||||
/* hash(n) */
|
||||
{
|
||||
struct tbl **pp, *p;
|
||||
int len;
|
||||
@ -140,24 +134,20 @@ tenter(tp, n, h)
|
||||
}
|
||||
|
||||
void
|
||||
tdelete(p)
|
||||
struct tbl *p;
|
||||
tdelete(struct tbl *p)
|
||||
{
|
||||
p->flag = 0;
|
||||
}
|
||||
|
||||
void
|
||||
twalk(ts, tp)
|
||||
struct tstate *ts;
|
||||
struct table *tp;
|
||||
twalk(struct tstate *ts, struct table *tp)
|
||||
{
|
||||
ts->left = tp->size;
|
||||
ts->next = tp->tbls;
|
||||
}
|
||||
|
||||
struct tbl *
|
||||
tnext(ts)
|
||||
struct tstate *ts;
|
||||
tnext(struct tstate *ts)
|
||||
{
|
||||
while (--ts->left >= 0) {
|
||||
struct tbl *p = *ts->next++;
|
||||
@ -168,15 +158,13 @@ tnext(ts)
|
||||
}
|
||||
|
||||
static int
|
||||
tnamecmp(p1, p2)
|
||||
void *p1, *p2;
|
||||
tnamecmp(void *p1, void *p2)
|
||||
{
|
||||
return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name);
|
||||
}
|
||||
|
||||
struct tbl **
|
||||
tsort(tp)
|
||||
struct table *tp;
|
||||
tsort(struct table *tp)
|
||||
{
|
||||
int i;
|
||||
struct tbl **p, **sp, **dp;
|
||||
|
11
table.h
11
table.h
@ -1,7 +1,10 @@
|
||||
/** $MirBSD: table.h,v 1.4 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: table.h,v 1.5 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: table.h,v 1.5 1999/06/15 01:18:36 millert Exp $ */
|
||||
/* $From: table.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */
|
||||
|
||||
#ifndef TABLE_H
|
||||
#define TABLE_H
|
||||
|
||||
/*
|
||||
* generic hashed associative table for commands and variables.
|
||||
*/
|
||||
@ -116,12 +119,8 @@ struct block {
|
||||
struct table vars; /* local variables */
|
||||
struct table funs; /* local functions */
|
||||
Getopt getopts_state;
|
||||
#if 1
|
||||
char * error; /* error handler */
|
||||
char * exit; /* exit handler */
|
||||
#else
|
||||
Trap error, exit;
|
||||
#endif
|
||||
struct block *next; /* enclosing block */
|
||||
};
|
||||
|
||||
@ -181,3 +180,5 @@ EXTERN char *tmpdir; /* TMPDIR value */
|
||||
EXTERN const char *prompt;
|
||||
EXTERN int cur_prompt; /* PS1 or PS2 */
|
||||
EXTERN int current_lineno; /* LINENO value */
|
||||
|
||||
#endif /* ndef TABLE_H */
|
||||
|
49
trap.c
49
trap.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: trap.c,v 1.5 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: trap.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: trap.c,v 1.13 2003/02/28 09:45:09 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -9,7 +9,7 @@
|
||||
#define FROM_TRAP_C
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirBSD: trap.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: trap.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
/* Table is indexed by signal number
|
||||
*
|
||||
@ -25,7 +25,7 @@ Trap sigtraps[SIGNALS+1] = {
|
||||
static struct sigaction Sigact_ign, Sigact_trap;
|
||||
|
||||
void
|
||||
inittraps()
|
||||
inittraps(void)
|
||||
{
|
||||
#ifdef HAVE_SYS_SIGLIST
|
||||
# ifndef SYS_SIGLIST_DECLARED
|
||||
@ -62,7 +62,7 @@ inittraps()
|
||||
static RETSIGTYPE alarm_catcher(int sig);
|
||||
|
||||
void
|
||||
alarm_init()
|
||||
alarm_init(void)
|
||||
{
|
||||
sigtraps[SIGALRM].flags |= TF_SHELL_USES;
|
||||
setsig(&sigtraps[SIGALRM], alarm_catcher,
|
||||
@ -89,9 +89,7 @@ alarm_catcher(int sig GCC_FUNC_ATTR(unused))
|
||||
#endif /* KSH */
|
||||
|
||||
Trap *
|
||||
gettrap(name, igncase)
|
||||
const char *name;
|
||||
int igncase;
|
||||
gettrap(const char *name, int igncase)
|
||||
{
|
||||
int i;
|
||||
Trap *p;
|
||||
@ -125,8 +123,7 @@ gettrap(name, igncase)
|
||||
* trap signal handler
|
||||
*/
|
||||
RETSIGTYPE
|
||||
trapsig(i)
|
||||
int i;
|
||||
trapsig(int i)
|
||||
{
|
||||
Trap *p = &sigtraps[i];
|
||||
int errno_ = errno;
|
||||
@ -152,7 +149,7 @@ trapsig(i)
|
||||
* work if user has trapped SIGINT.
|
||||
*/
|
||||
void
|
||||
intrcheck()
|
||||
intrcheck(void)
|
||||
{
|
||||
if (intrsig)
|
||||
runtraps(TF_DFL_INTR|TF_FATAL);
|
||||
@ -162,7 +159,7 @@ intrcheck()
|
||||
* termination has been received.
|
||||
*/
|
||||
int
|
||||
fatal_trap_check()
|
||||
fatal_trap_check(void)
|
||||
{
|
||||
int i;
|
||||
Trap *p;
|
||||
@ -180,7 +177,7 @@ fatal_trap_check()
|
||||
* is set.
|
||||
*/
|
||||
int
|
||||
trap_pending()
|
||||
trap_pending(void)
|
||||
{
|
||||
int i;
|
||||
Trap *p;
|
||||
@ -198,8 +195,7 @@ trap_pending()
|
||||
* can interrupt commands.
|
||||
*/
|
||||
void
|
||||
runtraps(flag)
|
||||
int flag;
|
||||
runtraps(int flag)
|
||||
{
|
||||
int i;
|
||||
Trap *p;
|
||||
@ -228,8 +224,7 @@ runtraps(flag)
|
||||
}
|
||||
|
||||
void
|
||||
runtrap(p)
|
||||
Trap *p;
|
||||
runtrap(Trap *p)
|
||||
{
|
||||
int i = p->signal;
|
||||
char *trapstr = p->trap;
|
||||
@ -275,7 +270,7 @@ runtrap(p)
|
||||
|
||||
/* clear pending traps and reset user's trap handlers; used after fork(2) */
|
||||
void
|
||||
cleartraps()
|
||||
cleartraps(void)
|
||||
{
|
||||
int i;
|
||||
Trap *p;
|
||||
@ -292,7 +287,7 @@ cleartraps()
|
||||
|
||||
/* restore signals just before an exec(2) */
|
||||
void
|
||||
restoresigs()
|
||||
restoresigs(void)
|
||||
{
|
||||
int i;
|
||||
Trap *p;
|
||||
@ -304,9 +299,7 @@ restoresigs()
|
||||
}
|
||||
|
||||
void
|
||||
settrap(p, s)
|
||||
Trap *p;
|
||||
char *s;
|
||||
settrap(Trap *p, char *s)
|
||||
{
|
||||
handler_t f;
|
||||
|
||||
@ -342,7 +335,7 @@ settrap(p, s)
|
||||
* kill shell (unless user catches it and exits)
|
||||
*/
|
||||
int
|
||||
block_pipe()
|
||||
block_pipe(void)
|
||||
{
|
||||
int restore_dfl = 0;
|
||||
Trap *p = &sigtraps[SIGPIPE];
|
||||
@ -360,8 +353,7 @@ block_pipe()
|
||||
|
||||
/* Called by c_print() to undo whatever block_pipe() did */
|
||||
void
|
||||
restore_pipe(restore_dfl)
|
||||
int restore_dfl;
|
||||
restore_pipe(int restore_dfl)
|
||||
{
|
||||
if (restore_dfl)
|
||||
setsig(&sigtraps[SIGPIPE], SIG_DFL, SS_RESTORE_CURR);
|
||||
@ -372,10 +364,7 @@ restore_pipe(restore_dfl)
|
||||
* FTALKING.
|
||||
*/
|
||||
int
|
||||
setsig(p, f, flags)
|
||||
Trap *p;
|
||||
handler_t f;
|
||||
int flags;
|
||||
setsig(Trap *p, handler_t f, int flags)
|
||||
{
|
||||
struct sigaction sigact;
|
||||
|
||||
@ -426,9 +415,7 @@ setsig(p, f, flags)
|
||||
|
||||
/* control what signal is set to before an exec() */
|
||||
void
|
||||
setexecsig(p, restore)
|
||||
Trap *p;
|
||||
int restore;
|
||||
setexecsig(Trap *p, int restore)
|
||||
{
|
||||
/* XXX debugging */
|
||||
if (!(p->flags & (TF_ORIG_IGN|TF_ORIG_DFL)))
|
||||
|
88
tree.c
88
tree.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: tree.c,v 1.5 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: tree.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: tree.c,v 1.10 2002/02/27 19:37:09 dhartmei Exp $ */
|
||||
|
||||
/*
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirBSD: tree.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: tree.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
#define INDENT 4
|
||||
|
||||
@ -25,10 +25,7 @@ static void iofree(struct ioword **iow, Area *ap);
|
||||
*/
|
||||
|
||||
static void
|
||||
ptree(t, indent, shf)
|
||||
struct op *t;
|
||||
int indent;
|
||||
struct shf *shf;
|
||||
ptree(struct op *t, int indent, struct shf *shf)
|
||||
{
|
||||
char **w;
|
||||
struct ioword **ioact;
|
||||
@ -51,25 +48,8 @@ ptree(t, indent, shf)
|
||||
fptreef(shf, indent, "#no-args# ");
|
||||
break;
|
||||
case TEXEC:
|
||||
#if 0 /* ?not useful - can't be called? */
|
||||
/* Print original vars */
|
||||
if (t->left->vars)
|
||||
for (w = t->left->vars; *w != NULL; )
|
||||
fptreef(shf, indent, "%S ", *w++);
|
||||
else
|
||||
fptreef(shf, indent, "#no-vars# ");
|
||||
/* Print expanded vars */
|
||||
if (t->args)
|
||||
for (w = t->args; *w != NULL; )
|
||||
fptreef(shf, indent, "%s ", *w++);
|
||||
else
|
||||
fptreef(shf, indent, "#no-args# ");
|
||||
/* Print original io */
|
||||
t = t->left;
|
||||
#else
|
||||
t = t->left;
|
||||
goto Chain;
|
||||
#endif
|
||||
case TPAREN:
|
||||
fptreef(shf, indent + 2, "( %T) ", t->left);
|
||||
break;
|
||||
@ -212,10 +192,7 @@ ptree(t, indent, shf)
|
||||
}
|
||||
|
||||
static void
|
||||
pioact(shf, indent, iop)
|
||||
struct shf *shf;
|
||||
int indent;
|
||||
struct ioword *iop;
|
||||
pioact(struct shf *shf, int indent, struct ioword *iop)
|
||||
{
|
||||
int flag = iop->flag;
|
||||
int type = flag & IOTYPE;
|
||||
@ -273,9 +250,7 @@ pioact(shf, indent, iop)
|
||||
*/
|
||||
|
||||
static void
|
||||
tputC(c, shf)
|
||||
int c;
|
||||
struct shf *shf;
|
||||
tputC(int c, struct shf *shf)
|
||||
{
|
||||
if ((c&0x60) == 0) { /* C0|C1 */
|
||||
tputc((c&0x80) ? '$' : '^', shf);
|
||||
@ -288,9 +263,7 @@ tputC(c, shf)
|
||||
}
|
||||
|
||||
static void
|
||||
tputS(wp, shf)
|
||||
char *wp;
|
||||
struct shf *shf;
|
||||
tputS(char *wp, struct shf *shf)
|
||||
{
|
||||
int c, quoted=0;
|
||||
|
||||
@ -372,15 +345,7 @@ tputS(wp, shf)
|
||||
*/
|
||||
/* VARARGS */
|
||||
int
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
fptreef(struct shf *shf, int indent, const char *fmt, ...)
|
||||
#else
|
||||
fptreef(shf, indent, fmt, va_alist)
|
||||
struct shf *shf;
|
||||
int indent;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
|
||||
@ -393,15 +358,7 @@ fptreef(shf, indent, fmt, va_alist)
|
||||
|
||||
/* VARARGS */
|
||||
char *
|
||||
#ifdef HAVE_PROTOTYPES
|
||||
snptreef(char *s, int n, const char *fmt, ...)
|
||||
#else
|
||||
snptreef(s, n, fmt, va_alist)
|
||||
char *s;
|
||||
int n;
|
||||
const char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list va;
|
||||
struct shf shf;
|
||||
@ -416,11 +373,7 @@ snptreef(s, n, fmt, va_alist)
|
||||
}
|
||||
|
||||
static void
|
||||
vfptreef(shf, indent, fmt, va)
|
||||
struct shf *shf;
|
||||
int indent;
|
||||
const char *fmt;
|
||||
va_list va;
|
||||
vfptreef(struct shf *shf, int indent, const char *fmt, va_list va)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -488,9 +441,7 @@ vfptreef(shf, indent, fmt, va)
|
||||
*/
|
||||
|
||||
struct op *
|
||||
tcopy(t, ap)
|
||||
struct op *t;
|
||||
Area *ap;
|
||||
tcopy(struct op *t, Area *ap)
|
||||
{
|
||||
struct op *r;
|
||||
char **tw, **rw;
|
||||
@ -539,9 +490,7 @@ tcopy(t, ap)
|
||||
}
|
||||
|
||||
char *
|
||||
wdcopy(wp, ap)
|
||||
const char *wp;
|
||||
Area *ap;
|
||||
wdcopy(const char *wp, Area *ap)
|
||||
{
|
||||
size_t len = wdscan(wp, EOS) - wp;
|
||||
return memcpy(alloc(len, ap), wp, len);
|
||||
@ -549,9 +498,7 @@ wdcopy(wp, ap)
|
||||
|
||||
/* return the position of prefix c in wp plus 1 */
|
||||
char *
|
||||
wdscan(wp, c)
|
||||
const char *wp;
|
||||
int c;
|
||||
wdscan(const char *wp, int c)
|
||||
{
|
||||
int nest = 0;
|
||||
|
||||
@ -607,8 +554,7 @@ wdscan(wp, c)
|
||||
* (string is allocated from ATEMP)
|
||||
*/
|
||||
char *
|
||||
wdstrip(wp)
|
||||
const char *wp;
|
||||
wdstrip(const char *wp)
|
||||
{
|
||||
struct shf shf;
|
||||
int c;
|
||||
@ -675,9 +621,7 @@ wdstrip(wp)
|
||||
}
|
||||
|
||||
static struct ioword **
|
||||
iocopy(iow, ap)
|
||||
struct ioword **iow;
|
||||
Area *ap;
|
||||
iocopy(struct ioword **iow, Area *ap)
|
||||
{
|
||||
struct ioword **ior;
|
||||
int i;
|
||||
@ -710,9 +654,7 @@ iocopy(iow, ap)
|
||||
*/
|
||||
|
||||
void
|
||||
tfree(t, ap)
|
||||
struct op *t;
|
||||
Area *ap;
|
||||
tfree(struct op *t, Area *ap)
|
||||
{
|
||||
char **w;
|
||||
|
||||
@ -744,9 +686,7 @@ tfree(t, ap)
|
||||
}
|
||||
|
||||
static void
|
||||
iofree(iow, ap)
|
||||
struct ioword **iow;
|
||||
Area *ap;
|
||||
iofree(struct ioword **iow, Area *ap)
|
||||
{
|
||||
struct ioword **iop;
|
||||
struct ioword *p;
|
||||
|
7
tree.h
7
tree.h
@ -1,7 +1,10 @@
|
||||
/** $MirBSD: tree.h,v 1.3 2004/09/21 11:57:16 tg Exp $ */
|
||||
/** $MirBSD: tree.h,v 1.4 2004/10/28 11:53:43 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 $ */
|
||||
|
||||
#ifndef TREE_H
|
||||
#define TREE_H
|
||||
|
||||
/*
|
||||
* command trees for compile/execute
|
||||
*/
|
||||
@ -140,3 +143,5 @@ struct ioword {
|
||||
#define DB_AND 3 /* && -> -a conversion */
|
||||
#define DB_BE 4 /* an inserted -BE */
|
||||
#define DB_PAT 5 /* a pattern argument */
|
||||
|
||||
#endif /* ndef TREE_H */
|
||||
|
13
tty.c
13
tty.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: tty.c,v 1.5 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: tty.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */
|
||||
|
||||
#include "sh.h"
|
||||
@ -7,12 +7,10 @@
|
||||
#include "tty.h"
|
||||
#undef EXTERN
|
||||
|
||||
__RCSID("$MirBSD: tty.c,v 1.5 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: tty.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
|
||||
|
||||
int
|
||||
get_tty(fd, ts)
|
||||
int fd;
|
||||
TTY_state *ts;
|
||||
get_tty(int fd, TTY_state *ts)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -99,8 +97,7 @@ set_tty(int fd, TTY_state *ts, int flags GCC_FUNC_ATTR(unused))
|
||||
* foreground job completion and for setting up tty process group.
|
||||
*/
|
||||
void
|
||||
tty_init(init_ttystate)
|
||||
int init_ttystate;
|
||||
tty_init(int init_ttystate)
|
||||
{
|
||||
int do_close = 1;
|
||||
int tfd;
|
||||
@ -170,7 +167,7 @@ tty_init(init_ttystate)
|
||||
}
|
||||
|
||||
void
|
||||
tty_close()
|
||||
tty_close(void)
|
||||
{
|
||||
if (tty_fd >= 0) {
|
||||
close(tty_fd);
|
||||
|
7
tty.h
7
tty.h
@ -1,6 +1,9 @@
|
||||
/** $MirBSD: tty.h,v 1.4 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: tty.h,v 1.5 2004/10/28 11:53:43 tg Exp $ */
|
||||
/* $OpenBSD: tty.h,v 1.2 1996/11/21 07:59:36 downsj Exp $ */
|
||||
|
||||
#ifndef TTY_H
|
||||
#define TTY_H
|
||||
|
||||
/*
|
||||
tty.h -- centralized definitions for a variety of terminal interfaces
|
||||
|
||||
@ -108,3 +111,5 @@ extern void tty_close(void);
|
||||
# undef EXTERN
|
||||
#endif
|
||||
#undef I__
|
||||
|
||||
#endif /* ndef TTY_H */
|
||||
|
112
var.c
112
var.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: var.c,v 1.10 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: var.c,v 1.11 2004/10/28 11:53:44 tg Exp $ */
|
||||
/* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */
|
||||
|
||||
#include "sh.h"
|
||||
@ -7,7 +7,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include <ctype.h>
|
||||
|
||||
__RCSID("$MirBSD: var.c,v 1.10 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: var.c,v 1.11 2004/10/28 11:53:44 tg Exp $");
|
||||
|
||||
/*
|
||||
* Variables
|
||||
@ -34,7 +34,7 @@ static struct tbl *arraysearch(struct tbl *, int);
|
||||
* assume caller has allocated and set up e->loc
|
||||
*/
|
||||
void
|
||||
newblock()
|
||||
newblock(void)
|
||||
{
|
||||
struct block *l;
|
||||
static char *const empty[] = {null};
|
||||
@ -60,7 +60,7 @@ newblock()
|
||||
* pop a block handling special variables
|
||||
*/
|
||||
void
|
||||
popblock()
|
||||
popblock(void)
|
||||
{
|
||||
struct block *l = e->loc;
|
||||
struct tbl *vp, **vpp = l->vars.tbls, *vq;
|
||||
@ -82,7 +82,7 @@ popblock()
|
||||
|
||||
/* called by main() to initialize variable data structures */
|
||||
void
|
||||
initvar()
|
||||
initvar(void)
|
||||
{
|
||||
static const struct {
|
||||
const char *name;
|
||||
@ -131,10 +131,7 @@ initvar()
|
||||
const char *array_index_calc(const char *n, bool_t *arrayp, int *valp);
|
||||
|
||||
const char *
|
||||
array_index_calc(n, arrayp, valp)
|
||||
const char *n;
|
||||
bool_t *arrayp;
|
||||
int *valp;
|
||||
array_index_calc(const char *n, bool_t *arrayp, int *valp)
|
||||
{
|
||||
const char *p;
|
||||
int len;
|
||||
@ -164,8 +161,7 @@ array_index_calc(n, arrayp, valp)
|
||||
* Search for variable, if not found create globally.
|
||||
*/
|
||||
struct tbl *
|
||||
global(n)
|
||||
const char *n;
|
||||
global(const char *n)
|
||||
{
|
||||
struct block *l = e->loc;
|
||||
struct tbl *vp;
|
||||
@ -247,9 +243,7 @@ global(n)
|
||||
* Search for local variable, if not found create locally.
|
||||
*/
|
||||
struct tbl *
|
||||
local(n, copy)
|
||||
const char *n;
|
||||
bool_t copy;
|
||||
local(const char *n, bool_t copy)
|
||||
{
|
||||
struct block *l = e->loc;
|
||||
struct tbl *vp;
|
||||
@ -293,8 +287,7 @@ local(n, copy)
|
||||
|
||||
/* get variable string value */
|
||||
char *
|
||||
str_val(vp)
|
||||
struct tbl *vp;
|
||||
str_val(struct tbl *vp)
|
||||
{
|
||||
char *s;
|
||||
|
||||
@ -342,8 +335,7 @@ str_val(vp)
|
||||
|
||||
/* get variable integer value, with error checking */
|
||||
long
|
||||
intval(vp)
|
||||
struct tbl *vp;
|
||||
intval(struct tbl *vp)
|
||||
{
|
||||
long num;
|
||||
int base;
|
||||
@ -357,10 +349,7 @@ intval(vp)
|
||||
|
||||
/* set variable to string value */
|
||||
int
|
||||
setstr(vq, s, error_ok)
|
||||
struct tbl *vq;
|
||||
const char *s;
|
||||
int error_ok;
|
||||
setstr(struct tbl *vq, const char *s, int error_ok)
|
||||
{
|
||||
int no_ro_check = error_ok & 0x4;
|
||||
error_ok &= ~0x4;
|
||||
@ -401,9 +390,7 @@ setstr(vq, s, error_ok)
|
||||
|
||||
/* set variable to integer */
|
||||
void
|
||||
setint(vq, n)
|
||||
struct tbl *vq;
|
||||
long n;
|
||||
setint(struct tbl *vq, long int n)
|
||||
{
|
||||
if (!(vq->flag&INTEGER)) {
|
||||
struct tbl *vp = &vtemp;
|
||||
@ -421,9 +408,7 @@ setint(vq, n)
|
||||
}
|
||||
|
||||
int
|
||||
getint(vp, nump)
|
||||
struct tbl *vp;
|
||||
long *nump;
|
||||
getint(struct tbl *vp, long int *nump)
|
||||
{
|
||||
char *s;
|
||||
int c;
|
||||
@ -480,8 +465,7 @@ getint(vp, nump)
|
||||
* (vq and vp may be the same)
|
||||
*/
|
||||
struct tbl *
|
||||
setint_v(vq, vp)
|
||||
struct tbl *vq, *vp;
|
||||
setint_v(struct tbl *vq, struct tbl *vp)
|
||||
{
|
||||
int base;
|
||||
long num;
|
||||
@ -502,9 +486,7 @@ setint_v(vq, vp)
|
||||
}
|
||||
|
||||
static char *
|
||||
formatstr(vp, s)
|
||||
struct tbl *vp;
|
||||
const char *s;
|
||||
formatstr(struct tbl *vp, const char *s)
|
||||
{
|
||||
int olen, nlen;
|
||||
char *p, *q;
|
||||
@ -566,9 +548,7 @@ formatstr(vp, s)
|
||||
* make vp->val.s be "name=value" for quick exporting.
|
||||
*/
|
||||
static void
|
||||
export(vp, val)
|
||||
struct tbl *vp;
|
||||
const char *val;
|
||||
export(struct tbl *vp, const char *val)
|
||||
{
|
||||
char *xp;
|
||||
char *op = (vp->flag&ALLOC) ? vp->val.s : NULL;
|
||||
@ -592,10 +572,7 @@ export(vp, val)
|
||||
* LCASEV, UCASEV_AL), and optionally set its value if an assignment.
|
||||
*/
|
||||
struct tbl *
|
||||
typeset(var, set, clr, field, base)
|
||||
const char *var;
|
||||
Tflag clr, set;
|
||||
int field, base;
|
||||
typeset(const char *var, Tflag set, Tflag clr, int field, int base)
|
||||
{
|
||||
struct tbl *vp;
|
||||
struct tbl *vpbase, *t;
|
||||
@ -746,9 +723,7 @@ typeset(var, set, clr, field, base)
|
||||
* the name lookup (eg, x[2]).
|
||||
*/
|
||||
void
|
||||
unset(vp, array_ref)
|
||||
struct tbl *vp;
|
||||
int array_ref;
|
||||
unset(struct tbl *vp, int array_ref)
|
||||
{
|
||||
if (vp->flag & ALLOC)
|
||||
afree((void*)vp->val.s, vp->areap);
|
||||
@ -776,9 +751,7 @@ unset(vp, array_ref)
|
||||
* null if whole string is legal).
|
||||
*/
|
||||
char *
|
||||
skip_varname(s, aok)
|
||||
const char *s;
|
||||
int aok;
|
||||
skip_varname(const char *s, int aok)
|
||||
{
|
||||
int alen;
|
||||
|
||||
@ -793,9 +766,9 @@ skip_varname(s, aok)
|
||||
|
||||
/* Return a pointer to the first character past any legal variable name. */
|
||||
char *
|
||||
skip_wdvarname(s, aok)
|
||||
const char *s;
|
||||
int aok; /* skip array de-reference? */
|
||||
skip_wdvarname(const char *s, int aok)
|
||||
|
||||
/* skip array de-reference? */
|
||||
{
|
||||
if (s[0] == CHAR && letter(s[1])) {
|
||||
do
|
||||
@ -826,9 +799,7 @@ skip_wdvarname(s, aok)
|
||||
|
||||
/* Check if coded string s is a variable name */
|
||||
int
|
||||
is_wdvarname(s, aok)
|
||||
const char *s;
|
||||
int aok;
|
||||
is_wdvarname(const char *s, int aok)
|
||||
{
|
||||
char *p = skip_wdvarname(s, aok);
|
||||
|
||||
@ -837,8 +808,7 @@ is_wdvarname(s, aok)
|
||||
|
||||
/* Check if coded string s is a variable assignment */
|
||||
int
|
||||
is_wdvarassign(s)
|
||||
const char *s;
|
||||
is_wdvarassign(const char *s)
|
||||
{
|
||||
char *p = skip_wdvarname(s, TRUE);
|
||||
|
||||
@ -849,7 +819,7 @@ is_wdvarassign(s)
|
||||
* Make the exported environment from the exported names in the dictionary.
|
||||
*/
|
||||
char **
|
||||
makenv()
|
||||
makenv(void)
|
||||
{
|
||||
struct block *l = e->loc;
|
||||
XPtrV env;
|
||||
@ -889,7 +859,7 @@ makenv()
|
||||
* Called after a fork in parent to bump the random number generator.
|
||||
*/
|
||||
void
|
||||
change_random()
|
||||
change_random(void)
|
||||
{
|
||||
rnd_seed(time(NULL) * getpid());
|
||||
}
|
||||
@ -900,8 +870,7 @@ change_random()
|
||||
|
||||
/* Test if name is a special parameter */
|
||||
static int
|
||||
special(name)
|
||||
const char * name;
|
||||
special(const char *name)
|
||||
{
|
||||
struct tbl *tp;
|
||||
|
||||
@ -911,8 +880,7 @@ special(name)
|
||||
|
||||
/* Make a variable non-special */
|
||||
static void
|
||||
unspecial(name)
|
||||
const char * name;
|
||||
unspecial(const char *name)
|
||||
{
|
||||
struct tbl *tp;
|
||||
|
||||
@ -927,8 +895,7 @@ static time_t seconds; /* time SECONDS last set */
|
||||
static int user_lineno; /* what user set $LINENO to */
|
||||
|
||||
static void
|
||||
getspec(vp)
|
||||
struct tbl *vp;
|
||||
getspec(struct tbl *vp)
|
||||
{
|
||||
switch (special(vp->name)) {
|
||||
#ifdef KSH
|
||||
@ -969,8 +936,7 @@ getspec(vp)
|
||||
}
|
||||
|
||||
static void
|
||||
setspec(vp)
|
||||
struct tbl *vp;
|
||||
setspec(struct tbl *vp)
|
||||
{
|
||||
char *s;
|
||||
|
||||
@ -1070,8 +1036,7 @@ setspec(vp)
|
||||
}
|
||||
|
||||
static void
|
||||
unsetspec(vp)
|
||||
struct tbl *vp;
|
||||
unsetspec(struct tbl *vp)
|
||||
{
|
||||
switch (special(vp->name)) {
|
||||
case V_PATH:
|
||||
@ -1129,9 +1094,7 @@ unsetspec(vp)
|
||||
* vp, indexed by val.
|
||||
*/
|
||||
static struct tbl *
|
||||
arraysearch(vp, val)
|
||||
struct tbl *vp;
|
||||
int val;
|
||||
arraysearch(struct tbl *vp, int val)
|
||||
{
|
||||
struct tbl *prev, *curr, *new;
|
||||
size_t namelen = strlen(vp->name) + 1;
|
||||
@ -1175,8 +1138,7 @@ arraysearch(vp, val)
|
||||
* bracket.
|
||||
*/
|
||||
int
|
||||
array_ref_len(cp)
|
||||
const char *cp;
|
||||
array_ref_len(const char *cp)
|
||||
{
|
||||
const char *s = cp;
|
||||
int c;
|
||||
@ -1194,8 +1156,7 @@ array_ref_len(cp)
|
||||
* Make a copy of the base of an array name
|
||||
*/
|
||||
char *
|
||||
arrayname(str)
|
||||
const char *str;
|
||||
arrayname(const char *str)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
@ -1209,10 +1170,7 @@ arrayname(str)
|
||||
/* Set (or overwrite, if !reset) the array variable var to the values in vals.
|
||||
*/
|
||||
void
|
||||
set_array(var, reset, vals)
|
||||
const char *var;
|
||||
int reset;
|
||||
char **vals;
|
||||
set_array(const char *var, int reset, char **vals)
|
||||
{
|
||||
struct tbl *vp, *vq;
|
||||
int i;
|
||||
|
141
vi.c
141
vi.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: vi.c,v 1.9 2004/10/28 11:11:19 tg Exp $ */
|
||||
/** $MirBSD: vi.c,v 1.10 2004/10/28 11:53:44 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: vi.c,v 1.9 2004/10/28 11:11:19 tg Exp $");
|
||||
__RCSID("$MirBSD: vi.c,v 1.10 2004/10/28 11:53:44 tg Exp $");
|
||||
|
||||
#define Ctrl(c) (c&0x1f)
|
||||
#define is_wordch(c) (letnum(c))
|
||||
@ -190,9 +190,7 @@ enum expand_mode { NONE, EXPAND, COMPLETE, PRINT };
|
||||
static enum expand_mode expanded = NONE;/* last input was expanded */
|
||||
|
||||
int
|
||||
x_vi(buf, len)
|
||||
char *buf;
|
||||
size_t len;
|
||||
x_vi(char *buf, size_t len)
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -252,8 +250,7 @@ x_vi(buf, len)
|
||||
}
|
||||
|
||||
static int
|
||||
vi_hook(ch)
|
||||
int ch;
|
||||
vi_hook(int ch)
|
||||
{
|
||||
static char curcmd[MAXVICMD];
|
||||
static char locpat[SRCHLEN];
|
||||
@ -550,9 +547,7 @@ vi_hook(ch)
|
||||
}
|
||||
|
||||
static void
|
||||
vi_reset(buf, len)
|
||||
char *buf;
|
||||
size_t len;
|
||||
vi_reset(char *buf, size_t len)
|
||||
{
|
||||
state = VNORMAL;
|
||||
ohnum = hnum = hlast = histnum(-1) + 1;
|
||||
@ -566,8 +561,7 @@ vi_reset(buf, len)
|
||||
}
|
||||
|
||||
static int
|
||||
nextstate(ch)
|
||||
int ch;
|
||||
nextstate(int ch)
|
||||
{
|
||||
if (is_extend(ch))
|
||||
return VEXTCMD;
|
||||
@ -586,8 +580,7 @@ nextstate(ch)
|
||||
}
|
||||
|
||||
static int
|
||||
vi_insert(ch)
|
||||
int ch;
|
||||
vi_insert(int ch)
|
||||
{
|
||||
int tcursor;
|
||||
|
||||
@ -719,9 +712,7 @@ vi_insert(ch)
|
||||
}
|
||||
|
||||
static int
|
||||
vi_cmd(argcnt, cmd)
|
||||
int argcnt;
|
||||
const char *cmd;
|
||||
vi_cmd(int argcnt, const char *cmd)
|
||||
{
|
||||
int ncursor;
|
||||
int cur, c1, c2, c3 = 0;
|
||||
@ -1172,10 +1163,7 @@ vi_cmd(argcnt, cmd)
|
||||
}
|
||||
|
||||
static int
|
||||
domove(argcnt, cmd, sub)
|
||||
int argcnt;
|
||||
const char *cmd;
|
||||
int sub;
|
||||
domove(int argcnt, const char *cmd, int sub)
|
||||
{
|
||||
int bcount, UNINITIALIZED(i), t;
|
||||
int UNINITIALIZED(ncursor);
|
||||
@ -1322,8 +1310,7 @@ domove(argcnt, cmd, sub)
|
||||
}
|
||||
|
||||
static int
|
||||
redo_insert(count)
|
||||
int count;
|
||||
redo_insert(int count)
|
||||
{
|
||||
while (count-- > 0)
|
||||
if (putbuf(ibuf, inslen, insert==REPLACE) != 0)
|
||||
@ -1335,8 +1322,7 @@ redo_insert(count)
|
||||
}
|
||||
|
||||
static void
|
||||
yank_range(a, b)
|
||||
int a, b;
|
||||
yank_range(int a, int b)
|
||||
{
|
||||
yanklen = b - a;
|
||||
if (yanklen != 0)
|
||||
@ -1344,8 +1330,7 @@ yank_range(a, b)
|
||||
}
|
||||
|
||||
static int
|
||||
bracktype(ch)
|
||||
int ch;
|
||||
bracktype(int ch)
|
||||
{
|
||||
switch (ch) {
|
||||
|
||||
@ -1390,7 +1375,7 @@ static char holdbuf[LINE]; /* place to hold last edit buffer */
|
||||
static int holdlen; /* length of holdbuf */
|
||||
|
||||
static void
|
||||
save_cbuf()
|
||||
save_cbuf(void)
|
||||
{
|
||||
memmove(holdbuf, es->cbuf, es->linelen);
|
||||
holdlen = es->linelen;
|
||||
@ -1398,7 +1383,7 @@ save_cbuf()
|
||||
}
|
||||
|
||||
static void
|
||||
restore_cbuf()
|
||||
restore_cbuf(void)
|
||||
{
|
||||
es->cursor = 0;
|
||||
es->linelen = holdlen;
|
||||
@ -1407,8 +1392,7 @@ restore_cbuf()
|
||||
|
||||
/* return a new edstate */
|
||||
static struct edstate *
|
||||
save_edstate(old)
|
||||
struct edstate *old;
|
||||
save_edstate(struct edstate *old)
|
||||
{
|
||||
struct edstate *new;
|
||||
|
||||
@ -1423,8 +1407,7 @@ save_edstate(old)
|
||||
}
|
||||
|
||||
static void
|
||||
restore_edstate(new, old)
|
||||
struct edstate *old, *new;
|
||||
restore_edstate(struct edstate *new, struct edstate *old)
|
||||
{
|
||||
memcpy(new->cbuf, old->cbuf, old->linelen);
|
||||
new->linelen = old->linelen;
|
||||
@ -1434,8 +1417,7 @@ restore_edstate(new, old)
|
||||
}
|
||||
|
||||
static void
|
||||
free_edstate(old)
|
||||
struct edstate *old;
|
||||
free_edstate(struct edstate *old)
|
||||
{
|
||||
afree(old->cbuf, APERM);
|
||||
afree((char *)old, APERM);
|
||||
@ -1444,9 +1426,7 @@ free_edstate(old)
|
||||
|
||||
|
||||
static void
|
||||
edit_reset(buf, len)
|
||||
char *buf;
|
||||
size_t len;
|
||||
edit_reset(char *buf, size_t len)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
@ -1486,18 +1466,13 @@ edit_reset(buf, len)
|
||||
* this is used for calling x_escape() in complete_word()
|
||||
*/
|
||||
static int
|
||||
x_vi_putbuf(s, len)
|
||||
const char *s;
|
||||
size_t len;
|
||||
x_vi_putbuf(const char *s, size_t len)
|
||||
{
|
||||
return putbuf(s, len, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
putbuf(buf, len, repl)
|
||||
const char *buf;
|
||||
int len;
|
||||
int repl;
|
||||
putbuf(const char *buf, int len, int repl)
|
||||
{
|
||||
if (len == 0)
|
||||
return 0;
|
||||
@ -1519,8 +1494,7 @@ putbuf(buf, len, repl)
|
||||
}
|
||||
|
||||
static void
|
||||
del_range(a, b)
|
||||
int a, b;
|
||||
del_range(int a, int b)
|
||||
{
|
||||
if (es->linelen != b)
|
||||
memmove(&es->cbuf[a], &es->cbuf[b], es->linelen - b);
|
||||
@ -1528,11 +1502,7 @@ del_range(a, b)
|
||||
}
|
||||
|
||||
static int
|
||||
findch(ch, cnt, forw, incl)
|
||||
int ch;
|
||||
int cnt;
|
||||
int forw;
|
||||
int incl;
|
||||
findch(int ch, int cnt, int forw, int incl)
|
||||
{
|
||||
int ncursor;
|
||||
|
||||
@ -1560,8 +1530,7 @@ findch(ch, cnt, forw, incl)
|
||||
}
|
||||
|
||||
static int
|
||||
forwword(argcnt)
|
||||
int argcnt;
|
||||
forwword(int argcnt)
|
||||
{
|
||||
int ncursor;
|
||||
|
||||
@ -1583,8 +1552,7 @@ forwword(argcnt)
|
||||
}
|
||||
|
||||
static int
|
||||
backword(argcnt)
|
||||
int argcnt;
|
||||
backword(int argcnt)
|
||||
{
|
||||
int ncursor;
|
||||
|
||||
@ -1609,8 +1577,7 @@ backword(argcnt)
|
||||
}
|
||||
|
||||
static int
|
||||
endword(argcnt)
|
||||
int argcnt;
|
||||
endword(int argcnt)
|
||||
{
|
||||
int ncursor;
|
||||
|
||||
@ -1636,8 +1603,7 @@ endword(argcnt)
|
||||
}
|
||||
|
||||
static int
|
||||
Forwword(argcnt)
|
||||
int argcnt;
|
||||
Forwword(int argcnt)
|
||||
{
|
||||
int ncursor;
|
||||
|
||||
@ -1652,8 +1618,7 @@ Forwword(argcnt)
|
||||
}
|
||||
|
||||
static int
|
||||
Backword(argcnt)
|
||||
int argcnt;
|
||||
Backword(int argcnt)
|
||||
{
|
||||
int ncursor;
|
||||
|
||||
@ -1669,8 +1634,7 @@ Backword(argcnt)
|
||||
}
|
||||
|
||||
static int
|
||||
Endword(argcnt)
|
||||
int argcnt;
|
||||
Endword(int argcnt)
|
||||
{
|
||||
int ncursor;
|
||||
|
||||
@ -1690,9 +1654,7 @@ Endword(argcnt)
|
||||
}
|
||||
|
||||
static int
|
||||
grabhist(save, n)
|
||||
int save;
|
||||
int n;
|
||||
grabhist(int save, int n)
|
||||
{
|
||||
char *hptr;
|
||||
|
||||
@ -1719,9 +1681,7 @@ grabhist(save, n)
|
||||
}
|
||||
|
||||
static int
|
||||
grabsearch(save, start, fwd, pat)
|
||||
int save, start, fwd;
|
||||
char *pat;
|
||||
grabsearch(int save, int start, int fwd, char *pat)
|
||||
{
|
||||
char *hptr;
|
||||
int hist;
|
||||
@ -1755,8 +1715,7 @@ grabsearch(save, start, fwd, pat)
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_line(newline)
|
||||
int newline;
|
||||
redraw_line(int newline)
|
||||
{
|
||||
(void) memset(wbuf[win], ' ', wbuf_len);
|
||||
if (newline) {
|
||||
@ -1769,8 +1728,7 @@ redraw_line(newline)
|
||||
}
|
||||
|
||||
static void
|
||||
refresh(leftside)
|
||||
int leftside;
|
||||
refresh(int leftside)
|
||||
{
|
||||
if (leftside < 0)
|
||||
leftside = lastref;
|
||||
@ -1783,7 +1741,7 @@ refresh(leftside)
|
||||
}
|
||||
|
||||
static int
|
||||
outofwin()
|
||||
outofwin(void)
|
||||
{
|
||||
int cur, col;
|
||||
|
||||
@ -1799,7 +1757,7 @@ outofwin()
|
||||
}
|
||||
|
||||
static void
|
||||
rewindow()
|
||||
rewindow(void)
|
||||
{
|
||||
int tcur, tcol;
|
||||
int holdcur1, holdcol1;
|
||||
@ -1823,8 +1781,7 @@ rewindow()
|
||||
}
|
||||
|
||||
static int
|
||||
newcol(ch, col)
|
||||
int ch, col;
|
||||
newcol(int ch, int col)
|
||||
{
|
||||
if (ch == '\t')
|
||||
return (col | 7) + 1;
|
||||
@ -1832,9 +1789,7 @@ newcol(ch, col)
|
||||
}
|
||||
|
||||
static void
|
||||
display(wb1, wb2, leftside)
|
||||
char *wb1, *wb2;
|
||||
int leftside;
|
||||
display(char *wb1, char *wb2, int leftside)
|
||||
{
|
||||
unsigned char ch;
|
||||
char *twb1, *twb2, mc;
|
||||
@ -1927,9 +1882,7 @@ display(wb1, wb2, leftside)
|
||||
}
|
||||
|
||||
static void
|
||||
ed_mov_opt(col, wb)
|
||||
int col;
|
||||
char *wb;
|
||||
ed_mov_opt(int col, char *wb)
|
||||
{
|
||||
if (col < cur_col) {
|
||||
if (col + 1 < cur_col - col) {
|
||||
@ -1953,8 +1906,7 @@ ed_mov_opt(col, wb)
|
||||
|
||||
/* replace word with all expansions (ie, expand word*) */
|
||||
static int
|
||||
expand_word(command)
|
||||
int command;
|
||||
expand_word(int command)
|
||||
{
|
||||
static struct edstate *buf;
|
||||
int rval = 0;
|
||||
@ -2008,9 +1960,7 @@ expand_word(command)
|
||||
}
|
||||
|
||||
static int
|
||||
complete_word(command, count)
|
||||
int command;
|
||||
int count;
|
||||
complete_word(int command, int count)
|
||||
{
|
||||
static struct edstate *buf;
|
||||
int rval = 0;
|
||||
@ -2139,8 +2089,7 @@ print_expansions(struct edstate *e, int command GCC_FUNC_ATTR(unused))
|
||||
|
||||
/* How long is char when displayed (not counting tabs) */
|
||||
static int
|
||||
char_len(c)
|
||||
int c;
|
||||
char_len(int c)
|
||||
{
|
||||
int len = 1;
|
||||
|
||||
@ -2155,8 +2104,7 @@ char_len(c)
|
||||
|
||||
/* Similar to x_zotc(emacs.c), but no tab weirdness */
|
||||
static void
|
||||
x_vi_zotc(c)
|
||||
int c;
|
||||
x_vi_zotc(int c)
|
||||
{
|
||||
if (Flag(FVISHOW8) && (c & 0x80)) {
|
||||
x_puts("M-");
|
||||
@ -2170,14 +2118,13 @@ x_vi_zotc(c)
|
||||
}
|
||||
|
||||
static void
|
||||
vi_pprompt(full)
|
||||
int full;
|
||||
vi_pprompt(int full)
|
||||
{
|
||||
pprompt(prompt + (full ? 0 : prompt_skip), prompt_trunc);
|
||||
}
|
||||
|
||||
static void
|
||||
vi_error()
|
||||
vi_error(void)
|
||||
{
|
||||
/* Beem out of any macros as soon as an error occurs */
|
||||
vi_macro_reset();
|
||||
@ -2186,7 +2133,7 @@ vi_error()
|
||||
}
|
||||
|
||||
static void
|
||||
vi_macro_reset()
|
||||
vi_macro_reset(void)
|
||||
{
|
||||
if (macro.p) {
|
||||
afree(macro.buf, APERM);
|
||||
|
Loading…
x
Reference in New Issue
Block a user