summaryrefslogtreecommitdiff
path: root/bin/ksh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ksh')
-rw-r--r--bin/ksh/c_ksh.c53
-rw-r--r--bin/ksh/c_sh.c60
-rw-r--r--bin/ksh/c_test.c89
-rw-r--r--bin/ksh/c_test.h18
-rw-r--r--bin/ksh/c_ulimit.c5
-rw-r--r--bin/ksh/edit.c123
-rw-r--r--bin/ksh/edit.h31
-rw-r--r--bin/ksh/emacs.c324
-rw-r--r--bin/ksh/eval.c113
-rw-r--r--bin/ksh/exec.c138
-rw-r--r--bin/ksh/expr.c57
-rw-r--r--bin/ksh/history.c109
-rw-r--r--bin/ksh/io.c63
-rw-r--r--bin/ksh/jobs.c108
-rw-r--r--bin/ksh/lex.c70
-rw-r--r--bin/ksh/mail.c29
-rw-r--r--bin/ksh/main.c39
-rw-r--r--bin/ksh/misc.c145
-rw-r--r--bin/ksh/path.c31
-rw-r--r--bin/ksh/proto.h371
-rw-r--r--bin/ksh/shf.c93
-rw-r--r--bin/ksh/shf.h44
-rw-r--r--bin/ksh/syn.c134
-rw-r--r--bin/ksh/table.c53
-rw-r--r--bin/ksh/tree.c67
-rw-r--r--bin/ksh/tty.c7
-rw-r--r--bin/ksh/tty.h4
-rw-r--r--bin/ksh/var.c123
-rw-r--r--bin/ksh/vi.c209
29 files changed, 975 insertions, 1735 deletions
diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c
index 86ed3f07ab0..4a5a41078dd 100644
--- a/bin/ksh/c_ksh.c
+++ b/bin/ksh/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.22 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.23 2004/12/20 11:34:26 otto Exp $ */
/*
* built-in Korn commands: c_*
@@ -10,8 +10,7 @@
int
-c_cd(wp)
- char **wp;
+c_cd(char **wp)
{
int optc;
int physical = Flag(FPHYSICAL);
@@ -155,8 +154,7 @@ c_cd(wp)
}
int
-c_pwd(wp)
- char **wp;
+c_pwd(char **wp)
{
int optc;
int physical = Flag(FPHYSICAL);
@@ -196,8 +194,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 */
@@ -391,8 +388,7 @@ c_print(wp)
}
int
-c_whence(wp)
- char **wp;
+c_whence(char **wp)
{
struct tbl *tp;
char *id;
@@ -514,8 +510,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()).
@@ -525,8 +520,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;
@@ -822,8 +816,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;
@@ -958,8 +951,7 @@ c_alias(wp)
}
int
-c_unalias(wp)
- char **wp;
+c_unalias(char **wp)
{
struct table *t = &aliases;
struct tbl *ap;
@@ -1011,8 +1003,7 @@ c_unalias(wp)
}
int
-c_let(wp)
- char **wp;
+c_let(char **wp)
{
int rv = 1;
long val;
@@ -1030,8 +1021,7 @@ c_let(wp)
}
int
-c_jobs(wp)
- char **wp;
+c_jobs(char **wp)
{
int optc;
int flag = 0;
@@ -1069,8 +1059,7 @@ c_jobs(wp)
#ifdef JOBS
int
-c_fgbg(wp)
- char **wp;
+c_fgbg(char **wp)
{
int bg = strcmp(*wp, "bg") == 0;
int rv = 0;
@@ -1102,11 +1091,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;
@@ -1126,8 +1111,7 @@ kill_fmt_entry(arg, i, buf, buflen)
int
-c_kill(wp)
- char **wp;
+c_kill(char **wp)
{
Trap *t = (Trap *) 0;
char *p;
@@ -1236,8 +1220,7 @@ c_kill(wp)
}
void
-getopts_reset(val)
- int val;
+getopts_reset(int val)
{
if (val >= 1) {
ksh_getopt_reset(&user_opt,
@@ -1247,8 +1230,7 @@ getopts_reset(val)
}
int
-c_getopts(wp)
- char **wp;
+c_getopts(char **wp)
{
int argc;
const char *options;
@@ -1347,8 +1329,7 @@ c_getopts(wp)
#ifdef EMACS
int
-c_bind(wp)
- char **wp;
+c_bind(char **wp)
{
int optc, rv = 0, macro = 0, list = 0;
char *cp;
diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c
index 8f20fa51a2d..252a83de13b 100644
--- a/bin/ksh/c_sh.c
+++ b/bin/ksh/c_sh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_sh.c,v 1.22 2004/12/19 01:58:04 millert Exp $ */
+/* $OpenBSD: c_sh.c,v 1.23 2004/12/20 11:34:26 otto Exp $ */
/*
* built-in Bourne commands
@@ -8,20 +8,18 @@
#include <sys/stat.h> /* umask() */
#include <sys/times.h>
-static char *clocktos(clock_t t);
+static char *clocktos(clock_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;
@@ -52,8 +50,7 @@ c_shift(wp)
}
int
-c_umask(wp)
- char **wp;
+c_umask(char **wp)
{
int i;
char *cp;
@@ -172,8 +169,7 @@ c_umask(wp)
}
int
-c_dot(wp)
- char **wp;
+c_dot(char **wp)
{
char *file, *cp;
char **argv;
@@ -211,8 +207,7 @@ c_dot(wp)
}
int
-c_wait(wp)
- char **wp;
+c_wait(char **wp)
{
int rv = 0;
int sig;
@@ -234,8 +229,7 @@ c_wait(wp)
}
int
-c_read(wp)
- char **wp;
+c_read(char **wp)
{
int c = 0;
int expand = 1, history = 0;
@@ -410,8 +404,7 @@ c_read(wp)
}
int
-c_eval(wp)
- char **wp;
+c_eval(char **wp)
{
struct source *s;
@@ -451,8 +444,7 @@ c_eval(wp)
}
int
-c_trap(wp)
- char **wp;
+c_trap(char **wp)
{
int i;
char *s;
@@ -511,8 +503,7 @@ c_trap(wp)
}
int
-c_exitreturn(wp)
- char **wp;
+c_exitreturn(char **wp)
{
int how = LEXIT;
int n;
@@ -554,8 +545,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;
@@ -608,8 +598,7 @@ c_brkcont(wp)
}
int
-c_set(wp)
- char **wp;
+c_set(char **wp)
{
int argi, setargs;
struct block *l = e->loc;
@@ -644,8 +633,7 @@ c_set(wp)
}
int
-c_unset(wp)
- char **wp;
+c_unset(char **wp)
{
char *id;
int optc, unset_var = 1;
@@ -682,8 +670,7 @@ c_unset(wp)
}
int
-c_times(wp)
- char **wp;
+c_times(char **wp)
{
struct tms all;
@@ -700,9 +687,7 @@ c_times(wp)
* 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 */
@@ -757,9 +742,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;
@@ -792,8 +775,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;
@@ -818,8 +800,7 @@ clocktos(t)
/* exec with no args - args case is taken care of in comexec() */
int
-c_exec(wp)
- char ** wp;
+c_exec(char **wp)
{
int i;
@@ -844,8 +825,7 @@ c_exec(wp)
/* dummy function, special case in comexec() */
int
-c_builtin(wp)
- char ** wp;
+c_builtin(char **wp)
{
return 0;
}
diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c
index ce859d0b21d..cec44612c25 100644
--- a/bin/ksh/c_test.c
+++ b/bin/ksh/c_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.c,v 1.12 2004/12/18 21:04:52 millert Exp $ */
+/* $OpenBSD: c_test.c,v 1.13 2004/12/20 11:34:26 otto Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@@ -85,21 +85,20 @@ static const struct t_op b_ops [] = {
{"", TO_NONOP }
};
-static int test_stat(const char *path, struct stat *statb);
-static int test_eaccess(const char *path, int mode);
-static int test_oexpr(Test_env *te, int do_eval);
-static int test_aexpr(Test_env *te, int do_eval);
-static int test_nexpr(Test_env *te, int do_eval);
-static int test_primary(Test_env *te, int do_eval);
-static int ptest_isa(Test_env *te, Test_meta meta);
-static const char *ptest_getopnd(Test_env *te, Test_op op, int do_eval);
-static int ptest_eval(Test_env *te, Test_op op, const char *opnd1,
- const char *opnd2, int do_eval);
-static void ptest_error(Test_env *te, int offset, const char *msg);
+static int test_stat(const char *, struct stat *);
+static int test_eaccess(const char *, int);
+static int test_oexpr(Test_env *, int);
+static int test_aexpr(Test_env *, int);
+static int test_nexpr(Test_env *, int);
+static int test_primary(Test_env *, int);
+static int ptest_isa(Test_env *, Test_meta);
+static const char *ptest_getopnd(Test_env *, Test_op, int);
+static int ptest_eval(Test_env *, Test_op, const char *,
+ const char *, int);
+static void ptest_error(Test_env *, int, const char *);
int
-c_test(wp)
- char **wp;
+c_test(char **wp)
{
int argc;
int res;
@@ -183,10 +182,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;
@@ -206,12 +202,8 @@ 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;
@@ -369,9 +361,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)
{
return stat(path, statb);
}
@@ -380,9 +370,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;
@@ -407,8 +395,7 @@ test_eaccess(path, mode)
}
int
-test_parse(te)
- Test_env *te;
+test_parse(Test_env *te)
{
int res;
@@ -421,9 +408,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;
@@ -436,9 +421,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;
@@ -451,9 +434,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);
@@ -461,9 +442,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;
@@ -522,9 +501,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[] = {
@@ -550,10 +527,7 @@ ptest_isa(te, meta)
}
static const char *
-ptest_getopnd(te, op, do_eval)
- Test_env *te;
- Test_op op;
- int do_eval;
+ptest_getopnd(Test_env *te, Test_op op, int do_eval)
{
if (te->pos.wp >= te->wp_end)
return op == TO_FILTT ? "1" : (const char *) 0;
@@ -561,21 +535,14 @@ ptest_getopnd(te, op, do_eval)
}
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];
diff --git a/bin/ksh/c_test.h b/bin/ksh/c_test.h
index 33df5721a8e..8b569e04b51 100644
--- a/bin/ksh/c_test.h
+++ b/bin/ksh/c_test.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.h,v 1.3 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* Various types of operations. Keeping things grouped nicely
* (unary,binary) makes switch() statements more efficient.
@@ -42,14 +42,12 @@ struct test_env {
XPtrV *av; /* used by dbtestp_* */
} pos;
char **wp_end; /* used by ptest_* */
- int (*isa)(Test_env *te, Test_meta meta);
- const char *(*getopnd) (Test_env *te, Test_op op, int do_eval);
- int (*eval)(Test_env *te, Test_op op, const char *opnd1,
- const char *opnd2, int do_eval);
- void (*error)(Test_env *te, int offset, const char *msg);
+ int (*isa)(Test_env *, Test_meta);
+ const char *(*getopnd) (Test_env *, Test_op, int);
+ int (*eval)(Test_env *, Test_op, const char *, const char *, int);
+ void (*error)(Test_env *, int, const char *);
};
-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);
+Test_op test_isop(Test_env *, Test_meta, const char *);
+int test_eval(Test_env *, Test_op, const char *, const char *, int);
+int test_parse(Test_env *);
diff --git a/bin/ksh/c_ulimit.c b/bin/ksh/c_ulimit.c
index 43b9cb8c1d4..96a1180060d 100644
--- a/bin/ksh/c_ulimit.c
+++ b/bin/ksh/c_ulimit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ulimit.c,v 1.11 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: c_ulimit.c,v 1.12 2004/12/20 11:34:26 otto Exp $ */
/*
ulimit -- handle "ulimit" builtin
@@ -25,8 +25,7 @@
#define HARD 0x2
int
-c_ulimit(wp)
- char **wp;
+c_ulimit(char **wp)
{
static const struct limits {
const char *name;
diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c
index 5095ec9fbcb..c70c657e0fd 100644
--- a/bin/ksh/edit.c
+++ b/bin/ksh/edit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.c,v 1.24 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: edit.c,v 1.25 2004/12/20 11:34:26 otto Exp $ */
/*
* Command line editing - common code
@@ -19,21 +19,18 @@
#include <sys/stat.h>
-static void x_sigwinch(int sig);
+static void x_sigwinch(int);
static volatile sig_atomic_t got_sigwinch;
static void check_sigwinch(void);
-static int x_file_glob(int flags, const char *str, int slen,
- char ***wordsp);
-static int x_command_glob(int flags, const char *str, int slen,
- char ***wordsp);
-static int x_locate_word(const char *buf, int buflen, int pos,
- int *startp, int *is_command);
+static int x_file_glob(int, const char *, int, char ***);
+static int x_command_glob(int, const char *, int, char ***);
+static int x_locate_word(const char *, int, int, int *, int *);
/* Called from main */
void
-x_init()
+x_init(void)
{
/* set to -2 to force initial binding */
edchars.erase = edchars.kill = edchars.intr = edchars.quit
@@ -52,8 +49,7 @@ x_init()
}
static void
-x_sigwinch(sig)
- int sig;
+x_sigwinch(int sig)
{
got_sigwinch = 1;
}
@@ -92,9 +88,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;
@@ -120,7 +114,7 @@ x_read(buf, len)
/* tty I/O */
int
-x_getc()
+x_getc(void)
{
char c;
int n;
@@ -137,29 +131,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;
@@ -219,8 +210,7 @@ x_mode(onoff)
}
void
-set_editmode(ed)
- const char *ed;
+set_editmode(const char *ed)
{
static const enum sh_flag edit_flags[] = {
#ifdef EMACS
@@ -254,10 +244,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;
@@ -310,12 +297,8 @@ static void glob_path(int flags, const char *pat, XPtrV *wp,
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;
+x_complete_word(const char *str, int slen, int is_command, int *multiple,
+ char **ret)
{
int nwords;
int prefix_len;
@@ -337,10 +320,7 @@ x_complete_word(str, slen, is_command, nwordsp, ret)
#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;
@@ -394,11 +374,7 @@ x_print_expansions(nwords, words, is_command)
* - returns number of matching strings
*/
static int
-x_file_glob(flags, str, slen, wordsp)
- int flags;
- const char *str;
- int slen;
- char ***wordsp;
+x_file_glob(int flags, const char *str, int slen, char ***wordsp)
{
char *toglob;
char **words;
@@ -481,9 +457,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;
@@ -494,11 +468,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;
@@ -592,12 +562,8 @@ 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;
@@ -649,15 +615,8 @@ 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;
@@ -693,9 +652,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;
@@ -734,9 +691,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;
@@ -756,9 +711,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;
@@ -781,9 +734,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;
@@ -808,10 +759,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;
@@ -823,11 +771,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;
@@ -897,10 +841,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));
diff --git a/bin/ksh/edit.h b/bin/ksh/edit.h
index 126e4ea17ca..82c0b8ed31b 100644
--- a/bin/ksh/edit.h
+++ b/bin/ksh/edit.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: edit.h,v 1.5 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: edit.h,v 1.6 2004/12/20 11:34:26 otto Exp $ */
/* NAME:
* edit.h - globals for edit modes
@@ -46,24 +46,23 @@ EXTERN X_chars edchars;
/* edit.c */
int x_getc(void);
void x_flush(void);
-void x_putc(int c);
-void x_puts(const char *s);
-bool_t x_mode(bool_t onoff);
-int promptlen(const char *cp, const char **spp);
-int x_do_comment(char *buf, int bsize, int *lenp);
-void x_print_expansions(int nwords, char *const *words, int is_command);
-int x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp,
- int *endp, char ***wordsp, int *is_commandp);
-int x_longest_prefix(int nwords, char *const *words);
-int x_basename(const char *s, const char *se);
-void x_free_words(int nwords, char **words);
-int x_escape(const char *, size_t, int (*)(const char *s, size_t len));
+void x_putc(int);
+void x_puts(const char *);
+bool_t x_mode(bool_t);
+int promptlen(const char *, const char **);
+int x_do_comment(char *, int, int *);
+void x_print_expansions(int, char *const *, int);
+int x_cf_glob(int, const char *, int, int, int *, int *, char ***, int *);
+int x_longest_prefix(int , char *const *);
+int x_basename(const char *, const char *);
+void x_free_words(int, char **);
+int x_escape(const char *, size_t, int (*)(const char *, size_t));
/* emacs.c */
-int x_emacs(char *buf, size_t len);
+int x_emacs(char *, size_t);
void x_init_emacs(void);
-void x_emacs_keys(X_chars *ec);
+void x_emacs_keys(X_chars *);
/* vi.c */
-int x_vi(char *buf, size_t len);
+int x_vi(char *, size_t);
#ifdef DEBUG
diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c
index 06a99627a2d..27a0ea623c6 100644
--- a/bin/ksh/emacs.c
+++ b/bin/ksh/emacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emacs.c,v 1.31 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: emacs.c,v 1.32 2004/12/20 11:34:26 otto Exp $ */
/*
* Emacs-like command line editing and history
@@ -109,34 +109,34 @@ static int x_curprefix;
static char *macroptr;
static int prompt_skip;
-static int x_ins(char *cp);
-static void x_delete(int nc, int push);
+static int x_ins(char *);
+static void x_delete(int, int);
static int x_bword(void);
static int x_fword(void);
-static void x_goto(char *cp);
-static void x_bs(int c);
-static int x_size_str(char *cp);
-static int x_size(int c);
-static void x_zots(char *str);
-static void x_zotc(int c);
-static void x_load_hist(char **hp);
-static int x_search(char *pat, int sameline, int offset);
-static int x_match(char *str, char *pat);
-static void x_redraw(int limit);
-static void x_push(int nchars);
-static char * x_mapin(const char *cp);
-static char * x_mapout(int c);
-static void x_print(int prefix, int key);
+static void x_goto(char *);
+static void x_bs(int);
+static int x_size_str(char *);
+static int x_size(int);
+static void x_zots(char *);
+static void x_zotc(int);
+static void x_load_hist(char **);
+static int x_search(char *, int, int);
+static int x_match(char *, char *);
+static void x_redraw(int);
+static void x_push(int);
+static char * x_mapin(const char *);
+static char * x_mapout(int);
+static void x_print(int, int);
static void x_adjust(void);
-static void x_e_ungetc(int c);
+static void x_e_ungetc(int);
static int x_e_getc(void);
-static void x_e_putc(int c);
-static void x_e_puts(const char *s);
-static int x_comment(int c);
-static int x_fold_case(int c);
+static void x_e_putc(int);
+static void x_e_puts(const char *);
+static int x_comment(int);
+static int x_fold_case(int);
static char *x_lastcp(void);
-static void do_complete(int flags, Comp_type type);
-static int x_emacs_putbuf(const char *s, size_t len);
+static void do_complete(int, Comp_type);
+static int x_emacs_putbuf(const char *, size_t);
/* The lines between START-FUNC-TAB .. END-FUNC-TAB are run through a
@@ -307,9 +307,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;
@@ -380,8 +378,7 @@ x_emacs(buf, len)
}
static int
-x_insert(c)
- int c;
+x_insert(int c)
{
char str[2];
@@ -400,8 +397,7 @@ x_insert(c)
}
static int
-x_ins_string(c)
- int c;
+x_ins_string(int c)
{
if (macroptr) {
x_e_putc(BEL);
@@ -418,9 +414,7 @@ x_ins_string(c)
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);
@@ -435,8 +429,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;
@@ -466,9 +459,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;
@@ -478,8 +469,7 @@ x_emacs_putbuf(s, len)
}
static int
-x_del_back(c)
- int c;
+x_del_back(int c)
{
int col = xcp - xbuf;
@@ -495,8 +485,7 @@ x_del_back(c)
}
static int
-x_del_char(c)
- int c;
+x_del_char(int c)
{
int nleft = xep - xcp;
@@ -512,9 +501,7 @@ x_del_char(c)
/* 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;
@@ -569,39 +556,35 @@ x_delete(nc, push)
}
static int
-x_del_bword(c)
- int c;
+x_del_bword(int c)
{
x_delete(x_bword(), TRUE);
return KSTD;
}
static int
-x_mv_bword(c)
- int c;
+x_mv_bword(int c)
{
(void)x_bword();
return KSTD;
}
static int
-x_mv_fword(c)
- int c;
+x_mv_fword(int c)
{
x_goto(xcp + x_fword());
return KSTD;
}
static int
-x_del_fword(c)
- int c;
+x_del_fword(int c)
{
x_delete(x_fword(), TRUE);
return KSTD;
}
static int
-x_bword()
+x_bword(void)
{
int nc = 0;
char *cp = xcp;
@@ -628,7 +611,7 @@ x_bword()
}
static int
-x_fword()
+x_fword(void)
{
int nc = 0;
char *cp = xcp;
@@ -654,8 +637,7 @@ x_fword()
}
static void
-x_goto(cp)
- char *cp;
+x_goto(char *cp)
{
if (cp < xbp || cp >= (xbp + x_displen))
{
@@ -682,8 +664,7 @@ x_goto(cp)
}
static void
-x_bs(c)
- int c;
+x_bs(int c)
{
int i;
i = x_size(c);
@@ -692,8 +673,7 @@ x_bs(c)
}
static int
-x_size_str(cp)
- char *cp;
+x_size_str(char *cp)
{
int size = 0;
while (*cp)
@@ -702,8 +682,7 @@ x_size_str(cp)
}
static int
-x_size(c)
- int c;
+x_size(int c)
{
if (c=='\t')
return 4; /* Kludge, tabs are always four spaces. */
@@ -713,8 +692,7 @@ x_size(c)
}
static void
-x_zots(str)
- char *str;
+x_zots(char *str)
{
int adj = x_adj_done;
@@ -724,8 +702,7 @@ x_zots(str)
}
static void
-x_zotc(c)
- int c;
+x_zotc(int c)
{
if (c == '\t') {
/* Kludge, tabs are always four spaces. */
@@ -738,8 +715,7 @@ x_zotc(c)
}
static int
-x_mv_back(c)
- int c;
+x_mv_back(int c)
{
int col = xcp - xbuf;
@@ -754,8 +730,7 @@ x_mv_back(c)
}
static int
-x_mv_forw(c)
- int c;
+x_mv_forw(int c)
{
int nleft = xep - xcp;
@@ -770,8 +745,7 @@ x_mv_forw(c)
}
static int
-x_search_char_forw(c)
- int c;
+x_search_char_forw(int c)
{
char *cp = xcp;
@@ -791,8 +765,7 @@ x_search_char_forw(c)
}
static int
-x_search_char_back(c)
- int c;
+x_search_char_back(int c)
{
char *cp = xcp, *p;
@@ -813,8 +786,7 @@ x_search_char_back(c)
}
static int
-x_newline(c)
- int c;
+x_newline(int c)
{
x_e_putc('\r');
x_e_putc('\n');
@@ -824,27 +796,25 @@ x_newline(c)
}
static int
-x_end_of_text(c)
- int c;
+x_end_of_text(int c)
{
return KEOL;
}
-static int x_beg_hist(c) int c; { x_load_hist(history); return KSTD;}
+static int x_beg_hist(int c) { x_load_hist(history); return KSTD;}
-static int x_end_hist(c) int c; { x_load_hist(histptr); return KSTD;}
+static int x_end_hist(int c) { x_load_hist(histptr); return KSTD;}
-static int x_prev_com(c) int c; { x_load_hist(x_histp - x_arg); return KSTD;}
+static int x_prev_com(int c) { x_load_hist(x_histp - x_arg); return KSTD;}
-static int x_next_com(c) int c; { x_load_hist(x_histp + x_arg); return KSTD;}
+static int x_next_com(int c) { x_load_hist(x_histp + x_arg); return KSTD;}
/* Goto a particular history number obtained from argument.
* If no argument is given history 1 is probably not what you
* want so we'll simply go to the oldest one.
*/
static int
-x_goto_hist(c)
- int c;
+x_goto_hist(int c)
{
if (x_arg_defaulted)
x_load_hist(history);
@@ -854,8 +824,7 @@ x_goto_hist(c)
}
static void
-x_load_hist(hp)
- char **hp;
+x_load_hist(char **hp)
{
int oldsize;
@@ -876,16 +845,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));
@@ -895,8 +862,7 @@ x_eot_del(c)
/* reverse incremental history search */
static int
-x_search_hist(c)
- int c;
+x_search_hist(int c)
{
int offset = -1; /* offset of match in xbuf, else -1 */
char pat [256+1]; /* pattern buffer */
@@ -958,10 +924,7 @@ x_search_hist(c)
/* 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;
@@ -983,8 +946,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;
@@ -995,8 +957,7 @@ x_match(str, pat)
}
static int
-x_del_line(c)
- int c;
+x_del_line(int c)
{
int i, j;
@@ -1014,24 +975,21 @@ x_del_line(c)
}
static int
-x_mv_end(c)
- int c;
+x_mv_end(int c)
{
x_goto(xep);
return KSTD;
}
static int
-x_mv_begin(c)
- int c;
+x_mv_begin(int c)
{
x_goto(xbuf);
return KSTD;
}
static int
-x_draw_line(c)
- int c;
+x_draw_line(int c)
{
x_redraw(-1);
return KSTD;
@@ -1043,8 +1001,7 @@ x_draw_line(c)
* redrawing.
*/
static void
-x_redraw(limit)
- int limit;
+x_redraw(int limit)
{
int i, j;
char *cp;
@@ -1099,8 +1056,7 @@ x_redraw(limit)
}
static int
-x_transpose(c)
- int c;
+x_transpose(int c)
{
char tmp;
@@ -1152,32 +1108,28 @@ x_transpose(c)
}
static int
-x_literal(c)
- int c;
+x_literal(int c)
{
x_curprefix = -1;
return KSTD;
}
static int
-x_meta1(c)
- int c;
+x_meta1(int c)
{
x_curprefix = 1;
return KSTD;
}
static int
-x_meta2(c)
- int c;
+x_meta2(int c)
{
x_curprefix = 2;
return KSTD;
}
static int
-x_kill(c)
- int c;
+x_kill(int c)
{
int col = xcp - xbuf;
int lastcol = xep - xbuf;
@@ -1197,8 +1149,7 @@ x_kill(c)
}
static void
-x_push(nchars)
- int nchars;
+x_push(int nchars)
{
char *cp = str_nsave(xcp, nchars, AEDIT);
if (killstack[killsp])
@@ -1208,8 +1159,7 @@ x_push(nchars)
}
static int
-x_yank(c)
- int c;
+x_yank(int c)
{
if (killsp == 0)
killtp = KILLSIZE;
@@ -1227,8 +1177,7 @@ x_yank(c)
}
static int
-x_meta_yank(c)
- int c;
+x_meta_yank(int c)
{
int len;
if ((x_last_command != XFUNC_yank && x_last_command != XFUNC_meta_yank)
@@ -1252,8 +1201,7 @@ x_meta_yank(c)
}
static int
-x_abort(c)
- int c;
+x_abort(int c)
{
/* x_zotc(c); */
xlp = xep = xcp = xbp = xbuf;
@@ -1263,16 +1211,14 @@ x_abort(c)
}
static int
-x_error(c)
- int c;
+x_error(int c)
{
x_e_putc(BEL);
return KSTD;
}
static int
-x_stuffreset(c)
- int c;
+x_stuffreset(int c)
{
#ifdef TIOCSTI
(void)x_stuff(c);
@@ -1288,8 +1234,7 @@ x_stuffreset(c)
}
static int
-x_stuff(c)
- int c;
+x_stuff(int c)
{
#ifdef TIOCSTI
char ch = c;
@@ -1303,8 +1248,7 @@ x_stuff(c)
}
static char *
-x_mapin(cp)
- const char *cp;
+x_mapin(const char *cp)
{
char *new, *op;
@@ -1329,8 +1273,7 @@ x_mapin(cp)
}
static char *
-x_mapout(c)
- int c;
+x_mapout(int c)
{
static char buf[8];
char *p = buf;
@@ -1345,8 +1288,7 @@ x_mapout(c)
}
static void
-x_print(prefix, key)
- int prefix, key;
+x_print(int prefix, int key)
{
if (prefix == 1)
shprintf("%s", x_mapout(x_prefix1));
@@ -1360,10 +1302,9 @@ 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, /* bind -m */
+ int list) /* bind -l */
{
Findex f;
int prefix, key;
@@ -1453,7 +1394,7 @@ x_bind(a1, a2, macro, list)
}
void
-x_init_emacs()
+x_init_emacs(void)
{
int i, j;
char *locale;
@@ -1488,9 +1429,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]
@@ -1501,8 +1440,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);
@@ -1519,16 +1457,14 @@ x_emacs_keys(ec)
}
static int
-x_set_mark(c)
- int c;
+x_set_mark(int c)
{
xmp = xcp;
return KSTD;
}
static int
-x_kill_region(c)
- int c;
+x_kill_region(int c)
{
int rsize;
char *xr;
@@ -1551,8 +1487,7 @@ x_kill_region(c)
}
static int
-x_xchg_point_mark(c)
- int c;
+x_xchg_point_mark(int c)
{
char *tmp;
@@ -1567,8 +1502,7 @@ x_xchg_point_mark(c)
}
static int
-x_version(c)
- int c;
+x_version(int c)
{
char *o_xbuf = xbuf, *o_xend = xend;
char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
@@ -1597,16 +1531,14 @@ x_version(c)
}
static int
-x_noop(c)
- int c;
+x_noop(int c)
{
return KSTD;
}
#ifdef SILLY
static int
-x_game_of_life(c)
- int c;
+x_game_of_life(int c)
{
char newbuf [256+1];
char *ip, *op;
@@ -1662,57 +1594,49 @@ x_game_of_life(c)
static int
-x_comp_comm(c)
- int c;
+x_comp_comm(int c)
{
do_complete(XCF_COMMAND, CT_COMPLETE);
return KSTD;
}
static int
-x_list_comm(c)
- int c;
+x_list_comm(int c)
{
do_complete(XCF_COMMAND, CT_LIST);
return KSTD;
}
static int
-x_complete(c)
- int c;
+x_complete(int c)
{
do_complete(XCF_COMMAND_FILE, CT_COMPLETE);
return KSTD;
}
static int
-x_enumerate(c)
- int c;
+x_enumerate(int c)
{
do_complete(XCF_COMMAND_FILE, CT_LIST);
return KSTD;
}
static int
-x_comp_file(c)
- int c;
+x_comp_file(int c)
{
do_complete(XCF_FILE, CT_COMPLETE);
return KSTD;
}
static int
-x_list_file(c)
- int c;
+x_list_file(int c)
{
do_complete(XCF_FILE, CT_LIST);
return KSTD;
}
static int
-x_comp_list(c)
- int c;
+x_comp_list(int c)
{
do_complete(XCF_COMMAND_FILE, CT_COMPLIST);
return KSTD;
}
static int
-x_expand(c)
- int c;
+x_expand(int c)
{
char **words;
int nwords = 0;
@@ -1746,9 +1670,8 @@ x_expand(c)
/* 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, /* XCF_{COMMAND,FILE,COMMAND_FILE} */
+ Comp_type type)
{
char **words;
int nwords;
@@ -1813,7 +1736,7 @@ do_complete(flags, type)
*/
static void
-x_adjust()
+x_adjust(void)
{
x_adj_done++; /* flag the fact that we were called. */
/*
@@ -1829,14 +1752,13 @@ x_adjust()
static int unget_char = -1;
static void
-x_e_ungetc(c)
- int c;
+x_e_ungetc(int c)
{
unget_char = c;
}
static int
-x_e_getc()
+x_e_getc(void)
{
int c;
@@ -1856,8 +1778,7 @@ x_e_getc()
}
static void
-x_e_putc(c)
- int c;
+x_e_putc(int c)
{
if (c == '\r' || c == '\n')
x_col = 0;
@@ -1887,8 +1808,7 @@ x_e_putc(c)
#ifdef DEBUG
static int
-x_debug_info(c)
- int c;
+x_debug_info(int c)
{
x_flush();
shellf("\nksh debug:\n");
@@ -1905,8 +1825,7 @@ x_debug_info(c)
#endif
static void
-x_e_puts(s)
- const char *s;
+x_e_puts(const char *s)
{
int adj = x_adj_done;
@@ -1925,8 +1844,7 @@ x_e_puts(s)
*/
static int
-x_set_arg(c)
- int c;
+x_set_arg(int c)
{
int n = 0;
int first = 1;
@@ -1949,8 +1867,7 @@ x_set_arg(c)
/* Comment or uncomment the current line. */
static int
-x_comment(c)
- int c;
+x_comment(int c)
{
int oldsize = x_size_str(xbuf);
int len = xep - xbuf;
@@ -1986,8 +1903,7 @@ x_comment(c)
*/
static int
-x_prev_histword(c)
- int c;
+x_prev_histword(int c)
{
char *rcp;
char *cp;
@@ -2035,24 +1951,21 @@ x_prev_histword(c)
/* Uppercase N(1) words */
static int
-x_fold_upper(c)
- int c;
+x_fold_upper(int c)
{
return x_fold_case('U');
}
/* Lowercase N(1) words */
static int
-x_fold_lower(c)
- int c;
+x_fold_lower(int c)
{
return x_fold_case('L');
}
/* Lowercase N(1) words */
static int
-x_fold_capitalize(c)
- int c;
+x_fold_capitalize(int c)
{
return x_fold_case('C');
}
@@ -2069,8 +1982,7 @@ x_fold_capitalize(c)
*/
static int
-x_fold_case(c)
- int c;
+x_fold_case(int c)
{
char *cp = xcp;
@@ -2137,7 +2049,7 @@ x_fold_case(c)
*/
static char *
-x_lastcp()
+x_lastcp(void)
{
char *rcp;
int i;
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index b2f62c091d2..c14f5daaf27 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.20 2004/12/18 21:25:44 millert Exp $ */
+/* $OpenBSD: eval.c,v 1.21 2004/12/20 11:34:26 otto Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -41,26 +41,21 @@ typedef struct Expand {
#define IFS_WS 1 /* have seen IFS white-space */
#define IFS_NWS 2 /* have seen IFS non-white-space */
-static int varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp);
-static int comsub(Expand *xp, char *cp);
-static char *trimsub(char *str, char *pat, int how);
-static void glob(char *cp, XPtrV *wp, int markdirs);
-static void globit(XString *xs, char **xpp, char *sp, XPtrV *wp,
- int check);
-static char *maybe_expand_tilde(char *p, XString *dsp, char **dpp,
- int isassign);
-static char *tilde(char *acp);
-static char *homedir(char *name);
+static int varsub(Expand *, char *, char *, int *, int *);
+static int comsub(Expand *, char *);
+static char *trimsub(char *, char *, int);
+static void glob(char *, XPtrV *, int);
+static void globit(XString *, char **, char *, XPtrV *, int);
+static char *maybe_expand_tilde(char *, XString *, char **, int);
+static char *tilde(char *);
+static char *homedir(char *);
#ifdef BRACE_EXPAND
-static void alt_expand(XPtrV *wp, char *start, char *exp_start,
- char *end, int fdo);
+static void alt_expand(XPtrV *, char *, char *, char *, int);
#endif
/* compile and expand word */
char *
-substitute(cp, f)
- const char *cp;
- int f;
+substitute(const char *cp, int f)
{
struct source *s, *sold;
@@ -79,9 +74,7 @@ substitute(cp, f)
* expand arg-list
*/
char **
-eval(ap, f)
- char **ap;
- int f;
+eval(char **ap, int f)
{
XPtrV w;
@@ -99,9 +92,7 @@ eval(ap, f)
* expand string
*/
char *
-evalstr(cp, f)
- char *cp;
- int f;
+evalstr(char *cp, int f)
{
XPtrV w;
@@ -117,9 +108,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;
@@ -152,10 +141,9 @@ typedef struct SubType {
} SubType;
void
-expand(cp, wp, f)
- char *cp; /* input word */
- XPtrV *wp; /* output words */
- int f; /* DO* flags */
+expand(char *cp, /* input word */
+ XPtrV *wp, /* output words */
+ int f) /* DO* flags */
{
int c = 0;
int type; /* expansion type */
@@ -696,12 +684,9 @@ 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, /* becomes qualifier type */
+ int *slenp) /* " " len (=, :=, etc.) valid iff *stypep != 0 */
{
int c;
int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */
@@ -848,9 +833,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;
@@ -902,10 +885,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;
@@ -955,10 +935,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);
@@ -978,10 +955,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;
@@ -995,12 +969,11 @@ 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, /* dest string */
+ char **xpp, /* ptr to dest end */
+ char *sp, /* source path */
+ XPtrV *wp, /* output list */
+ int check) /* GF_* flags */
{
char *np; /* next source component */
char *xp = *xpp;
@@ -1133,10 +1106,7 @@ globit(xs, xpp, sp, wp, check)
*/
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;
+copy_non_glob(XString *xs, char **xpp, char *p)
{
char *xp;
int len = strlen(p);
@@ -1173,10 +1143,7 @@ copy_non_glob(xs, xpp, p)
/* 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;
@@ -1206,11 +1173,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;
@@ -1247,8 +1210,7 @@ maybe_expand_tilde(p, dsp, dpp, isassign)
*/
static char *
-tilde(cp)
- char *cp;
+tilde(char *cp)
{
char *dp;
@@ -1274,8 +1236,7 @@ tilde(cp)
*/
static char *
-homedir(name)
- char *name;
+homedir(char *name)
{
struct tbl *ap;
@@ -1294,11 +1255,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 count = 0;
char *brace_start, *brace_end, *comma = NULL;
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c
index c68441553ce..0364b7a610e 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.36 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: exec.c,v 1.37 2004/12/20 11:34:26 otto Exp $ */
/*
* execute command tree
@@ -12,28 +12,26 @@
/* Does ps4 get parameter substitutions done? */
# define PS4_SUBSTITUTE(s) substitute((s), 0)
-static int comexec(struct op *t, struct tbl *volatile tp, char **ap,
- int volatile flags);
-static void scriptexec(struct op *tp, char **ap);
-static int call_builtin(struct tbl *tp, char **wp);
-static int iosetup(struct ioword *iop, struct tbl *tp);
-static int herein(const char *content, int sub);
-static char *do_selectargs(char **ap, bool_t print_menu);
-static int dbteste_isa(Test_env *te, Test_meta meta);
-static const char *dbteste_getopnd(Test_env *te, Test_op op,
- int do_eval);
-static int dbteste_eval(Test_env *te, Test_op op, const char *opnd1,
- const char *opnd2, int do_eval);
-static void dbteste_error(Test_env *te, int offset, const char *msg);
+static int comexec(struct op *, struct tbl *volatile, char **,
+ int volatile);
+static void scriptexec(struct op *, char **);
+static int call_builtin(struct tbl *, char **);
+static int iosetup(struct ioword *, struct tbl *);
+static int herein(const char *, int);
+static char *do_selectargs(char **, bool_t);
+static int dbteste_isa(Test_env *, Test_meta);
+static const char *dbteste_getopnd(Test_env *, Test_op, int);
+static int dbteste_eval(Test_env *, Test_op, const char *, const char *,
+ int);
+static void dbteste_error(Test_env *, int, const char *);
/*
* 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;
@@ -381,11 +379,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;
@@ -683,9 +677,7 @@ comexec(t, tp, ap, flags)
}
static void
-scriptexec(tp, ap)
- struct op *tp;
- char **ap;
+scriptexec(struct op *tp, char **ap)
{
char *shell;
@@ -705,8 +697,7 @@ scriptexec(tp, ap)
}
int
-shcomexec(wp)
- char **wp;
+shcomexec(char **wp)
{
struct tbl *tp;
@@ -721,10 +712,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;
@@ -749,9 +737,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;
@@ -794,9 +780,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;
@@ -824,9 +808,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);
@@ -923,8 +907,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;
@@ -941,10 +925,8 @@ 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 */
{
int ret, err = 0;
struct stat statb;
@@ -971,11 +953,9 @@ search_access(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, /* R_OK or X_OK */
+ int *errnop) /* set if candidate found, but not suitable */
{
const char *sp, *p;
char *xp;
@@ -1017,9 +997,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;
@@ -1040,9 +1018,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;
@@ -1180,9 +1156,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;
@@ -1249,9 +1223,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
@@ -1291,11 +1263,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;
@@ -1308,8 +1276,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;
@@ -1352,19 +1319,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;
@@ -1392,9 +1354,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;
@@ -1433,10 +1393,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;
@@ -1457,21 +1414,14 @@ 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);
diff --git a/bin/ksh/expr.c b/bin/ksh/expr.c
index 57b254183be..22ce0351d0f 100644
--- a/bin/ksh/expr.c
+++ b/bin/ksh/expr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expr.c,v 1.13 2004/12/18 22:42:26 millert Exp $ */
+/* $OpenBSD: expr.c,v 1.14 2004/12/20 11:34:26 otto Exp $ */
/*
* Korn expression evaluation
@@ -128,25 +128,20 @@ struct expr_state {
enum error_type { ET_UNEXPECTED, ET_BADLIT, ET_RECURSIVE,
ET_LVALUE, ET_RDONLY, ET_STR };
-static void evalerr(Expr_state *es, enum error_type type,
- const char *str) __attribute__((__noreturn__));
-static struct tbl *evalexpr(Expr_state *es, enum prec prec);
-static void token(Expr_state *es);
-static struct tbl *do_ppmm(Expr_state *es, enum token op,
- struct tbl *vasn, bool_t is_prefix);
-static void assign_check(Expr_state *es, enum token op,
- struct tbl *vasn);
+static void evalerr(Expr_state *, enum error_type, const char *)
+ __attribute__((__noreturn__));
+static struct tbl *evalexpr(Expr_state *, enum prec);
+static void token(Expr_state *);
+static struct tbl *do_ppmm(Expr_state *, enum token, struct tbl *, bool_t);
+static void assign_check(Expr_state *, enum token, struct tbl *);
static struct tbl *tempvar(void);
-static struct tbl *intvar(Expr_state *es, struct tbl *vp);
+static struct tbl *intvar(Expr_state *, struct tbl *);
/*
* 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;
@@ -162,10 +157,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;
@@ -217,10 +209,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;
@@ -276,9 +265,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, *vr = NULL, *vasn;
enum token op;
@@ -457,8 +444,7 @@ evalexpr(es, prec)
}
static void
-token(es)
- Expr_state *es;
+token(Expr_state *es)
{
const char *cp;
int c;
@@ -528,11 +514,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;
@@ -552,10 +534,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);
@@ -564,7 +543,7 @@ assign_check(es, op, vasn)
}
static struct tbl *
-tempvar()
+tempvar(void)
{
struct tbl *vp;
@@ -579,9 +558,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;
diff --git a/bin/ksh/history.c b/bin/ksh/history.c
index cf6260d0f8d..9ff359bdc21 100644
--- a/bin/ksh/history.c
+++ b/bin/ksh/history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: history.c,v 1.27 2004/12/18 21:25:44 millert Exp $ */
+/* $OpenBSD: history.c,v 1.28 2004/12/20 11:34:26 otto Exp $ */
/*
* command history
@@ -36,10 +36,9 @@ static void histinsert(Source *, int, unsigned char *);
static void writehistfile(int, char *);
static int sprinkle(int);
-static int hist_execute(char *cmd);
-static int hist_replace(char **hp, const char *pat, const char *rep,
- int global);
-static char **hist_get(const char *str, int approx, int allow_cur);
+static int hist_execute(char *);
+static int hist_replace(char **, const char *, const char *, int);
+static char **hist_get(const char *, int, int);
static char **hist_get_oldest(void);
static void histbackup(void);
@@ -51,8 +50,7 @@ static Source *hist_source;
int
-c_fc(wp)
- char **wp;
+c_fc(char **wp)
{
struct shf *shf;
struct temp *tf = NULL;
@@ -269,8 +267,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;
@@ -305,11 +302,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;
@@ -354,10 +347,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;
@@ -398,8 +388,7 @@ hist_get(str, approx, allow_cur)
/* Return a pointer to the newest command in the history */
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)");
@@ -412,7 +401,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)");
@@ -425,7 +414,7 @@ hist_get_oldest()
/* Back up over last histsave */
/******************************/
static void
-histbackup()
+histbackup(void)
{
static int last_line = -1;
@@ -441,20 +430,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;
@@ -475,11 +463,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;
@@ -499,8 +483,7 @@ findhist(start, fwd, str, anchored)
}
int
-findhistrel(str)
- const char *str;
+findhistrel(const char *str)
{
int maxhist = histptr - history;
int start = maxhist - 1;
@@ -523,8 +506,7 @@ findhistrel(str)
* this means reallocating the dataspace
*/
void
-sethistsize(n)
- int n;
+sethistsize(int n)
{
if (n > 0 && n != histsize) {
int cursize = histptr - history;
@@ -548,8 +530,7 @@ sethistsize(n)
* maintenance
*/
void
-sethistfile(name)
- const char *name;
+sethistfile(const char *name)
{
/* if not started then nothing to do */
if (hstarted == 0)
@@ -581,7 +562,7 @@ sethistfile(name)
* initialise the history vector
*/
void
-init_histvec()
+init_histvec(void)
{
if (history == (char **)NULL) {
histsize = HISTORYSIZE;
@@ -604,10 +585,7 @@ init_histvec()
* 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;
@@ -655,8 +633,7 @@ histsave(lno, cmd, dowrite)
#define COMMAND 0xff
void
-hist_init(s)
- Source *s;
+hist_init(Source *s)
{
unsigned char *base;
int lines;
@@ -733,9 +710,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;
@@ -768,9 +743,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[1024];
@@ -822,10 +795,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;
@@ -851,10 +821,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;
@@ -904,10 +871,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;
@@ -927,9 +891,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;
@@ -985,7 +947,7 @@ bad:
}
void
-hist_finish()
+hist_finish(void)
{
(void) flock(histfd, LOCK_UN);
(void) close(histfd);
@@ -996,8 +958,7 @@ hist_finish()
* add magic to the history file
*/
static int
-sprinkle(fd)
- int fd;
+sprinkle(int fd)
{
static unsigned char mag[] = { HMAGIC1, HMAGIC2 };
@@ -1008,23 +969,19 @@ sprinkle(fd)
/* No history to be compiled in: dummy routines to avoid lots more ifdefs */
void
-init_histvec()
+init_histvec(void)
{
}
void
-hist_init(s)
- Source *s;
+hist_init(Source *s)
{
}
void
-hist_finish()
+hist_finish(void)
{
}
void
-histsave(lno, cmd, dowrite)
- int lno;
- const char *cmd;
- int dowrite;
+histsave(int lno, const char *cmd, int dowrite)
{
errorf("history not enabled");
}
diff --git a/bin/ksh/io.c b/bin/ksh/io.c
index 4ba9d638718..12e9c120935 100644
--- a/bin/ksh/io.c
+++ b/bin/ksh/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.17 2004/12/18 22:35:41 millert Exp $ */
+/* $OpenBSD: io.c,v 1.18 2004/12/20 11:34:26 otto Exp $ */
/*
* shell buffered IO and formatted output
@@ -100,8 +100,7 @@ internal_errorf(int jump, const char *fmt, ...)
/* 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
@@ -145,7 +144,7 @@ shprintf(const char *fmt, ...)
static struct shf *kshdebug_shf;
void
-kshdebug_init_()
+kshdebug_init_(void)
{
if (kshdebug_shf)
shf_close(kshdebug_shf);
@@ -174,10 +173,7 @@ kshdebug_printf_(const char *fmt, ...)
}
void
-kshdebug_dump_(str, mem, nbytes)
- const char *str;
- const void *mem;
- int nbytes;
+kshdebug_dump_(const char *str, const void *mem, int nbytes)
{
int i, j;
int nprow = 16;
@@ -200,8 +196,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;
@@ -212,7 +207,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);
@@ -223,10 +218,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);
@@ -241,9 +233,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;
@@ -264,8 +254,7 @@ savefd(fd, noclose)
}
void
-restfd(fd, ofd)
- int fd, ofd;
+restfd(int fd, int ofd)
{
if (fd == 2)
shf_flush(&shf_iob[fd]);
@@ -278,8 +267,7 @@ restfd(fd, ofd)
}
void
-openpipe(pv)
- int *pv;
+openpipe(int *pv)
{
if (pipe(pv) < 0)
errorf("can't create pipe - try again");
@@ -288,8 +276,7 @@ openpipe(pv)
}
void
-closepipe(pv)
- int *pv;
+closepipe(int *pv)
{
close(pv[0]);
close(pv[1]);
@@ -299,10 +286,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;
@@ -338,7 +322,7 @@ check_fd(name, mode, emsgp)
/* Called once from main */
void
-coproc_init()
+coproc_init(void)
{
coproc.read = coproc.readw = coproc.write = -1;
coproc.njobs = 0;
@@ -347,8 +331,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);
@@ -361,8 +344,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);
@@ -374,8 +356,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);
@@ -387,9 +368,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;
@@ -404,8 +383,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) {
@@ -430,10 +408,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)
{
static unsigned int inc;
struct temp *tp;
diff --git a/bin/ksh/jobs.c b/bin/ksh/jobs.c
index f897945e46a..52cf287bde8 100644
--- a/bin/ksh/jobs.c
+++ b/bin/ksh/jobs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jobs.c,v 1.27 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: jobs.c,v 1.28 2004/12/20 11:34:26 otto Exp $ */
/*
* Process and job control
@@ -124,23 +124,22 @@ static pid_t our_pgrp;
static int const tt_sigs[] = { SIGTSTP, SIGTTIN, SIGTTOU };
#endif /* JOBS */
-static void j_set_async(Job *j);
-static void j_startjob(Job *j);
-static int j_waitj(Job *j, int flags, const char *where);
-static void j_sigchld(int sig);
-static void j_print(Job *j, int how, struct shf *shf);
-static Job *j_lookup(const char *cp, int *ecodep);
+static void j_set_async(Job *);
+static void j_startjob(Job *);
+static int j_waitj(Job *, int, const char *);
+static void j_sigchld(int);
+static void j_print(Job *, int, struct shf *);
+static Job *j_lookup(const char *, int *);
static Job *new_job(void);
static Proc *new_proc(void);
-static void check_job(Job *j);
-static void put_job(Job *j, int where);
-static void remove_job(Job *j, const char *where);
-static int kill_job(Job *j, int sig);
+static void check_job(Job *);
+static void put_job(Job *, int);
+static void remove_job(Job *, const char *);
+static int kill_job(Job *, int);
/* initialize job control */
void
-j_init(mflagset)
- int mflagset;
+j_init(int mflagset)
{
child_max = CHILD_MAX; /* so syscon() isn't always being called */
@@ -187,7 +186,7 @@ j_init(mflagset)
/* job cleanup before shell exit */
void
-j_exit()
+j_exit(void)
{
/* kill stopped, and possibly running, jobs */
Job *j;
@@ -242,7 +241,7 @@ j_exit()
#ifdef JOBS
/* turn job control on or off according to Flag(FMONITOR) */
void
-j_change()
+j_change(void)
{
int i;
@@ -323,10 +322,8 @@ 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 */
@@ -511,7 +508,7 @@ exchild(t, flags, close_fd)
/* start the last job: only used for `command` jobs */
void
-startlast()
+startlast(void)
{
sigset_t omask;
@@ -527,7 +524,7 @@ startlast()
/* wait for last job: only used for `command` jobs */
int
-waitlast()
+waitlast(void)
{
int rv;
Job *j;
@@ -554,9 +551,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;
@@ -607,9 +602,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;
Proc *p;
@@ -649,9 +642,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;
@@ -754,7 +745,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;
@@ -797,10 +788,9 @@ j_njobs(void)
/* 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;
@@ -847,7 +837,7 @@ j_jobs(cp, slp, nflag)
/* list jobs for top-level notification */
void
-j_notify()
+j_notify(void)
{
Job *j, *tmp;
sigset_t omask;
@@ -875,7 +865,7 @@ j_notify()
/* Return pid of last process in last asynchronous job */
pid_t
-j_async()
+j_async(void)
{
sigset_t omask;
@@ -894,8 +884,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;
@@ -930,8 +919,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;
@@ -953,10 +941,9 @@ 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, /* see JW_* */
+ const char *where)
{
int rv;
@@ -1086,8 +1073,7 @@ j_waitj(j, flags, where)
* If jobs are compiled in then this routine expects sigchld to be blocked.
*/
static void
-j_sigchld(sig)
- int sig;
+j_sigchld(int sig)
{
int errno_ = errno;
Job *j;
@@ -1161,8 +1147,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;
@@ -1268,10 +1253,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;
@@ -1379,9 +1361,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;
@@ -1474,7 +1454,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;
@@ -1502,7 +1482,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;
@@ -1521,9 +1501,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;
@@ -1563,9 +1541,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;
@@ -1600,9 +1576,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;
diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c
index 9227c626382..0799df78b08 100644
--- a/bin/ksh/lex.c
+++ b/bin/ksh/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.27 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: lex.c,v 1.28 2004/12/20 11:34:26 otto Exp $ */
/*
* lexical analysis and source input
@@ -53,16 +53,17 @@ struct State_info {
};
-static void readhere(struct ioword *iop);
+static void readhere(struct ioword *);
static int getsc__(void);
-static void getsc_line(Source *s);
+static void getsc_line(Source *);
static int getsc_bn(void);
-static char *get_brace_var(XString *wsp, char *wp);
-static int arraysub(char **strp);
-static const char *ungetsc(int c);
+static char *get_brace_var(XString *, char *);
+static int arraysub(char **);
+static const char *ungetsc(int);
static void gethere(void);
-static Lex_state *push_state_(State_info *si, Lex_state *old_end);
-static Lex_state *pop_state_(State_info *si, Lex_state *old_end);
+static Lex_state *push_state_(State_info *, Lex_state *);
+static Lex_state *pop_state_(State_info *, Lex_state *);
+static int dopprompt(const char *, int, const char **, int);
static int backslash_skip;
static int ignore_backslash_newline;
@@ -98,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;
@@ -808,7 +808,7 @@ Done:
}
static void
-gethere()
+gethere(void)
{
struct ioword **p;
@@ -822,8 +822,7 @@ gethere()
*/
static void
-readhere(iop)
- struct ioword *iop;
+readhere(struct ioword *iop)
{
int c;
char *volatile eof;
@@ -902,9 +901,7 @@ yyerror(const char *fmt, ...)
*/
Source *
-pushs(type, areap)
- int type;
- Area *areap;
+pushs(int type, Area *areap)
{
Source *s;
@@ -927,7 +924,7 @@ pushs(type, areap)
}
static int
-getsc__()
+getsc__(void)
{
Source *s = source;
int c;
@@ -1028,8 +1025,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;
@@ -1129,9 +1125,7 @@ getsc_line(s)
}
void
-set_prompt(to, s)
- int to;
- Source *s;
+set_prompt(int to, Source *s)
{
struct shf *shf;
char * volatile ps1;
@@ -1169,11 +1163,7 @@ set_prompt(to, s)
}
static int
-dopprompt(sp, ntruncate, spp, doprint)
- const char *sp;
- int ntruncate;
- const char **spp;
- int doprint;
+dopprompt(const char *sp, int ntruncate, const char **spp, int doprint)
{
char strbuf[1024], tmpbuf[1024], *p, *str, nbuf[32], delimiter = '\0';
int len, c, n, totlen = 0, indelimit = 0, counting = 1, delimitthis;
@@ -1436,17 +1426,13 @@ dopprompt(sp, ntruncate, spp, doprint)
}
void
-pprompt(cp, ntruncate)
- const char *cp;
- int ntruncate;
+pprompt(const char *cp, int ntruncate)
{
dopprompt(cp, ntruncate, NULL, 1);
}
int
-promptlen(cp, spp)
- const char *cp;
- const char **spp;
+promptlen(const char *cp, const char **spp)
{
return dopprompt(cp, 0, spp, 0);
}
@@ -1455,9 +1441,7 @@ promptlen(cp, spp)
* 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,
@@ -1532,8 +1516,7 @@ get_brace_var(wsp, wp)
* (Returned string double null terminated)
*/
static int
-arraysub(strp)
- char **strp;
+arraysub(char **strp)
{
XString ws;
char *wp;
@@ -1560,8 +1543,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--;
@@ -1613,9 +1595,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);
@@ -1626,9 +1606,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;
diff --git a/bin/ksh/mail.c b/bin/ksh/mail.c
index b1441667334..22853ccb913 100644
--- a/bin/ksh/mail.c
+++ b/bin/ksh/mail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mail.c,v 1.12 2004/12/18 21:25:44 millert Exp $ */
+/* $OpenBSD: mail.c,v 1.13 2004/12/20 11:34:26 otto Exp $ */
/*
* Mailbox checking code by Robert J. Gibson, adapted for PD ksh by
@@ -31,12 +31,12 @@ static mbox_t mbox;
static time_t mlastchkd; /* when mail was last checked */
static time_t mailcheck_interval;
-static void munset(mbox_t *mlist); /* free mlist and mval */
-static mbox_t * mballoc(char *p, char *m); /* allocate a new mbox */
-static void mprintit(mbox_t *mbp);
+static void munset(mbox_t *); /* free mlist and mval */
+static mbox_t * mballoc(char *, char *); /* allocate a new mbox */
+static void mprintit(mbox_t *);
void
-mcheck()
+mcheck(void)
{
mbox_t *mbp;
time_t now;
@@ -80,15 +80,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;
@@ -106,8 +104,7 @@ mbset(p)
}
void
-mpset(mptoparse)
- char *mptoparse;
+mpset(char *mptoparse)
{
mbox_t *mbp;
char *mpath, *mmsg, *mval;
@@ -146,8 +143,7 @@ mpset(mptoparse)
}
static void
-munset(mlist)
-mbox_t *mlist;
+munset(mbox_t *mlist)
{
mbox_t *mbp;
@@ -161,9 +157,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;
@@ -180,8 +174,7 @@ mballoc(p, m)
}
static void
-mprintit( mbp )
-mbox_t *mbp;
+mprintit(mbox_t *mbp)
{
struct tbl *vp;
diff --git a/bin/ksh/main.c b/bin/ksh/main.c
index 73ec9d40374..eb9bbb8947f 100644
--- a/bin/ksh/main.c
+++ b/bin/ksh/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.32 2004/12/18 21:25:44 millert Exp $ */
+/* $OpenBSD: main.c,v 1.33 2004/12/20 11:34:26 otto Exp $ */
/*
* startup, main loop, environments and error handling
@@ -375,11 +375,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;
@@ -447,8 +443,7 @@ include(name, argc, argv, intr_ok)
}
int
-command(comm)
- const char *comm;
+command(const char *comm)
{
Source *s;
@@ -461,9 +456,7 @@ 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)
{
struct op *t;
volatile int wastty = s->flags & SF_TTY;
@@ -570,8 +563,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)
@@ -605,8 +597,7 @@ unwind(i)
}
void
-newenv(type)
- int type;
+newenv(int type)
{
struct env *ep;
@@ -622,7 +613,7 @@ newenv(type)
}
void
-quitenv()
+quitenv(void)
{
struct env *ep = e;
int fd;
@@ -672,7 +663,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;
@@ -697,7 +688,7 @@ cleanup_parents_env()
/* Called just before an execve cleanup stuff temporary files */
void
-cleanup_proc_env()
+cleanup_proc_env(void)
{
struct env *ep;
@@ -707,7 +698,7 @@ cleanup_proc_env()
/* remove temp files and free ATEMP Area */
static void
-reclaim()
+reclaim(void)
{
remove_temps(e->temps);
e->temps = NULL;
@@ -715,8 +706,7 @@ reclaim()
}
static void
-remove_temps(tp)
- struct temp *tp;
+remove_temps(struct temp *tp)
{
for (; tp != NULL; tp = tp->next)
@@ -727,8 +717,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;
@@ -739,9 +728,7 @@ is_restricted(name)
}
void
-aerror(ap, msg)
- Area *ap;
- const char *msg;
+aerror(Area *ap, const char *msg)
{
internal_errorf(1, "alloc: %s", msg);
errorf(null); /* this is never executed - keeps gcc quiet */
diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c
index 88713b0dd43..ea7c8338521 100644
--- a/bin/ksh/misc.c
+++ b/bin/ksh/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.23 2004/12/18 21:25:44 millert Exp $ */
+/* $OpenBSD: misc.c,v 1.24 2004/12/20 11:34:26 otto Exp $ */
/*
* Miscellaneous functions
@@ -10,17 +10,15 @@
short ctypes [UCHAR_MAX+1]; /* type bits for unsigned char */
-static int do_gmatch(const unsigned char *s, const unsigned char *p,
- const unsigned char *se, const unsigned char *pe);
-static const unsigned char *cclass(const unsigned char *p, int sub);
+static int do_gmatch(const unsigned char *, const unsigned char *,
+ const unsigned char *, const unsigned char *);
+static const unsigned char *cclass(const unsigned char *, int);
/*
* Fast character classes
*/
void
-setctypes(s, t)
- const char *s;
- int t;
+setctypes(const char *s, int t)
{
int i;
@@ -34,7 +32,7 @@ setctypes(s, t)
}
void
-initctypes()
+initctypes(void)
{
int c;
@@ -55,9 +53,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];
@@ -72,9 +68,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;
@@ -92,10 +86,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;
@@ -108,10 +99,7 @@ str_nsave(s, n, ap)
/* called from expand.h:XcheckN() to grow buffer */
char *
-Xcheck_grow_(xsp, xp, more)
- XString *xsp;
- char *xp;
- int more;
+Xcheck_grow_(XString *xsp, char *xp, int more)
{
char *old_beg = xsp->beg;
@@ -186,8 +174,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)
{
int i;
@@ -211,11 +198,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;
@@ -226,8 +209,7 @@ options_fmt_entry(arg, i, buf, buflen)
}
static void
-printoptions(verbose)
- int verbose;
+printoptions(int verbose)
{
int i;
@@ -259,7 +241,7 @@ printoptions(verbose)
}
char *
-getoptions()
+getoptions(void)
{
int i;
char m[(int) FNFLAGS + 1];
@@ -274,10 +256,9 @@ 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, /* flag to change */
+ int newval) /* what is changing the flag (command line vs set) */
{
int oldval;
@@ -333,10 +314,9 @@ 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, /* OF_CMDLINE or OF_SET */
+ int *setargsp)
{
static char cmd_opts[NELEM(options) + 3]; /* o:\0 */
static char set_opts[NELEM(options) + 5]; /* Ao;s\0 */
@@ -473,9 +453,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;
@@ -491,9 +469,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);
@@ -513,9 +489,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;
@@ -555,8 +529,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;
@@ -610,9 +583,8 @@ has_globbing(xp, xpe)
/* Function must return either 0 or 1 (assumed by code for 0x80|'!') */
static int
-do_gmatch(s, se, p, pe)
- const unsigned char *s, *p;
- const unsigned char *se, *pe;
+do_gmatch(const unsigned char *s, const unsigned char *se,
+ const unsigned char *p, const unsigned char *pe)
{
int sc, pc;
const unsigned char *prest, *psub, *pnext;
@@ -740,9 +712,7 @@ do_gmatch(s, se, p, pe)
}
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;
@@ -787,10 +757,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;
@@ -815,10 +782,9 @@ 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, /* base address */
+ size_t n, /* elements */
+ int (*f) (void *, void *)) /* compare function */
{
qsort1(base, base + n, f);
}
@@ -831,9 +797,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;
@@ -902,17 +866,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;
@@ -948,10 +909,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;
@@ -1051,8 +1009,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;
@@ -1085,13 +1042,8 @@ 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;
@@ -1137,9 +1089,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;
@@ -1170,10 +1120,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);
@@ -1190,10 +1137,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;
@@ -1217,8 +1161,7 @@ blocking_read(fd, buf, nbytes)
* 1 if it was.
*/
int
-reset_nonblock(fd)
- int fd;
+reset_nonblock(int fd)
{
int flags;
@@ -1235,9 +1178,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)
{
char *b;
char *ret;
diff --git a/bin/ksh/path.c b/bin/ksh/path.c
index dc21bf866ac..46bfd388749 100644
--- a/bin/ksh/path.c
+++ b/bin/ksh/path.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: path.c,v 1.10 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: path.c,v 1.11 2004/12/20 11:34:26 otto Exp $ */
#include "sh.h"
#include <sys/stat.h>
@@ -12,7 +12,7 @@
* Larry Bouzane (larry@cs.mun.ca)
*/
-static char *do_phys_path(XString *xsp, char *xp, const char *path);
+static char *do_phys_path(XString *, char *, const char *);
/*
* Makes a filename into result using the following algorithm.
@@ -30,12 +30,10 @@ 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, /* & of : separated list */
+ XString *xsp,
+ int *phys_pathp)
{
int rval = 0;
int use_cdpath = 1;
@@ -108,8 +106,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;
@@ -176,8 +173,7 @@ simplify_path(path)
void
-set_current_wd(path)
- char *path;
+set_current_wd(char *path)
{
int len;
char *p = path;
@@ -195,8 +191,7 @@ set_current_wd(path)
}
char *
-get_phys_path(path)
- const char *path;
+get_phys_path(const char *path)
{
XString xs;
char *xp;
@@ -216,10 +211,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;
int len, llen;
@@ -271,7 +263,8 @@ do_phys_path(xsp, xp, path)
#ifdef TEST
-main(argc, argv)
+int
+main(void)
{
int rv;
char *cp, cdpath[256], pwd[256], file[256], result[256];
diff --git a/bin/ksh/proto.h b/bin/ksh/proto.h
index bb05202e3d5..526f12d3bda 100644
--- a/bin/ksh/proto.h
+++ b/bin/ksh/proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.h,v 1.19 2004/12/18 22:42:26 millert Exp $ */
+/* $OpenBSD: proto.h,v 1.20 2004/12/20 11:34:26 otto Exp $ */
/*
* prototypes for PD-KSH
@@ -7,263 +7,260 @@
*/
/* alloc.c */
-Area * ainit(Area *ap);
-void afreeall(Area *ap);
-void * alloc(size_t size, Area *ap);
-void * aresize(void *ptr, size_t size, Area *ap);
-void afree(void *ptr, Area *ap);
+Area * ainit(Area *);
+void afreeall(Area *);
+void * alloc(size_t, Area *);
+void * aresize(void *, size_t, Area *);
+void afree(void *, Area *);
/* c_ksh.c */
-int c_hash(char **wp);
-int c_cd(char **wp);
-int c_pwd(char **wp);
-int c_print(char **wp);
-int c_whence(char **wp);
-int c_command(char **wp);
-int c_typeset(char **wp);
-int c_alias(char **wp);
-int c_unalias(char **wp);
-int c_let(char **wp);
-int c_jobs(char **wp);
-int c_fgbg(char **wp);
-int c_kill(char **wp);
-void getopts_reset(int val);
-int c_getopts(char **wp);
-int c_bind(char **wp);
+int c_hash(char **);
+int c_cd(char **);
+int c_pwd(char **);
+int c_print(char **);
+int c_whence(char **);
+int c_command(char **);
+int c_typeset(char **);
+int c_alias(char **);
+int c_unalias(char **);
+int c_let(char **);
+int c_jobs(char **);
+int c_fgbg(char **);
+int c_kill(char **);
+void getopts_reset(int);
+int c_getopts(char **);
+int c_bind(char **);
/* c_sh.c */
-int c_label(char **wp);
-int c_shift(char **wp);
-int c_umask(char **wp);
-int c_dot(char **wp);
-int c_wait(char **wp);
-int c_read(char **wp);
-int c_eval(char **wp);
-int c_trap(char **wp);
-int c_brkcont(char **wp);
-int c_exitreturn(char **wp);
-int c_set(char **wp);
-int c_unset(char **wp);
-int c_ulimit(char **wp);
-int c_times(char **wp);
-int timex(struct op *t, int f);
-void timex_hook(struct op *t, char ** volatile *app);
-int c_exec(char **wp);
-int c_builtin(char **wp);
+int c_label(char **);
+int c_shift(char **);
+int c_umask(char **);
+int c_dot(char **);
+int c_wait(char **);
+int c_read(char **);
+int c_eval(char **);
+int c_trap(char **);
+int c_brkcont(char **);
+int c_exitreturn(char **);
+int c_set(char **);
+int c_unset(char **);
+int c_ulimit(char **);
+int c_times(char **);
+int timex(struct op *, int);
+void timex_hook(struct op *, char ** volatile *);
+int c_exec(char **);
+int c_builtin(char **);
/* c_test.c */
-int c_test(char **wp);
+int c_test(char **);
/* edit.c: most prototypes in edit.h */
void x_init(void);
-int x_read(char *buf, size_t len);
-void set_editmode(const char *ed);
+int x_read(char *, size_t);
+void set_editmode(const char *);
/* emacs.c: most prototypes in edit.h */
-int x_bind(const char *a1, const char *a2, int macro, int list);
+int x_bind(const char *, const char *, int, int);
/* eval.c */
-char * substitute(const char *cp, int f);
-char ** eval(char **ap, int f);
-char * evalstr(char *cp, int f);
-char * evalonestr(char *cp, int f);
-char *debunk(char *dp, const char *sp, size_t dlen);
-void expand(char *cp, XPtrV *wp, int f);
-int glob_str(char *cp, XPtrV *wp, int markdirs);
+char * substitute(const char *, int);
+char ** eval(char **, int);
+char * evalstr(char *cp, int);
+char * evalonestr(char *cp, int);
+char *debunk(char *, const char *, size_t);
+void expand(char *, XPtrV *, int);
+int glob_str(char *, XPtrV *, int);
/* exec.c */
-int execute(struct op * volatile t, volatile int flags);
-int shcomexec(char **wp);
-struct tbl * findfunc(const char *name, unsigned int h, int create);
-int define(const char *name, struct op *t);
-void builtin(const char *name, int (*func)(char **));
-struct tbl * findcom(const char *name, int flags);
-void flushcom(int all);
-char * search(const char *name, const char *path, int mode, int *errnop);
-int search_access(const char *path, int mode, int *errnop);
-int pr_menu(char *const *ap);
-int pr_list(char *const *ap);
+int execute(struct op * volatile, volatile int);
+int shcomexec(char **);
+struct tbl * findfunc(const char *, unsigned int, int);
+int define(const char *, struct op *);
+void builtin(const char *, int (*)(char **));
+struct tbl * findcom(const char *, int);
+void flushcom(int);
+char * search(const char *, const char *, int, int *);
+int search_access(const char *, int, int *);
+int pr_menu(char *const *);
+int pr_list(char *const *);
/* expr.c */
-int evaluate(const char *expr, long *rval, int error_ok);
-int v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok);
+int evaluate(const char *, long *, int);
+int v_evaluate(struct tbl *, const char *, volatile int);
/* history.c */
void init_histvec(void);
-void hist_init(Source *s);
+void hist_init(Source *);
void hist_finish(void);
-void histsave(int lno, const char *cmd, int dowrite);
+void histsave(int, const char *, int);
#ifdef HISTORY
-int c_fc(char **wp);
-void sethistsize(int n);
-void sethistfile(const char *name);
+int c_fc(char **);
+void sethistsize(int);
+void sethistfile(const char *);
char ** histpos(void);
int histN(void);
-int histnum(int n);
-int findhist(int start, int fwd, const char *str, int anchored);
-int findhistrel(const char *str);
-char **hist_get_newest(int allow_cur);
+int histnum(int);
+int findhist(int, int, const char *, int);
+int findhistrel(const char *);
+char **hist_get_newest(int);
#endif /* HISTORY */
/* io.c */
-void errorf(const char *fmt, ...)
+void errorf(const char *, ...)
__attribute__((__noreturn__, __format__ (printf, 1, 2)));
-void warningf(int fileline, const char *fmt, ...)
+void warningf(int, const char *, ...)
__attribute__((__format__ (printf, 2, 3)));
-void bi_errorf(const char *fmt, ...)
+void bi_errorf(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
-void internal_errorf(int jump, const char *fmt, ...)
+void internal_errorf(int, const char *, ...)
__attribute__((__format__ (printf, 2, 3)));
-void error_prefix(int fileline);
-void shellf(const char *fmt, ...)
+void error_prefix(int);
+void shellf(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
-void shprintf(const char *fmt, ...)
+void shprintf(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
#ifdef KSH_DEBUG
void kshdebug_init_(void);
-void kshdebug_printf_(const char *fmt, ...)
+void kshdebug_printf_(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
-void kshdebug_dump_(const char *str, const void *mem, int nbytes);
+void kshdebug_dump_(const char *, const void *, int);
#endif /* KSH_DEBUG */
-int can_seek(int fd);
+int can_seek(int);
void initio(void);
-int ksh_dup2(int ofd, int nfd, int errok);
-int savefd(int fd, int noclose);
-void restfd(int fd, int ofd);
-void openpipe(int *pv);
-void closepipe(int *pv);
-int check_fd(char *name, int mode, const char **emsgp);
+int ksh_dup2(int, int, int);
+int savefd(int, int);
+void restfd(int, int);
+void openpipe(int *);
+void closepipe(int *);
+int check_fd(char *, int, const char **);
void coproc_init(void);
-void coproc_read_close(int fd);
-void coproc_readw_close(int fd);
-void coproc_write_close(int fd);
-int coproc_getfd(int mode, const char **emsgp);
-void coproc_cleanup(int reuse);
-struct temp *maketemp(Area *ap, Temp_type type, struct temp **tlist);
+void coproc_read_close(int);
+void coproc_readw_close(int);
+void coproc_write_close(int);
+int coproc_getfd(int, const char **);
+void coproc_cleanup(int);
+struct temp *maketemp(Area *, Temp_type, struct temp **);
/* jobs.c */
-void j_init(int mflagset);
+void j_init(int);
void j_exit(void);
void j_change(void);
-int exchild(struct op *t, int flags, int close_fd);
+int exchild(struct op *, int, int);
void startlast(void);
int waitlast(void);
-int waitfor(const char *cp, int *sigp);
-int j_kill(const char *cp, int sig);
-int j_resume(const char *cp, int bg);
-int j_jobs(const char *cp, int slp, int nflag);
+int waitfor(const char *, int *);
+int j_kill(const char *, int);
+int j_resume(const char *, int);
+int j_jobs(const char *, int, int);
int j_njobs(void);
void j_notify(void);
pid_t j_async(void);
int j_stopped_running(void);
/* lex.c */
-int yylex(int cf);
-void yyerror(const char *fmt, ...)
+int yylex(int);
+void yyerror(const char *, ...)
__attribute__((__noreturn__, __format__ (printf, 1, 2)));
-Source * pushs(int type, Area *areap);
-void set_prompt(int to, Source *s);
-void pprompt(const char *cp, int ntruncate);
+Source * pushs(int, Area *);
+void set_prompt(int, Source *);
+void pprompt(const char *, int);
/* mail.c */
void mcheck(void);
-void mcset(long interval);
-void mbset(char *p);
-void mpset(char *mptoparse);
+void mcset(long);
+void mbset(char *);
+void mpset(char *);
/* main.c */
-int include(const char *name, int argc, char **argv, int intr_ok);
-int command(const char *comm);
-int shell(Source *volatile s, int volatile toplevel);
-void unwind(int i) __attribute__((__noreturn__));
-void newenv(int type);
+int include(const char *, int, char **, int);
+int command(const char *);
+int shell(Source *volatile, int volatile);
+void unwind(int) __attribute__((__noreturn__));
+void newenv(int);
void quitenv(void);
void cleanup_parents_env(void);
void cleanup_proc_env(void);
-void aerror(Area *ap, const char *msg)
- __attribute__((__noreturn__));
+void aerror(Area *, const char *) __attribute__((__noreturn__));
/* misc.c */
-void setctypes(const char *s, int t);
+void setctypes(const char *, int);
void initctypes(void);
-char * ulton(unsigned long n, int base);
-char * str_save(const char *s, Area *ap);
-char * str_nsave(const char *s, int n, Area *ap);
-int option(const char *n);
+char * ulton(unsigned long, int);
+char * str_save(const char *, Area *);
+char * str_nsave(const char *, int, Area *);
+int option(const char *);
char * getoptions(void);
-void change_flag(enum sh_flag f, int what, int newval);
-int parse_args(char **argv, int what, int *setargsp);
-int getn(const char *as, int *ai);
-int bi_getn(const char *as, int *ai);
-int gmatch(const char *s, const char *p, int isfile);
-int has_globbing(const char *xp, const char *xpe);
-const unsigned char *pat_scan(const unsigned char *p,
- const unsigned char *pe, int match_sep);
-void qsortp(void **base, size_t n, int (*f)(void *, void *));
-int xstrcmp(void *p1, void *p2);
-void ksh_getopt_reset(Getopt *go, int);
-int ksh_getopt(char **argv, Getopt *go, const char *options);
-void print_value_quoted(const char *s);
-void print_columns(struct shf *shf, int n,
- char *(*func)(void *, int, char *, int),
- void *arg, int max_width, int prefcol);
-int strip_nuls(char *buf, int nbytes);
-char *str_zcpy(char *dst, const char *src, int dsize);
-int blocking_read(int fd, char *buf, int nbytes);
-int reset_nonblock(int fd);
-char *ksh_get_wd(char *buf, int bsize);
+void change_flag(enum sh_flag, int, int);
+int parse_args(char **, int, int *);
+int getn(const char *, int *);
+int bi_getn(const char *, int *);
+int gmatch(const char *, const char *, int);
+int has_globbing(const char *, const char *);
+const unsigned char *pat_scan(const unsigned char *, const unsigned char *,
+ int);
+void qsortp(void **, size_t, int (*)(void *, void *));
+int xstrcmp(void *, void *);
+void ksh_getopt_reset(Getopt *, int);
+int ksh_getopt(char **, Getopt *, const char *);
+void print_value_quoted(const char *);
+void print_columns(struct shf *, int, char *(*)(void *, int, char *, int),
+ void *, int, int prefcol);
+int strip_nuls(char *, int);
+char *str_zcpy(char *, const char *, int);
+int blocking_read(int, char *, int);
+int reset_nonblock(int);
+char *ksh_get_wd(char *, int);
/* path.c */
-int make_path(const char *cwd, const char *file,
- char **pathlist, XString *xsp, int *phys_pathp);
-void simplify_path(char *path);
-char *get_phys_path(const char *path);
-void set_current_wd(char *path);
+int make_path(const char *, const char *, char **, XString *, int *);
+void simplify_path(char *);
+char *get_phys_path(const char *);
+void set_current_wd(char *);
/* syn.c */
void initkeywords(void);
-struct op * compile(Source *s);
+struct op * compile(Source *);
/* table.c */
-unsigned int hash(const char *n);
-void tinit(struct table *tp, Area *ap, int tsize);
-struct tbl * tsearch(struct table *tp, const char *n, unsigned int h);
-struct tbl * tenter(struct table *tp, const char *n, unsigned int h);
-void tdelete(struct tbl *p);
-void twalk(struct tstate *ts, struct table *tp);
-struct tbl * tnext(struct tstate *ts);
-struct tbl ** tsort(struct table *tp);
+unsigned int hash(const char *);
+void tinit(struct table *, Area *, int);
+struct tbl * tsearch(struct table *, const char *, unsigned int);
+struct tbl * tenter(struct table *, const char *, unsigned int);
+void tdelete(struct tbl *);
+void twalk(struct tstate *, struct table *);
+struct tbl * tnext(struct tstate *);
+struct tbl ** tsort(struct table *);
/* trace.c */
/* trap.c */
void inittraps(void);
void alarm_init(void);
-Trap * gettrap(const char *name, int igncase);
-void trapsig(int i);
+Trap * gettrap(const char *, int);
+void trapsig(int);
void intrcheck(void);
int fatal_trap_check(void);
int trap_pending(void);
void runtraps(int intr);
-void runtrap(Trap *p);
+void runtrap(Trap *);
void cleartraps(void);
void restoresigs(void);
-void settrap(Trap *p, char *s);
+void settrap(Trap *, char *);
int block_pipe(void);
-void restore_pipe(int restore_dfl);
-int setsig(Trap *p, sig_t f, int flags);
-void setexecsig(Trap *p, int restore);
+void restore_pipe(int);
+int setsig(Trap *, sig_t, int);
+void setexecsig(Trap *, int);
/* tree.c */
-int fptreef(struct shf *f, int indent, const char *fmt, ...);
-char * snptreef(char *s, int n, const char *fmt, ...);
-struct op * tcopy(struct op *t, Area *ap);
-char * wdcopy(const char *wp, Area *ap);
-char * wdscan(const char *wp, int c);
-char * wdstrip(const char *wp);
-void tfree(struct op *t, Area *ap);
+int fptreef(struct shf *, int, const char *, ...);
+char * snptreef(char *, int, const char *, ...);
+struct op * tcopy(struct op *, Area *);
+char * wdcopy(const char *, Area *);
+char * wdscan(const char *, int);
+char * wdstrip(const char *);
+void tfree(struct op *, Area *);
/* var.c */
void newblock(void);
void popblock(void);
void initvar(void);
-struct tbl * global(const char *n);
-struct tbl * local(const char *n, bool_t copy);
-char * str_val(struct tbl *vp);
-long intval(struct tbl *vp);
-int setstr(struct tbl *vq, const char *s, int error_ok);
-struct tbl *setint_v(struct tbl *vq, struct tbl *vp);
-void setint(struct tbl *vq, long n);
-int getint(struct tbl *vp, long *nump);
-struct tbl * typeset(const char *var, Tflag set, Tflag clr, int field, int base);
-void unset(struct tbl *vp, int array_ref);
-char * skip_varname(const char *s, int aok);
-char *skip_wdvarname(const char *s, int aok);
-int is_wdvarname(const char *s, int aok);
-int is_wdvarassign(const char *s);
+struct tbl * global(const char *);
+struct tbl * local(const char *, bool_t);
+char * str_val(struct tbl *);
+long intval(struct tbl *);
+int setstr(struct tbl *, const char *, int);
+struct tbl *setint_v(struct tbl *, struct tbl *);
+void setint(struct tbl *, long);
+int getint(struct tbl *, long *);
+struct tbl * typeset(const char *, Tflag, Tflag, int, int);
+void unset(struct tbl *, int);
+char * skip_varname(const char *, int);
+char *skip_wdvarname(const char *, int);
+int is_wdvarname(const char *, int);
+int is_wdvarassign(const char *);
char ** makenv(void);
void change_random(void);
-int array_ref_len(const char *cp);
-char * arrayname(const char *str);
-void set_array(const char *var, int reset, char **vals);
+int array_ref_len(const char *);
+char * arrayname(const char *);
+void set_array(const char *, int, char **);
/* version.c */
/* vi.c: see edit.h */
diff --git a/bin/ksh/shf.c b/bin/ksh/shf.c
index 335e55fb65d..fd8969a98d7 100644
--- a/bin/ksh/shf.c
+++ b/bin/ksh/shf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: shf.c,v 1.10 2004/12/18 22:35:41 millert Exp $ */
+/* $OpenBSD: shf.c,v 1.11 2004/12/20 11:34:26 otto Exp $ */
/*
* Shell file I/O routines
@@ -19,19 +19,15 @@
* file descriptors.
*/
-static int shf_fillbuf(struct shf *shf);
-static int shf_emptybuf(struct shf *shf, int flags);
+static int shf_fillbuf(struct shf *);
+static int shf_emptybuf(struct shf *, int);
/* Open a file. First three args are for open(), last arg is flags for
* this package. Returns NULL if file could not be opened, or if a dup
* 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;
@@ -71,10 +67,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;
@@ -124,10 +117,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;
@@ -174,11 +164,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))
@@ -211,8 +197,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;
@@ -231,8 +216,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;
@@ -254,8 +238,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;
@@ -271,8 +254,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;
@@ -290,8 +272,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;
@@ -322,9 +303,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;
@@ -404,8 +383,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;
@@ -451,10 +429,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;
@@ -499,10 +474,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;
@@ -536,10 +508,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;
@@ -578,8 +547,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);
@@ -594,9 +562,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);
@@ -631,9 +597,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);
@@ -675,9 +639,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;
@@ -687,10 +649,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;
@@ -843,8 +802,7 @@ shf_smprintf(const char *fmt, ...)
#include <math.h>
static double
-my_ceil(d)
- double d;
+my_ceil(double d)
{
double i;
@@ -853,10 +811,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 tmp = 0;
diff --git a/bin/ksh/shf.h b/bin/ksh/shf.h
index 8d94434fd52..5104e02a730 100644
--- a/bin/ksh/shf.h
+++ b/bin/ksh/shf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: shf.h,v 1.3 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: shf.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
#ifndef SHF_H
# define SHF_H
@@ -59,26 +59,26 @@ struct shf {
extern struct shf shf_iob[];
-struct shf *shf_open(const char *name, int oflags, int mode, int sflags);
-struct shf *shf_fdopen(int fd, int sflags, struct shf *shf);
-struct shf *shf_reopen(int fd, int sflags, struct shf *shf);
-struct shf *shf_sopen(char *buf, int bsize, int sflags, struct shf *shf);
-int shf_close(struct shf *shf);
-int shf_fdclose(struct shf *shf);
-char *shf_sclose(struct shf *shf);
-int shf_finish(struct shf *shf);
-int shf_flush(struct shf *shf);
-int shf_seek(struct shf *shf, off_t where, int from);
-int shf_read(char *buf, int bsize, struct shf *shf);
-char *shf_getse(char *buf, int bsize, struct shf *shf);
-int shf_getchar(struct shf *shf);
-int shf_ungetc(int c, struct shf *shf);
-int shf_putchar(int c, struct shf *shf);
-int shf_puts(const char *s, struct shf *shf);
-int shf_write(const char *buf, int nbytes, struct shf *shf);
-int shf_fprintf(struct shf *shf, const char *fmt, ...);
-int shf_snprintf(char *buf, int bsize, const char *fmt, ...);
-char *shf_smprintf(const char *fmt, ...);
-int shf_vfprintf(struct shf *, const char *fmt, va_list args);
+struct shf *shf_open(const char *, int, int, int);
+struct shf *shf_fdopen(int, int, struct shf *);
+struct shf *shf_reopen(int, int, struct shf *);
+struct shf *shf_sopen(char *, int, int, struct shf *);
+int shf_close(struct shf *);
+int shf_fdclose(struct shf *);
+char *shf_sclose(struct shf *);
+int shf_finish(struct shf *);
+int shf_flush(struct shf *);
+int shf_seek(struct shf *, off_t, int);
+int shf_read(char *, int, struct shf *);
+char *shf_getse(char *, int, struct shf *);
+int shf_getchar(struct shf *s);
+int shf_ungetc(int, struct shf *);
+int shf_putchar(int, struct shf *);
+int shf_puts(const char *, struct shf *);
+int shf_write(const char *, int, struct shf *);
+int shf_fprintf(struct shf *, const char *, ...);
+int shf_snprintf(char *, int, const char *, ...);
+char *shf_smprintf(const char *, ...);
+int shf_vfprintf(struct shf *, const char *, va_list);
#endif /* SHF_H */
diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c
index 2d1ed02536c..d97fedadc54 100644
--- a/bin/ksh/syn.c
+++ b/bin/ksh/syn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syn.c,v 1.18 2004/12/18 22:42:26 millert Exp $ */
+/* $OpenBSD: syn.c,v 1.19 2004/12/20 11:34:26 otto Exp $ */
/*
* shell parser (C version)
@@ -13,33 +13,32 @@ struct nesting_state {
};
static void yyparse(void);
-static struct op *pipeline(int cf);
+static struct op *pipeline(int);
static struct op *andor(void);
-static struct op *c_list(int multi);
-static struct ioword *synio(int cf);
-static void musthave(int c, int cf);
-static struct op *nested(int type, int smark, int emark);
-static struct op *get_command(int cf);
+static struct op *c_list(int);
+static struct ioword *synio(int);
+static void musthave(int, int);
+static struct op *nested(int, int, int);
+static struct op *get_command(int);
static struct op *dogroup(void);
static struct op *thenpart(void);
static struct op *elsepart(void);
static struct op *caselist(void);
-static struct op *casepart(int endtok);
-static struct op *function_body(char *name, int ksh_func);
+static struct op *casepart(int);
+static struct op *function_body(char *, int);
static char ** wordlist(void);
-static struct op *block(int type, struct op *t1, struct op *t2, char **wp);
-static struct op *newtp(int type);
-static void syntaxerr(const char *what)
- __attribute__((__noreturn__));
-static void nesting_push(struct nesting_state *save, int tok);
-static void nesting_pop(struct nesting_state *saved);
-static int assign_command(char *s);
-static int inalias(struct source *s);
-static int dbtestp_isa(Test_env *te, Test_meta meta);
-static const char *dbtestp_getopnd(Test_env *te, Test_op op, int do_eval);
-static int dbtestp_eval(Test_env *te, Test_op op, const char *opnd1,
- const char *opnd2, int do_eval);
-static void dbtestp_error(Test_env *te, int offset, const char *msg);
+static struct op *block(int, struct op *, struct op *, char **);
+static struct op *newtp(int);
+static void syntaxerr(const char *) __attribute__((__noreturn__));
+static void nesting_push(struct nesting_state *, int);
+static void nesting_pop(struct nesting_state *);
+static int assign_command(char *);
+static int inalias(struct source *);
+static int dbtestp_isa(Test_env *, Test_meta);
+static const char *dbtestp_getopnd(Test_env *, Test_op, int);
+static int dbtestp_eval(Test_env *, Test_op, const char *, const char *,
+ int);
+static void dbtestp_error(Test_env *, int, const char *);
static struct op *outtree; /* yyparse output */
@@ -56,7 +55,7 @@ static int symbol; /* yylex value */
((reject) ? (symbol) : (REJECT, symbol = yylex(cf)))
static void
-yyparse()
+yyparse(void)
{
int c;
@@ -71,8 +70,7 @@ yyparse()
}
static struct op *
-pipeline(cf)
- int cf;
+pipeline(int cf)
{
struct op *t, *p, *tl = NULL;
@@ -92,7 +90,7 @@ pipeline(cf)
}
static struct op *
-andor()
+andor(void)
{
struct op *t, *p;
int c;
@@ -110,8 +108,7 @@ andor()
}
static struct op *
-c_list(multi)
- int multi;
+c_list(int multi)
{
struct op *t = NULL, *p, *tl = NULL;
int c;
@@ -148,8 +145,7 @@ c_list(multi)
}
static struct ioword *
-synio(cf)
- int cf;
+synio(int cf)
{
struct ioword *iop;
int ishere;
@@ -173,16 +169,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;
@@ -195,8 +189,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;
@@ -408,7 +401,7 @@ get_command(cf)
}
static struct op *
-dogroup()
+dogroup(void)
{
int c;
struct op *list;
@@ -431,7 +424,7 @@ dogroup()
}
static struct op *
-thenpart()
+thenpart(void)
{
struct op *t;
@@ -445,7 +438,7 @@ thenpart()
}
static struct op *
-elsepart()
+elsepart(void)
{
struct op *t;
@@ -468,7 +461,7 @@ elsepart()
}
static struct op *
-caselist()
+caselist(void)
{
struct op *t, *tl;
int c;
@@ -494,8 +487,7 @@ caselist()
}
static struct op *
-casepart(endtok)
- int endtok;
+casepart(int endtok)
{
struct op *t;
int c;
@@ -523,9 +515,8 @@ 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;
@@ -584,7 +575,7 @@ function_body(name, ksh_func)
}
static char **
-wordlist()
+wordlist(void)
{
int c;
XPtrV args;
@@ -614,10 +605,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;
@@ -666,7 +654,7 @@ const struct tokeninfo {
};
void
-initkeywords()
+initkeywords(void)
{
struct tokeninfo const *tt;
struct tbl *p;
@@ -683,8 +671,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;
@@ -736,9 +723,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;
@@ -746,15 +731,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;
@@ -769,8 +752,7 @@ newtp(type)
}
struct op *
-compile(s)
- Source *s;
+compile(Source *s)
{
nesting.start_token = 0;
nesting.start_line = 0;
@@ -791,8 +773,7 @@ compile(s)
* $
*/
static int
-assign_command(s)
- char *s;
+assign_command(char *s)
{
char c = *s;
@@ -806,8 +787,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))
@@ -839,9 +819,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;
@@ -885,10 +863,7 @@ dbtestp_isa(te, meta)
}
static const char *
-dbtestp_getopnd(te, op, do_eval)
- Test_env *te;
- Test_op op;
- int do_eval;
+dbtestp_getopnd(Test_env *te, Test_op op, int do_eval)
{
int c = tpeek(ARRAYVAR);
@@ -902,21 +877,14 @@ dbtestp_getopnd(te, op, do_eval)
}
static int
-dbtestp_eval(te, op, opnd1, opnd2, do_eval)
- Test_env *te;
- Test_op op;
- const char *opnd1;
- const char *opnd2;
- int do_eval;
+dbtestp_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2,
+ int do_eval)
{
return 1;
}
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;
diff --git a/bin/ksh/table.c b/bin/ksh/table.c
index 615d17ccdaf..a27cf38c685 100644
--- a/bin/ksh/table.c
+++ b/bin/ksh/table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: table.c,v 1.8 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: table.c,v 1.9 2004/12/20 11:34:26 otto Exp $ */
/*
* dynamic hashed associative table for commands and variables
@@ -8,13 +8,12 @@
#define INIT_TBLS 8 /* initial table size (power of 2) */
-static void texpand(struct table *tp, int nsize);
-static int tnamecmp(void *p1, void *p2);
+static void texpand(struct table *, int);
+static int tnamecmp(void *, void *);
unsigned int
-hash(n)
- const char * n;
+hash(const char *n)
{
unsigned int h = 0;
@@ -24,10 +23,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;
@@ -37,9 +33,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;
@@ -72,10 +66,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;
@@ -95,10 +89,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;
@@ -137,24 +131,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++;
@@ -165,15 +155,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;
@@ -196,8 +184,7 @@ tsort(tp)
void tprintinfo(struct table *tp);
void
-tprintinfo(tp)
- struct table *tp;
+tprintinfo(struct table *tp)
{
struct tbl *te;
char *n;
diff --git a/bin/ksh/tree.c b/bin/ksh/tree.c
index b8c76c69f57..797f6770aeb 100644
--- a/bin/ksh/tree.c
+++ b/bin/ksh/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.14 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: tree.c,v 1.15 2004/12/20 11:34:26 otto Exp $ */
/*
* command tree climbing
@@ -9,23 +9,20 @@
#define INDENT 4
#define tputc(c, shf) shf_putchar(c, shf);
-static void ptree(struct op *t, int indent, struct shf *f);
-static void pioact(struct shf *f, int indent, struct ioword *iop);
-static void tputC(int c, struct shf *shf);
-static void tputS(char *wp, struct shf *shf);
-static void vfptreef(struct shf *shf, int indent, const char *fmt, va_list va);
-static struct ioword **iocopy(struct ioword **iow, Area *ap);
-static void iofree(struct ioword **iow, Area *ap);
+static void ptree(struct op *, int, struct shf *);
+static void pioact(struct shf *, int, struct ioword *);
+static void tputC(int, struct shf *);
+static void tputS(char *, struct shf *);
+static void vfptreef(struct shf *, int, const char *, va_list);
+static struct ioword **iocopy(struct ioword **, Area *);
+static void iofree(struct ioword **, Area *);
/*
* print a command tree
*/
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;
@@ -207,10 +204,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;
@@ -268,9 +262,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);
@@ -283,9 +275,7 @@ tputC(c, shf)
}
static void
-tputS(wp, shf)
- char *wp;
- struct shf *shf;
+tputS(char *wp, struct shf *shf)
{
int c, quoted=0;
@@ -393,11 +383,7 @@ snptreef(char *s, int n, const char *fmt, ...)
}
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;
@@ -465,9 +451,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;
@@ -516,9 +500,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);
@@ -526,9 +508,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;
@@ -582,8 +562,7 @@ wdscan(wp, c)
* (string is allocated from ATEMP)
*/
char *
-wdstrip(wp)
- const char *wp;
+wdstrip(const char *wp)
{
struct shf shf;
int c;
@@ -648,9 +627,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;
@@ -683,9 +660,7 @@ iocopy(iow, ap)
*/
void
-tfree(t, ap)
- struct op *t;
- Area *ap;
+tfree(struct op *t, Area *ap)
{
char **w;
@@ -717,9 +692,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;
diff --git a/bin/ksh/tty.c b/bin/ksh/tty.c
index e197eaffadb..f5748d3aa96 100644
--- a/bin/ksh/tty.c
+++ b/bin/ksh/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.5 2004/12/18 22:35:41 millert Exp $ */
+/* $OpenBSD: tty.c,v 1.6 2004/12/20 11:34:26 otto Exp $ */
#include "sh.h"
#include <sys/stat.h>
@@ -10,8 +10,7 @@
* 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;
@@ -58,7 +57,7 @@ tty_init(init_ttystate)
}
void
-tty_close()
+tty_close(void)
{
if (tty_fd >= 0) {
close(tty_fd);
diff --git a/bin/ksh/tty.h b/bin/ksh/tty.h
index e7935cdaa3c..a7b3aaa8c57 100644
--- a/bin/ksh/tty.h
+++ b/bin/ksh/tty.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.h,v 1.4 2004/12/18 22:12:23 millert Exp $ */
+/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
/*
tty.h -- centralized definitions for a variety of terminal interfaces
@@ -26,7 +26,7 @@ EXTERN int tty_fd I__(-1); /* dup'd tty file descriptor */
EXTERN int tty_devtty; /* true if tty_fd is from /dev/tty */
EXTERN struct termios tty_state; /* saved tty state */
-extern void tty_init(int init_ttystate);
+extern void tty_init(int);
extern void tty_close(void);
/* be sure not to interfere with anyone else's idea about EXTERN */
diff --git a/bin/ksh/var.c b/bin/ksh/var.c
index a9a0b64f783..e43b98b3cf4 100644
--- a/bin/ksh/var.c
+++ b/bin/ksh/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.20 2004/12/18 21:25:44 millert Exp $ */
+/* $OpenBSD: var.c,v 1.21 2004/12/20 11:34:26 otto Exp $ */
#include "sh.h"
#include <time.h>
@@ -17,13 +17,13 @@
*/
static struct tbl vtemp;
static struct table specials;
-static char *formatstr(struct tbl *vp, const char *s);
-static void export(struct tbl *vp, const char *val);
-static int special(const char *name);
-static void unspecial(const char *name);
-static void getspec(struct tbl *vp);
-static void setspec(struct tbl *vp);
-static void unsetspec(struct tbl *vp);
+static char *formatstr(struct tbl *, const char *);
+static void export(struct tbl *, const char *);
+static int special(const char *);
+static void unspecial(const char *);
+static void getspec(struct tbl *);
+static void setspec(struct tbl *);
+static void unsetspec(struct tbl *);
static struct tbl *arraysearch(struct tbl *, int);
/*
@@ -31,7 +31,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};
@@ -57,7 +57,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;
@@ -79,7 +79,7 @@ popblock()
/* called by main() to initialize variable data structures */
void
-initvar()
+initvar(void)
{
static const struct {
const char *name;
@@ -126,10 +126,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;
@@ -159,8 +156,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;
@@ -242,9 +238,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;
@@ -288,8 +282,7 @@ local(n, copy)
/* get variable string value */
char *
-str_val(vp)
- struct tbl *vp;
+str_val(struct tbl *vp)
{
char *s;
@@ -337,8 +330,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;
@@ -352,10 +344,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;
@@ -396,9 +385,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;
@@ -416,9 +403,7 @@ setint(vq, n)
}
int
-getint(vp, nump)
- struct tbl *vp;
- long *nump;
+getint(struct tbl *vp, long int *nump)
{
char *s;
int c;
@@ -475,8 +460,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;
@@ -497,9 +481,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;
@@ -561,9 +543,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;
@@ -587,10 +567,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;
@@ -741,9 +718,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);
@@ -771,9 +746,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;
@@ -788,9 +761,8 @@ 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
@@ -821,9 +793,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);
@@ -832,8 +802,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);
@@ -844,7 +813,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;
@@ -892,7 +861,7 @@ int use_rand = 0;
* if the parent doesn't use $RANDOM.
*/
void
-change_random()
+change_random(void)
{
if (use_rand)
rand();
@@ -904,8 +873,7 @@ change_random()
/* Test if name is a special parameter */
static int
-special(name)
- const char * name;
+special(const char *name)
{
struct tbl *tp;
@@ -915,8 +883,7 @@ special(name)
/* Make a variable non-special */
static void
-unspecial(name)
- const char * name;
+unspecial(const char *name)
{
struct tbl *tp;
@@ -929,8 +896,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)) {
case V_SECONDS:
@@ -972,8 +938,7 @@ getspec(vp)
}
static void
-setspec(vp)
- struct tbl *vp;
+setspec(struct tbl *vp)
{
char *s;
@@ -1072,8 +1037,7 @@ setspec(vp)
}
static void
-unsetspec(vp)
- struct tbl *vp;
+unsetspec(struct tbl *vp)
{
switch (special(vp->name)) {
case V_PATH:
@@ -1126,9 +1090,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;
@@ -1172,8 +1134,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;
@@ -1191,8 +1152,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;
@@ -1206,10 +1166,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;
diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c
index 9b25a2e6d68..d79f27eff66 100644
--- a/bin/ksh/vi.c
+++ b/bin/ksh/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.16 2004/12/19 04:14:20 deraadt Exp $ */
+/* $OpenBSD: vi.c,v 1.17 2004/12/20 11:34:26 otto Exp $ */
/*
* vi command editing
@@ -27,45 +27,45 @@ struct edstate {
};
-static int vi_hook(int ch);
-static void vi_reset(char *buf, size_t len);
-static int nextstate(int ch);
-static int vi_insert(int ch);
-static int vi_cmd(int argcnt, const char *cmd);
-static int domove(int argcnt, const char *cmd, int sub);
-static int redo_insert(int count);
-static void yank_range(int a, int b);
-static int bracktype(int ch);
+static int vi_hook(int);
+static void vi_reset(char *, size_t);
+static int nextstate(int);
+static int vi_insert(int);
+static int vi_cmd(int, const char *);
+static int domove(int, const char *, int);
+static int redo_insert(int);
+static void yank_range(int, int);
+static int bracktype(int);
static void save_cbuf(void);
static void restore_cbuf(void);
-static void edit_reset(char *buf, size_t len);
-static int putbuf(const char *buf, int len, int repl);
-static void del_range(int a, int b);
-static int findch(int ch, int cnt, int forw, int incl);
-static int forwword(int argcnt);
-static int backword(int argcnt);
-static int endword(int argcnt);
-static int Forwword(int argcnt);
-static int Backword(int argcnt);
-static int Endword(int argcnt);
-static int grabhist(int save, int n);
-static int grabsearch(int save, int start, int fwd, char *pat);
-static void redraw_line(int newline);
-static void refresh(int leftside);
+static void edit_reset(char *, size_t);
+static int putbuf(const char *, int, int);
+static void del_range(int, int);
+static int findch(int, int, int, int);
+static int forwword(int);
+static int backword(int);
+static int endword(int);
+static int Forwword(int);
+static int Backword(int);
+static int Endword(int);
+static int grabhist(int, int);
+static int grabsearch(int, int, int, char *);
+static void redraw_line(int);
+static void refresh(int);
static int outofwin(void);
static void rewindow(void);
-static int newcol(int ch, int col);
-static void display(char *wb1, char *wb2, int leftside);
-static void ed_mov_opt(int col, char *wb);
-static int expand_word(int command);
-static int complete_word(int command, int count);
-static int print_expansions(struct edstate *e, int command);
-static int char_len(int c);
-static void x_vi_zotc(int c);
-static void vi_pprompt(int full);
+static int newcol(int, int);
+static void display(char *, char *, int);
+static void ed_mov_opt(int, char *);
+static int expand_word(int);
+static int complete_word(int, int);
+static int print_expansions(struct edstate *, int);
+static int char_len(int);
+static void x_vi_zotc(int);
+static void vi_pprompt(int);
static void vi_error(void);
static void vi_macro_reset(void);
-static int x_vi_putbuf(const char *s, size_t len);
+static int x_vi_putbuf(const char *, size_t);
#define C_ 0x1 /* a valid command that isn't a M_, E_, U_ */
#define M_ 0x2 /* movement command (h, l, etc.) */
@@ -188,9 +188,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;
@@ -250,8 +248,7 @@ x_vi(buf, len)
}
static int
-vi_hook(ch)
- int ch;
+vi_hook(int ch)
{
static char curcmd[MAXVICMD];
static char locpat[SRCHLEN];
@@ -524,9 +521,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;
@@ -540,8 +535,7 @@ vi_reset(buf, len)
}
static int
-nextstate(ch)
- int ch;
+nextstate(int ch)
{
if (is_extend(ch))
return VEXTCMD;
@@ -560,8 +554,7 @@ nextstate(ch)
}
static int
-vi_insert(ch)
- int ch;
+vi_insert(int ch)
{
int tcursor;
@@ -689,9 +682,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;
@@ -1142,10 +1133,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, i = 0, t;
int ncursor = 0;
@@ -1292,8 +1280,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)
@@ -1305,8 +1292,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)
@@ -1314,8 +1300,7 @@ yank_range(a, b)
}
static int
-bracktype(ch)
- int ch;
+bracktype(int ch)
{
switch (ch) {
@@ -1360,7 +1345,7 @@ static char holdbuf[CMDLEN]; /* 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;
@@ -1368,7 +1353,7 @@ save_cbuf()
}
static void
-restore_cbuf()
+restore_cbuf(void)
{
es->cursor = 0;
es->linelen = holdlen;
@@ -1377,8 +1362,7 @@ restore_cbuf()
/* return a new edstate */
static struct edstate *
-save_edstate(old)
- struct edstate *old;
+save_edstate(struct edstate *old)
{
struct edstate *new;
@@ -1393,8 +1377,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;
@@ -1404,8 +1387,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);
@@ -1414,9 +1396,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;
@@ -1456,18 +1436,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;
@@ -1489,8 +1464,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);
@@ -1498,11 +1472,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;
@@ -1530,8 +1500,7 @@ findch(ch, cnt, forw, incl)
}
static int
-forwword(argcnt)
- int argcnt;
+forwword(int argcnt)
{
int ncursor;
@@ -1553,8 +1522,7 @@ forwword(argcnt)
}
static int
-backword(argcnt)
- int argcnt;
+backword(int argcnt)
{
int ncursor;
@@ -1579,8 +1547,7 @@ backword(argcnt)
}
static int
-endword(argcnt)
- int argcnt;
+endword(int argcnt)
{
int ncursor;
@@ -1606,8 +1573,7 @@ endword(argcnt)
}
static int
-Forwword(argcnt)
- int argcnt;
+Forwword(int argcnt)
{
int ncursor;
@@ -1622,8 +1588,7 @@ Forwword(argcnt)
}
static int
-Backword(argcnt)
- int argcnt;
+Backword(int argcnt)
{
int ncursor;
@@ -1639,8 +1604,7 @@ Backword(argcnt)
}
static int
-Endword(argcnt)
- int argcnt;
+Endword(int argcnt)
{
int ncursor;
@@ -1660,9 +1624,7 @@ Endword(argcnt)
}
static int
-grabhist(save, n)
- int save;
- int n;
+grabhist(int save, int n)
{
char *hptr;
@@ -1689,9 +1651,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;
@@ -1725,8 +1685,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) {
@@ -1739,8 +1698,7 @@ redraw_line(newline)
}
static void
-refresh(leftside)
- int leftside;
+refresh(int leftside)
{
if (leftside < 0)
leftside = lastref;
@@ -1753,7 +1711,7 @@ refresh(leftside)
}
static int
-outofwin()
+outofwin(void)
{
int cur, col;
@@ -1769,7 +1727,7 @@ outofwin()
}
static void
-rewindow()
+rewindow(void)
{
int tcur, tcol;
int holdcur1, holdcol1;
@@ -1793,8 +1751,7 @@ rewindow()
}
static int
-newcol(ch, col)
- int ch, col;
+newcol(int ch, int col)
{
if (ch == '\t')
return (col | 7) + 1;
@@ -1802,9 +1759,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;
@@ -1897,9 +1852,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) {
@@ -1923,8 +1876,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;
@@ -1978,9 +1930,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;
@@ -2087,9 +2037,7 @@ complete_word(command, count)
}
static int
-print_expansions(e, command)
- struct edstate *e;
- int command;
+print_expansions(struct edstate *e, int command)
{
int nwords;
int start, end;
@@ -2111,8 +2059,7 @@ print_expansions(e, command)
/* How long is char when displayed (not counting tabs) */
static int
-char_len(c)
- int c;
+char_len(int c)
{
int len = 1;
@@ -2127,8 +2074,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-");
@@ -2142,14 +2088,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();
@@ -2158,7 +2103,7 @@ vi_error()
}
static void
-vi_macro_reset()
+vi_macro_reset(void)
{
if (macro.p) {
afree(macro.buf, APERM);