From 0cb589cee4e70d3b7d2bd09f942e1655015aa30b Mon Sep 17 00:00:00 2001 From: Santurysim Date: Wed, 23 Jun 2021 11:11:23 +0300 Subject: [PATCH] Revert "Cleanup: ksh: convert all K&R-style funtion definitions to ANSI-style" This reverts commit e47e5f169423a1bd4c029b3e41268c5644cded19. --- bin/ksh/c_ksh.c | 52 ++++++--- bin/ksh/c_sh.c | 57 ++++++--- bin/ksh/c_test.c | 64 +++++++--- bin/ksh/c_test.h | 1 - bin/ksh/c_ulimit.c | 4 +- bin/ksh/conf-end.h | 1 - bin/ksh/edit.c | 103 +++++++++++++---- bin/ksh/edit.h | 1 - bin/ksh/emacs.c | 269 ++++++++++++++++++++++++++++--------------- bin/ksh/eval.c | 93 ++++++++++----- bin/ksh/exec.c | 122 ++++++++++++++------ bin/ksh/expand.h | 1 - bin/ksh/expr.c | 40 +++++-- bin/ksh/history.c | 113 ++++++++++++------ bin/ksh/io.c | 106 ++++++++++++++--- bin/ksh/jobs.c | 99 ++++++++++------ bin/ksh/ksh_dir.h | 1 - bin/ksh/ksh_limval.h | 1 - bin/ksh/ksh_stat.h | 1 - bin/ksh/ksh_time.h | 1 - bin/ksh/ksh_times.h | 1 - bin/ksh/ksh_wait.h | 1 - bin/ksh/lex.c | 50 +++++--- bin/ksh/lex.h | 1 - bin/ksh/mail.c | 22 ++-- bin/ksh/main.c | 39 ++++--- bin/ksh/misc.c | 148 ++++++++++++++++-------- bin/ksh/path.c | 27 +++-- bin/ksh/proto.h | 1 - bin/ksh/sh.h | 1 - bin/ksh/shf.c | 109 ++++++++++++++---- bin/ksh/shf.h | 1 - bin/ksh/sigact.c | 43 ++++--- bin/ksh/sigact.h | 1 - bin/ksh/syn.c | 93 ++++++++++----- bin/ksh/table.c | 52 +++++---- bin/ksh/table.h | 1 - bin/ksh/trap.c | 49 +++++--- bin/ksh/tree.c | 69 ++++++++--- bin/ksh/tree.h | 1 - bin/ksh/tty.c | 15 ++- bin/ksh/tty.h | 1 - bin/ksh/var.c | 111 ++++++++++++------ bin/ksh/version.c | 1 - bin/ksh/vi.c | 140 +++++++++++++++------- 45 files changed, 1456 insertions(+), 652 deletions(-) diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c index e3aef04a8..5fff393d6 100644 --- a/bin/ksh/c_ksh.c +++ b/bin/ksh/c_ksh.c @@ -18,7 +18,8 @@ __RCSID("$NetBSD: c_ksh.c,v 1.18 2011/10/16 17:12:11 joerg Exp $"); #endif /* __CYGWIN__ */ int -c_cd(char **wp) +c_cd(wp) + char **wp; { int optc; int physical = Flag(FPHYSICAL); @@ -185,7 +186,8 @@ c_cd(char **wp) } int -c_pwd(char **wp) +c_pwd(wp) + char **wp; { int optc; int physical = Flag(FPHYSICAL); @@ -231,7 +233,8 @@ c_pwd(char **wp) } int -c_print(char **wp) +c_print(wp) + char **wp; { #define PO_NL BIT(0) /* print newline */ #define PO_EXPAND BIT(1) /* expand backslash sequences */ @@ -454,7 +457,8 @@ c_print(char **wp) } int -c_whence(char **wp) +c_whence(wp) + char **wp; { struct tbl *tp; char *id; @@ -576,7 +580,8 @@ c_whence(char **wp) /* Deal with command -vV - command -p dealt with in comexec() */ int -c_command(char **wp) +c_command(wp) + char **wp; { /* Let c_whence do the work. Note that c_command() must be * a distinct function from c_whence() (tested in comexec()). @@ -586,7 +591,8 @@ c_command(char **wp) /* typeset, export, and readonly */ int -c_typeset(char **wp) +c_typeset(wp) + char **wp; { struct block *l = e->loc; struct tbl *vp, **p; @@ -882,7 +888,8 @@ c_typeset(char **wp) } int -c_alias(char **wp) +c_alias(wp) + char **wp; { struct table *t = &aliases; int rv = 0, rflag = 0, tflag, Uflag = 0, pflag = 0; @@ -1018,7 +1025,8 @@ c_alias(char **wp) } int -c_unalias(char **wp) +c_unalias(wp) + char **wp; { register struct table *t = &aliases; register struct tbl *ap; @@ -1071,7 +1079,8 @@ c_unalias(char **wp) #ifdef KSH int -c_let(char **wp) +c_let(wp) + char **wp; { int rv = 1; long val; @@ -1090,7 +1099,8 @@ c_let(char **wp) #endif /* KSH */ int -c_jobs(char **wp) +c_jobs(wp) + char **wp; { int optc; int flag = 0; @@ -1128,7 +1138,8 @@ c_jobs(char **wp) #ifdef JOBS int -c_fgbg(char **wp) +c_fgbg(wp) + char **wp; { int bg = strcmp(*wp, "bg") == 0; int UNINITIALIZED(rv); @@ -1160,7 +1171,11 @@ static char *kill_fmt_entry ARGS((void *arg, int i, char *buf, int buflen)); /* format a single kill item */ static char * -kill_fmt_entry(void *arg, int i, char *buf, int buflen) +kill_fmt_entry(arg, i, buf, buflen) + void *arg; + int i; + char *buf; + int buflen; { struct kill_info *ki = (struct kill_info *) arg; @@ -1180,7 +1195,8 @@ kill_fmt_entry(void *arg, int i, char *buf, int buflen) int -c_kill(char **wp) +c_kill(wp) + char **wp; { Trap *t = (Trap *) 0; char *p; @@ -1291,7 +1307,8 @@ c_kill(char **wp) } void -getopts_reset(int val) +getopts_reset(val) + int val; { if (val >= 1) { ksh_getopt_reset(&user_opt, @@ -1301,7 +1318,8 @@ getopts_reset(int val) } int -c_getopts(char **wp) +c_getopts(wp) + char **wp; { int argc; const char *options; @@ -1400,7 +1418,8 @@ c_getopts(char **wp) #ifdef EMACS int -c_bind(char **wp) +c_bind(wp) + char **wp; { int rv = 0, macro = 0, list = 0; register char *cp; @@ -1469,4 +1488,3 @@ const struct builtin kshbuiltins [] = { #endif {NULL, NULL} }; - diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c index ad68e8ea2..dbda824d5 100644 --- a/bin/ksh/c_sh.c +++ b/bin/ksh/c_sh.c @@ -20,13 +20,15 @@ static char *clocktos ARGS((clock_t t)); /* :, false and true */ int -c_label(char **wp) +c_label(wp) + char **wp; { return wp[0][0] == 'f' ? 1 : 0; } int -c_shift(char **wp) +c_shift(wp) + char **wp; { register struct block *l = e->loc; register int n; @@ -57,7 +59,8 @@ c_shift(char **wp) } int -c_umask(char **wp) +c_umask(wp) + char **wp; { register int i; register char *cp; @@ -176,7 +179,8 @@ c_umask(char **wp) } int -c_dot(char **wp) +c_dot(wp) + char **wp; { char *file, *cp; char **argv; @@ -214,7 +218,8 @@ c_dot(char **wp) } int -c_wait(char **wp) +c_wait(wp) + char **wp; { int UNINITIALIZED(rv); int sig; @@ -236,7 +241,8 @@ c_wait(char **wp) } int -c_read(char **wp) +c_read(wp) + char **wp; { register int c = 0; int expandv = 1, history = 0; @@ -422,7 +428,8 @@ c_read(char **wp) } int -c_eval(char **wp) +c_eval(wp) + char **wp; { register struct source *s; int rv; @@ -465,7 +472,8 @@ c_eval(char **wp) } int -c_trap(char **wp) +c_trap(wp) + char **wp; { int i; char *s; @@ -526,7 +534,8 @@ c_trap(char **wp) } int -c_exitreturn(char **wp) +c_exitreturn(wp) + char **wp; { int how = LEXIT; int n; @@ -568,7 +577,8 @@ c_exitreturn(char **wp) } int -c_brkcont(char **wp) +c_brkcont(wp) + char **wp; { int n, quit; struct env *ep, *last_ep = (struct env *) 0; @@ -622,7 +632,8 @@ c_brkcont(char **wp) } int -c_set(char **wp) +c_set(wp) + char **wp; { int argi, setargs; struct block *l = e->loc; @@ -657,7 +668,8 @@ c_set(char **wp) } int -c_unset(char **wp) +c_unset(wp) + char **wp; { register char *id; int optc, unset_var = 1; @@ -694,7 +706,8 @@ c_unset(char **wp) } int -c_times(char **wp) +c_times(wp) + char **wp; { struct tms all; @@ -711,7 +724,9 @@ c_times(char **wp) * time pipeline (really a statement, not a built-in command) */ int -timex(struct op *t, int f) +timex(t, f) + struct op *t; + int f; { #define TF_NOARGS BIT(0) #define TF_NOREAL BIT(1) /* don't report real time */ @@ -766,7 +781,9 @@ timex(struct op *t, int f) } void -timex_hook(struct op *t, char ** volatile *app) +timex_hook(t, app) + struct op *t; + char ** volatile *app; { char **wp = *app; int optc; @@ -799,7 +816,8 @@ timex_hook(struct op *t, char ** volatile *app) } static char * -clocktos(clock_t t) +clocktos(t) + clock_t t; { static char temp[22]; /* enough for 64 bit clock_t */ register int i; @@ -824,7 +842,8 @@ clocktos(clock_t t) /* exec with no args - args case is taken care of in comexec() */ int -c_exec(char **wp) +c_exec(wp) + char ** wp; { int i; @@ -851,7 +870,8 @@ c_exec(char **wp) /* dummy function, special case in comexec() */ int -c_builtin(char **wp) +c_builtin(wp) + char ** wp; { return 0; } @@ -897,4 +917,3 @@ const struct builtin shbuiltins [] = { #endif /* OS2 */ {NULL, NULL} }; - diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c index bc75df37b..41e10fed5 100644 --- a/bin/ksh/c_test.c +++ b/bin/ksh/c_test.c @@ -106,7 +106,8 @@ static int ptest_eval ARGS((Test_env *, Test_op, const char *, static void ptest_error ARGS((Test_env *, int, const char *)); int -c_test(char **wp) +c_test(wp) + char **wp; { int argc; int res; @@ -190,7 +191,10 @@ c_test(char **wp) */ Test_op -test_isop(Test_env *te, Test_meta meta, const char *s) +test_isop(te, meta, s) + Test_env *te; + Test_meta meta; + const char *s; { char sc1; const struct t_op *otab; @@ -210,7 +214,12 @@ 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) +test_eval(te, op, opnd1, opnd2, do_eval) + Test_env *te; + Test_op op; + const char *opnd1; + const char *opnd2; + int do_eval; { int res; int not; @@ -415,7 +424,9 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, int do /* Nasty kludge to handle Korn's bizarre /dev/fd hack */ static int -test_stat(const char *pathx, struct stat *statb) +test_stat(pathx, statb) + const char *pathx; + struct stat *statb; { #if !defined(HAVE_DEV_FD) int fd; @@ -431,7 +442,9 @@ test_stat(const char *pathx, struct stat *statb) * non-directories when running as root. */ static int -test_eaccess(const char *pathx, int mode) +test_eaccess(pathx, mode) + const char *pathx; + int mode; { int res; @@ -472,7 +485,8 @@ test_eaccess(const char *pathx, int mode) } int -test_parse(Test_env *te) +test_parse(te) + Test_env *te; { int res; @@ -485,7 +499,9 @@ test_parse(Test_env *te) } static int -test_oexpr(Test_env *te, int do_eval) +test_oexpr(te, do_eval) + Test_env *te; + int do_eval; { int res; @@ -498,7 +514,9 @@ test_oexpr(Test_env *te, int do_eval) } static int -test_aexpr(Test_env *te, int do_eval) +test_aexpr(te, do_eval) + Test_env *te; + int do_eval; { int res; @@ -511,7 +529,9 @@ test_aexpr(Test_env *te, int do_eval) } static int -test_nexpr(Test_env *te, int do_eval) +test_nexpr(te, do_eval) + Test_env *te; + int do_eval; { if (!(te->flags & TEF_ERROR) && (*te->isa)(te, TM_NOT)) return !test_nexpr(te, do_eval); @@ -519,7 +539,9 @@ test_nexpr(Test_env *te, int do_eval) } static int -test_primary(Test_env *te, int do_eval) +test_primary(te, do_eval) + Test_env *te; + int do_eval; { const char *opnd1, *opnd2; int res; @@ -578,7 +600,9 @@ test_primary(Test_env *te, int do_eval) * TM_UNOP and TM_BINOP, the returned value is a Test_op). */ static int -ptest_isa(Test_env *te, Test_meta meta) +ptest_isa(te, meta) + Test_env *te; + Test_meta meta; { /* Order important - indexed by Test_meta values */ static const char *const tokens[] = { @@ -604,7 +628,10 @@ ptest_isa(Test_env *te, Test_meta meta) } static const char * -ptest_getopnd(Test_env *te, Test_op op, int do_eval) +ptest_getopnd(te, op, do_eval) + Test_env *te; + Test_op op; + int do_eval; { if (te->pos.wp >= te->wp_end) return op == TO_FILTT ? "1" : (const char *) 0; @@ -612,13 +639,21 @@ 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) +ptest_eval(te, op, opnd1, opnd2, do_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(Test_env *te, int offset, const char *msg) +ptest_error(te, offset, msg) + 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]; @@ -629,4 +664,3 @@ ptest_error(Test_env *te, int offset, const char *msg) else bi_errorf("%s", msg); } - diff --git a/bin/ksh/c_test.h b/bin/ksh/c_test.h index 6986b79bd..f1182f3f6 100644 --- a/bin/ksh/c_test.h +++ b/bin/ksh/c_test.h @@ -53,4 +53,3 @@ Test_op test_isop ARGS((Test_env *te, Test_meta meta, const char *s)); int test_eval ARGS((Test_env *te, Test_op op, const char *opnd1, const char *opnd2, int do_eval)); int test_parse ARGS((Test_env *te)); - diff --git a/bin/ksh/c_ulimit.c b/bin/ksh/c_ulimit.c index 8da0e45b8..08da473bf 100644 --- a/bin/ksh/c_ulimit.c +++ b/bin/ksh/c_ulimit.c @@ -47,7 +47,8 @@ extern long ulimit(); #endif /* RLIM_INFINITY */ int -c_ulimit(char **wp) +c_ulimit(wp) + char **wp; { static const struct limits { const char *name; @@ -289,4 +290,3 @@ c_ulimit(char **wp) } return 0; } - diff --git a/bin/ksh/conf-end.h b/bin/ksh/conf-end.h index 886d6f3bf..67451f1c9 100644 --- a/bin/ksh/conf-end.h +++ b/bin/ksh/conf-end.h @@ -55,4 +55,3 @@ # define GCC_FUNC_ATTR(x) # define GCC_FUNC_ATTR2(x,y) #endif /* HAVE_GCC_FUNC_ATTR */ - diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c index f42b0ae6f..07a2f908e 100644 --- a/bin/ksh/edit.c +++ b/bin/ksh/edit.c @@ -87,7 +87,8 @@ x_init() #if defined(TIOCGWINSZ) static RETSIGTYPE -x_sigwinch(int sig) +x_sigwinch(sig) + int sig; { got_sigwinch = 1; return RETSIGVAL; @@ -128,7 +129,9 @@ check_sigwinch ARGS((void)) * read an edited command line */ int -x_read(char *buf, size_t len) +x_read(buf, len) + char *buf; + size_t len; { int i; @@ -178,26 +181,29 @@ x_getc() } void -x_flush(void) +x_flush() { shf_flush(shl_out); } void -x_putc(int c) +x_putc(c) + int c; { shf_putc(c, shl_out); } void -x_puts(const char *s) +x_puts(s) + const char *s; { while (*s != 0) shf_putc(*s++, shl_out); } bool_t -x_mode(bool_t onoff) +x_mode(onoff) + bool_t onoff; { static bool_t x_cur_mode; bool_t prev; @@ -330,7 +336,9 @@ x_mode(bool_t onoff) * length */ int -promptlen(const char *cp, const char **spp) +promptlen(cp, spp) + const char *cp; + const char **spp; { int count = 0; const char *sp = cp; @@ -370,7 +378,8 @@ promptlen(const char *cp, const char **spp) } void -set_editmode(const char *ed) +set_editmode(ed) + const char *ed; { static const enum sh_flag edit_flags[] = { #ifdef EMACS @@ -404,7 +413,10 @@ set_editmode(const char *ed) * moved to the start of the line after (un)commenting. */ int -x_do_comment(char *buf, int bsize, int *lenp) +x_do_comment(buf, bsize, lenp) + char *buf; + int bsize; + int *lenp; { int i, j; int len = *lenp; @@ -482,7 +494,10 @@ x_complete_word(str, slen, is_command, nwordsp, ret) #endif /* 0 */ void -x_print_expansions(int nwords, char *const *words, int is_command) +x_print_expansions(nwords, words, is_command) + int nwords; + char *const *words; + int is_command; { int use_copy = 0; int prefix_len; @@ -538,7 +553,11 @@ x_print_expansions(int nwords, char *const *words, int is_command) * - returns number of matching strings */ static int -x_file_glob(int flags, const char *str, int slen, char ***wordsp) +x_file_glob(flags, str, slen, wordsp) + int flags; + const char *str; + int slen; + char ***wordsp; { char *toglob; char **words; @@ -626,7 +645,9 @@ static int path_order_cmp(const void *aa, const void *bb); /* Compare routine used in x_command_glob() */ static int -path_order_cmp(const void *aa, const void *bb) +path_order_cmp(aa, bb) + 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; @@ -637,7 +658,11 @@ path_order_cmp(const void *aa, const void *bb) } static int -x_command_glob(int flags, const char *str, int slen, char ***wordsp) +x_command_glob(flags, str, slen, wordsp) + int flags; + const char *str; + int slen; + char ***wordsp; { char *toglob; char *pat; @@ -731,8 +756,12 @@ x_command_glob(int flags, const char *str, int slen, char ***wordsp) || (c) == '`' || (c) == '=' || (c) == ':' ) static int -x_locate_word(const char *buf, int buflen, int pos, int *startp, - int *is_commandp) +x_locate_word(buf, buflen, pos, startp, is_commandp) + const char *buf; + int buflen; + int pos; + int *startp; + int *is_commandp; { int p; int start, end; @@ -784,8 +813,15 @@ x_locate_word(const char *buf, int buflen, int pos, int *startp, } int -x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp, - int *endp, char ***wordsp, int *is_commandp) +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; { int len; int nwords; @@ -821,7 +857,9 @@ x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp, * new string is returned. */ static char * -add_glob(const char *str, int slen) +add_glob(str, slen) + const char *str; + int slen; { char *toglob; char *s; @@ -860,7 +898,9 @@ add_glob(const char *str, int slen) * Find longest common prefix */ int -x_longest_prefix(int nwords, char *const *words) +x_longest_prefix(nwords, words) + int nwords; + char *const *words; { int i, j; int prefix_len; @@ -881,7 +921,9 @@ x_longest_prefix(int nwords, char *const *words) } void -x_free_words(int nwords, char **words) +x_free_words(nwords, words) + int nwords; + char **words; { int i; @@ -904,7 +946,9 @@ x_free_words(int nwords, char **words) * 0 */ int -x_basename(const char *s, const char *se) +x_basename(s, se) + const char *s; + const char *se; { const char *p; @@ -929,7 +973,10 @@ x_basename(const char *s, const char *se) * are added to wp. */ static void -glob_table(const char *pat, XPtrV *wp, struct table *tp) +glob_table(pat, wp, tp) + const char *pat; + XPtrV *wp; + struct table *tp; { struct tstate ts; struct tbl *te; @@ -941,7 +988,11 @@ glob_table(const char *pat, XPtrV *wp, struct table *tp) } static void -glob_path(int flags, const char *pat, XPtrV *wp, const char *xpath) +glob_path(flags, pat, wp, xpath) + int flags; + const char *pat; + XPtrV *wp; + const char *xpath; { const char *sp, *p; char *xp; @@ -1011,7 +1062,10 @@ glob_path(int flags, const char *pat, XPtrV *wp, const char *xpath) * keybinding-specific function */ int -x_escape(const char *s, size_t len, int (*putbuf_func)(const char *, size_t)) +x_escape(s, len, putbuf_func) + const char *s; + size_t len; + int (*putbuf_func) ARGS((const char *, size_t)); { size_t add, wlen; const char *ifs = str_val(local("IFS", 0)); @@ -1039,4 +1093,3 @@ x_escape(const char *s, size_t len, int (*putbuf_func)(const char *, size_t)) return (rval); } #endif /* EDIT */ - diff --git a/bin/ksh/edit.h b/bin/ksh/edit.h index 48d2a9e00..c0bc8c50f 100644 --- a/bin/ksh/edit.h +++ b/bin/ksh/edit.h @@ -85,4 +85,3 @@ int x_vi ARGS((char *buf, size_t len)); * comment-column:40 * End: */ - diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c index 24d2f1af1..2177da3ef 100644 --- a/bin/ksh/emacs.c +++ b/bin/ksh/emacs.c @@ -414,7 +414,8 @@ x_emacs(buf, len) } static int -x_insert(int c) +x_insert(c) + int c; { char str[2]; @@ -433,7 +434,8 @@ x_insert(int c) } static int -x_ins_string(int c) +x_ins_string(c) + int c; { if (macroptr) { x_e_putc(BEL); @@ -450,7 +452,9 @@ x_ins_string(int c) static int x_do_ins(const char *cp, int len); static int -x_do_ins(const char *cp, int len) +x_do_ins(cp, len) + const char *cp; + int len; { if (xep+len >= xend) { x_e_putc(BEL); @@ -465,7 +469,8 @@ x_do_ins(const char *cp, int len) } static int -x_ins(char *s) +x_ins(s) + char *s; { char *cp = xcp; register int adj = x_adj_done; @@ -495,7 +500,9 @@ x_ins(char *s) * this is used for x_escape() in do_complete() */ static int -x_emacs_putbuf(const char *s, size_t len) +x_emacs_putbuf(s, len) + const char *s; + size_t len; { int rval; @@ -505,7 +512,8 @@ x_emacs_putbuf(const char *s, size_t len) } static int -x_del_back(int c) +x_del_back(c) + int c; { int col = xcp - xbuf; @@ -521,7 +529,8 @@ x_del_back(int c) } static int -x_del_char(int c) +x_del_char(c) + int c; { int nleft = xep - xcp; @@ -537,7 +546,9 @@ x_del_char(int c) /* Delete nc chars to the right of the cursor (including cursor position) */ static void -x_delete(int nc, int push) +x_delete(nc, push) + int nc; + int push; { int i,j; char *cp; @@ -592,35 +603,39 @@ x_delete(int nc, int push) } static int -x_del_bword(int c) +x_del_bword(c) + int c; { x_delete(x_bword(), TRUE); return KSTD; } static int -x_mv_bword(int c) +x_mv_bword(c) + int c; { (void)x_bword(); return KSTD; } static int -x_mv_fword(int c) +x_mv_fword(c) + int c; { x_goto(xcp + x_fword()); return KSTD; } static int -x_del_fword(int c) +x_del_fword(c) + int c; { x_delete(x_fword(), TRUE); return KSTD; } static int -x_bword(void) +x_bword() { int nc = 0; register char *cp = xcp; @@ -647,7 +662,7 @@ x_bword(void) } static int -x_fword(void) +x_fword() { int nc = 0; register char *cp = xcp; @@ -673,7 +688,8 @@ x_fword(void) } static void -x_goto(register char *cp) +x_goto(cp) + register char *cp; { if (cp < xbp || cp >= (xbp + x_displen)) { @@ -700,7 +716,8 @@ x_goto(register char *cp) } static void -x_bs(int c) +x_bs(c) + int c; { register int i; i = x_size(c); @@ -709,7 +726,8 @@ x_bs(int c) } static int -x_size_str(register char *cp) +x_size_str(cp) + register char *cp; { register int size = 0; while (*cp) @@ -718,7 +736,8 @@ x_size_str(register char *cp) } static int -x_size(int c) +x_size(c) + int c; { if (c=='\t') return 4; /* Kludge, tabs are always four spaces. */ @@ -728,7 +747,8 @@ x_size(int c) } static void -x_zots(register char *str) +x_zots(str) + register char *str; { register int adj = x_adj_done; @@ -738,7 +758,8 @@ x_zots(register char *str) } static void -x_zotc(int c) +x_zotc(c) + int c; { if (c == '\t') { /* Kludge, tabs are always four spaces. */ @@ -751,7 +772,8 @@ x_zotc(int c) } static int -x_mv_back(int c) +x_mv_back(c) + int c; { int col = xcp - xbuf; @@ -766,7 +788,8 @@ x_mv_back(int c) } static int -x_mv_forw(int c) +x_mv_forw(c) + int c; { int nleft = xep - xcp; @@ -781,7 +804,8 @@ x_mv_forw(int c) } static int -x_search_char_forw(int c) +x_search_char_forw(c) + int c; { char *cp = xcp; @@ -801,7 +825,8 @@ x_search_char_forw(int c) } static int -x_search_char_back(int c) +x_search_char_back(c) + int c; { char *cp = xcp, *p; @@ -822,7 +847,8 @@ x_search_char_back(int c) } static int -x_newline(int c) +x_newline(c) + int c; { x_e_putc('\r'); x_e_putc('\n'); @@ -832,7 +858,8 @@ x_newline(int c) } static int -x_end_of_text(int c) +x_end_of_text(c) + int c; { return KEOL; } @@ -850,7 +877,8 @@ static int x_next_com(c) int c; { x_load_hist(x_histp + x_arg); return KSTD;} * want so we'll simply go to the oldest one. */ static int -x_goto_hist(int c) +x_goto_hist(c) + int c; { if (x_arg_defaulted) x_load_hist(histlist); @@ -860,7 +888,8 @@ x_goto_hist(int c) } static void -x_load_hist(register char **hp) +x_load_hist(hp) + register char **hp; { int oldsize; @@ -881,14 +910,16 @@ x_load_hist(register char **hp) } static int -x_nl_next_com(int c) +x_nl_next_com(c) + int c; { x_nextcmd = source->line - (histptr - x_histp) + 1; return (x_newline(c)); } static int -x_eot_del(int c) +x_eot_del(c) + int c; { if (xep == xbuf && x_arg_defaulted) return (x_end_of_text(c)); @@ -898,7 +929,8 @@ x_eot_del(int c) /* reverse incremental history search */ static int -x_search_hist(int c) +x_search_hist(c) + int c; { int offset = -1; /* offset of match in xbuf, else -1 */ char pat [256+1]; /* pattern buffer */ @@ -960,7 +992,10 @@ x_search_hist(int c) /* search backward from current line */ static int -x_search(char *pat, int sameline, int offset) +x_search(pat, sameline, offset) + char *pat; + int sameline; + int offset; { register char **hp; int i; @@ -982,7 +1017,8 @@ x_search(char *pat, int sameline, int offset) /* return position of first match of pattern in string, else -1 */ static int -x_match(char *str, char *pat) +x_match(str, pat) + char *str, *pat; { if (*pat == '^') { return (strncmp(str, pat+1, strlen(pat+1)) == 0) ? 0 : -1; @@ -993,7 +1029,8 @@ x_match(char *str, char *pat) } static int -x_del_line(int c) +x_del_line(c) + int c; { int i, j; @@ -1011,21 +1048,24 @@ x_del_line(int c) } static int -x_mv_end(int c) +x_mv_end(c) + int c; { x_goto(xep); return KSTD; } static int -x_mv_begin(int c) +x_mv_begin(c) + int c; { x_goto(xbuf); return KSTD; } static int -x_draw_line(int c) +x_draw_line(c) + int c; { x_redraw(-1); return KSTD; @@ -1037,7 +1077,8 @@ x_draw_line(int c) * redrawing. */ static void -x_redraw(int limit) +x_redraw(limit) + int limit; { int i, j; char *cp; @@ -1092,7 +1133,8 @@ x_redraw(int limit) } static int -x_transpose(int c) +x_transpose(c) + int c; { char tmp; @@ -1144,21 +1186,24 @@ x_transpose(int c) } static int -x_literal(int c) +x_literal(c) + int c; { x_curprefix = -1; return KSTD; } static int -x_meta1(int c) +x_meta1(c) + int c; { x_curprefix = 1; return KSTD; } static int -x_meta2(int c) +x_meta2(c) + int c; { x_curprefix = 2; return KSTD; @@ -1166,7 +1211,8 @@ x_meta2(int c) #ifdef OS2 static int -x_meta3(int c) +x_meta3(c) + int c; { x_curprefix = 3; return KSTD; @@ -1174,7 +1220,8 @@ x_meta3(int c) #endif /* OS2 */ static int -x_kill(int c) +x_kill(c) + int c; { int col = xcp - xbuf; int lastcol = xep - xbuf; @@ -1194,7 +1241,8 @@ x_kill(int c) } static void -x_push(int nchars) +x_push(nchars) + int nchars; { char *cp = str_nsave(xcp, nchars, AEDIT); if (killstack[killsp]) @@ -1204,7 +1252,8 @@ x_push(int nchars) } static int -x_yank(int c) +x_yank(c) + int c; { if (killsp == 0) killtp = KILLSIZE; @@ -1222,7 +1271,8 @@ x_yank(int c) } static int -x_meta_yank(int c) +x_meta_yank(c) + int c; { int len; if ((x_last_command != XFUNC_yank && x_last_command != XFUNC_meta_yank) @@ -1246,7 +1296,8 @@ x_meta_yank(int c) } static int -x_abort(int c) +x_abort(c) + int c; { /* x_zotc(c); */ xlp = xep = xcp = xbp = xbuf; @@ -1256,14 +1307,16 @@ x_abort(int c) } static int -x_error(int c) +x_error(c) + int c; { x_e_putc(BEL); return KSTD; } static int -x_stuffreset(int c) +x_stuffreset(c) + int c; { #ifdef TIOCSTI (void)x_stuff(c); @@ -1279,7 +1332,8 @@ x_stuffreset(int c) } static int -x_stuff(int c) +x_stuff(c) + int c; { #if 0 || defined TIOCSTI char ch = c; @@ -1293,7 +1347,9 @@ x_stuff(int c) } static char * -x_mapin(const char *cp, Area *area) +x_mapin(cp, area) + const char *cp; + Area *area; { char *new, *op; @@ -1323,7 +1379,8 @@ x_mapin(const char *cp, Area *area) } static char * -x_mapout(int c) +x_mapout(c) + int c; { static char buf[8]; register char *p = buf; @@ -1344,7 +1401,8 @@ x_mapout(int c) } static void -x_print(int prefix, int key) +x_print(prefix, key) + int prefix, key; { if (prefix == 1) shprintf("%s", x_mapout(x_prefix1)); @@ -1361,10 +1419,11 @@ x_print(int prefix, int key) shprintf("'%s'\n", x_atab[prefix][key]); } -/* macro for bind -m */ -/* list for bind -l */ int -x_bind(const char *a1, const char *a2, int macro, int list) +x_bind(a1, a2, macro, list) + const char *a1, *a2; + int macro; /* bind -m */ + int list; /* bind -l */ { Findex f; int prefix, key; @@ -1458,7 +1517,7 @@ x_bind(const char *a1, const char *a2, int macro, int list) } void -x_init_emacs(void) +x_init_emacs() { size_t i; register int j; @@ -1494,7 +1553,9 @@ x_init_emacs(void) static void bind_if_not_bound(int p, int k, int func); static void -bind_if_not_bound(int p, int k, int func) +bind_if_not_bound(p, k, func) + int p, k; + int func; { /* Has user already bound this key? If so, don't override it */ if (x_bound[((p) * X_TABSZ + (k)) / 8] @@ -1505,7 +1566,8 @@ bind_if_not_bound(int p, int k, int func) } void -x_emacs_keys(X_chars *ec) +x_emacs_keys(ec) + X_chars *ec; { if (ec->erase >= 0) { bind_if_not_bound(0, ec->erase, XFUNC_del_back); @@ -1522,14 +1584,16 @@ x_emacs_keys(X_chars *ec) } static int -x_set_mark(int c) +x_set_mark(c) + int c; { xmp = xcp; return KSTD; } static int -x_kill_region(int c) +x_kill_region(c) + int c; { int rsize; char *xr; @@ -1552,7 +1616,8 @@ x_kill_region(int c) } static int -x_xchg_point_mark(int c) +x_xchg_point_mark(c) + int c; { char *tmp; @@ -1567,7 +1632,8 @@ x_xchg_point_mark(int c) } static int -x_version(int c) +x_version(c) + int c; { char *o_xbuf = xbuf, *o_xend = xend; char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp; @@ -1596,14 +1662,16 @@ x_version(int c) } static int -x_noop(int c) +x_noop(c) + int c; { return KSTD; } #ifdef SILLY static int -x_game_of_life(int c) +x_game_of_life(c) + int c; { char newbuf [256+1]; register char *ip, *op; @@ -1659,49 +1727,57 @@ x_game_of_life(int c) static int -x_comp_comm(int c) +x_comp_comm(c) + int c; { do_complete(XCF_COMMAND, CT_COMPLETE); return KSTD; } static int -x_list_comm(int c) +x_list_comm(c) + int c; { do_complete(XCF_COMMAND, CT_LIST); return KSTD; } static int -x_complete(int c) +x_complete(c) + int c; { do_complete(XCF_COMMAND_FILE, CT_COMPLETE); return KSTD; } static int -x_enumerate(int c) +x_enumerate(c) + int c; { do_complete(XCF_COMMAND_FILE, CT_LIST); return KSTD; } static int -x_comp_file(int c) +x_comp_file(c) + int c; { do_complete(XCF_FILE, CT_COMPLETE); return KSTD; } static int -x_list_file(int c) +x_list_file(c) + int c; { do_complete(XCF_FILE, CT_LIST); return KSTD; } static int -x_comp_list(int c) +x_comp_list(c) + int c; { do_complete(XCF_COMMAND_FILE, CT_COMPLIST); return KSTD; } static int -x_expand(int c) +x_expand(c) + int c; { char **words; int nwords = 0; @@ -1734,9 +1810,10 @@ x_expand(int c) } /* type == 0 for list, 1 for complete and 2 for complete-list */ -/* flags == XCF_{COMMAND,FILE,COMMAND_FILE}*/ static void -do_complete(int flags, Comp_type type) +do_complete(flags, type) + int flags; /* XCF_{COMMAND,FILE,COMMAND_FILE} */ + Comp_type type; { char **words; int nwords; @@ -1801,7 +1878,7 @@ do_complete(int flags, Comp_type type) */ static void -x_adjust(void) +x_adjust() { x_adj_done++; /* flag the fact that we were called. */ /* @@ -1817,13 +1894,14 @@ x_adjust(void) static int unget_char = -1; static void -x_e_ungetc(int c) +x_e_ungetc(c) + int c; { unget_char = c; } static int -x_e_getc(void) +x_e_getc() { int c; @@ -1843,7 +1921,8 @@ x_e_getc(void) } static void -x_e_putc(int c) +x_e_putc(c) + int c; { if (c == '\r' || c == '\n') x_col = 0; @@ -1873,7 +1952,8 @@ x_e_putc(int c) #ifdef DEBUG static int -x_debug_info(int c) +x_debug_info(c) + int c; { x_flush(); shellf("\nksh debug:\n"); @@ -1890,7 +1970,8 @@ x_debug_info(int c) #endif static void -x_e_puts(const char *s) +x_e_puts(s) + const char *s; { register int adj = x_adj_done; @@ -1909,7 +1990,8 @@ x_e_puts(const char *s) */ static int -x_set_arg(int c) +x_set_arg(c) + int c; { int n = 0; int first = 1; @@ -1932,7 +2014,8 @@ x_set_arg(int c) /* Comment or uncomment the current line. */ static int -x_comment(int c) +x_comment(c) + int c; { int oldsize = x_size_str(xbuf); int len = xep - xbuf; @@ -1968,7 +2051,8 @@ x_comment(int c) */ static int -x_prev_histword(int c) +x_prev_histword(c) + int c; { register char *rcp; char *cp; @@ -2017,21 +2101,24 @@ x_prev_histword(int c) /* Uppercase N(1) words */ static int -x_fold_upper(int c) +x_fold_upper(c) + int c; { return x_fold_case('U'); } /* Lowercase N(1) words */ static int -x_fold_lower(int c) +x_fold_lower(c) + int c; { return x_fold_case('L'); } /* Lowercase N(1) words */ static int -x_fold_capitalize(int c) +x_fold_capitalize(c) + int c; { return x_fold_case('C'); } @@ -2048,7 +2135,8 @@ x_fold_capitalize(int c) */ static int -x_fold_case(int c) +x_fold_case(c) + int c; { char *cp = xcp; @@ -2115,7 +2203,7 @@ x_fold_case(int c) */ static char * -x_lastcp(void) +x_lastcp() { register char *rcp; register int i; @@ -2131,4 +2219,3 @@ x_lastcp(void) } #endif /* EDIT */ - diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c index 8b416cd18..4c016ecdf 100644 --- a/bin/ksh/eval.c +++ b/bin/ksh/eval.c @@ -64,7 +64,9 @@ static void alt_expand ARGS((XPtrV *wp, char *start, char *exp_start, /* compile and expand word */ char * -substitute(const char *cp, int f) +substitute(cp, f) + const char *cp; + int f; { struct source *s, *sold; @@ -83,7 +85,9 @@ substitute(const char *cp, int f) * expand arg-list */ char ** -eval(register char **ap, int f) +eval(ap, f) + register char **ap; + int f; { XPtrV w; @@ -108,7 +112,9 @@ eval(register char **ap, int f) * expand string */ char * -evalstr(char *cp, int f) +evalstr(cp, f) + char *cp; + int f; { XPtrV w; @@ -124,7 +130,9 @@ evalstr(char *cp, int f) * used from iosetup to expand redirection files */ char * -evalonestr(register char *cp, int f) +evalonestr(cp, f) + register char *cp; + int f; { XPtrV w; @@ -156,12 +164,11 @@ typedef struct SubType { struct SubType *next; /* poped type (to avoid re-allocating) */ } SubType; -/* cp - input word - * wp - output words - * f - DO* flags - */ void -expand(char *cp, register XPtrV *wp, int f) +expand(cp, wp, f) + char *cp; /* input word */ + register XPtrV *wp; /* output words */ + int f; /* DO* flags */ { register int UNINITIALIZED(c); register int type; /* expansion type */ @@ -675,7 +682,7 @@ expand(char *cp, register XPtrV *wp, int f) quote &= ~2; /* undo temporary */ if (make_magic) { - make_magic = 0; + make_magic = 0; fdo |= DOMAGIC_ | (f & DOGLOB); *dp++ = MAGIC; } else if (ISMAGIC(c)) { @@ -690,11 +697,14 @@ expand(char *cp, register XPtrV *wp, int f) /* * Prepare to generate the string returned by ${} substitution. - * stypep: becomes qualifier type - * slenp: " " len (=, :=, etc) valid iff *stypep != 0 */ static int -varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp) +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 */ { int c; int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */ @@ -840,7 +850,9 @@ varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp) * Run the command in $(...) and read its output. */ static int -comsub(register Expand *xp, char *cp) +comsub(xp, cp) + register Expand *xp; + char *cp; { Source *s, *sold; register struct op *t; @@ -893,7 +905,10 @@ comsub(register Expand *xp, char *cp) */ static char * -trimsub(register char *str, char *pat, int how) +trimsub(str, pat, how) + register char *str; + char *pat; + int how; { register char *end = strchr(str, 0); register char *p, c; @@ -943,7 +958,10 @@ trimsub(register char *str, char *pat, int how) /* XXX cp not const 'cause slashes are temporarily replaced with nulls... */ static void -glob(char *cp, register XPtrV *wp, int markdirs) +glob(cp, wp, markdirs) + char *cp; + register XPtrV *wp; + int markdirs; { int oldsize = XPsize(*wp); @@ -963,7 +981,10 @@ glob(char *cp, register XPtrV *wp, int markdirs) * the number of matches found. */ int -glob_str(char *cp, XPtrV *wp, int markdirs) +glob_str(cp, wp, markdirs) + char *cp; + XPtrV *wp; + int markdirs; { int oldsize = XPsize(*wp); XString xs; @@ -976,15 +997,13 @@ glob_str(char *cp, XPtrV *wp, int markdirs) return XPsize(*wp) - oldsize; } -/* - * xs - dest string - * xpp - prt to dest end - * sp - source path - * wp - output list - * check - GF_* paths - */ static void -globit(XString *xs, char **xpp, char *sp, register XPtrV *wp, int check) +globit(xs, xpp, sp, wp, check) + XString *xs; /* dest string */ + char **xpp; /* ptr to dest end */ + char *sp; /* source path */ + register XPtrV *wp; /* output list */ + int check; /* GF_* flags */ { register char *np; /* next source component */ char *xp = *xpp; @@ -1168,7 +1187,10 @@ copy_non_glob(xs, xpp, p) /* remove MAGIC from string */ char * -debunk(char *dp, const char *sp, size_t dlen) +debunk(dp, sp, dlen) + char *dp; + const char *sp; + size_t dlen; { char *d, *s; @@ -1198,7 +1220,11 @@ debunk(char *dp, const char *sp, size_t dlen) * past the name, otherwise returns 0. */ static char * -maybe_expand_tilde(char *p, XString *dsp, char **dpp, int isassign) +maybe_expand_tilde(p, dsp, dpp, isassign) + char *p; + XString *dsp; + char **dpp; + int isassign; { XString ts; char *dp = *dpp; @@ -1236,7 +1262,8 @@ maybe_expand_tilde(char *p, XString *dsp, char **dpp, int isassign) */ static char * -tilde(char *cp) +tilde(cp) + char *cp; { char *dp; @@ -1262,7 +1289,8 @@ tilde(char *cp) */ static char * -homedir(char *name) +homedir(name) + char *name; { register struct tbl *ap; @@ -1294,7 +1322,11 @@ homedir(char *name) #ifdef BRACE_EXPAND static void -alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo) +alt_expand(wp, start, exp_start, end, fdo) + XPtrV *wp; + char *start, *exp_start; + char *end; + int fdo; { int UNINITIALIZED(count); char *brace_start, *brace_end, *UNINITIALIZED(comma); @@ -1369,4 +1401,3 @@ alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo) return; } #endif /* BRACE_EXPAND */ - diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c index 13144bbf3..93c1aa257 100644 --- a/bin/ksh/exec.c +++ b/bin/ksh/exec.c @@ -58,7 +58,8 @@ static char clexec_tab[MAXFD+1]; * we now use this function always. */ int -fd_clexec(int fd) +fd_clexec(fd) + int fd; { #ifndef F_SETFD if (fd >= 0 && fd < sizeof(clexec_tab)) { @@ -76,7 +77,9 @@ fd_clexec(int fd) * execute command tree */ int -execute(struct op * volatile t, volatile int flags) +execute(t, flags) + struct op * volatile t; + volatile int flags; /* if XEXEC don't fork */ { int i; volatile int rv = 0; @@ -447,7 +450,11 @@ execute(struct op * volatile t, volatile int flags) */ static int -comexec(struct op *t, struct tbl *volatile tp, register char **ap, int volatile flags) +comexec(t, tp, ap, flags) + struct op *t; + struct tbl *volatile tp; + register char **ap; + int volatile flags; { int i; int leave = LLEAVE; @@ -749,7 +756,9 @@ comexec(struct op *t, struct tbl *volatile tp, register char **ap, int volatile } static void -scriptexec(register struct op *tp, register char **ap) +scriptexec(tp, ap) + register struct op *tp; + register char **ap; { char *shellv; @@ -861,7 +870,8 @@ scriptexec(register struct op *tp, register char **ap) } int -shcomexec(register char **wp) +shcomexec(wp) + register char **wp; { register struct tbl *tp; @@ -876,7 +886,10 @@ shcomexec(register char **wp) * is created if none is found. */ struct tbl * -findfunc(const char *name, unsigned int h, int create) +findfunc(name, h, create) + const char *name; + unsigned int h; + int create; { struct block *l; struct tbl *tp = (struct tbl *) 0; @@ -901,7 +914,9 @@ findfunc(const char *name, unsigned int h, int create) * function did not exist, returns 0 otherwise. */ int -define(const char *name, struct op *t) +define(name, t) + const char *name; + struct op *t; { struct tbl *tp; int was_set = 0; @@ -944,7 +959,9 @@ define(const char *name, struct op *t) * add builtin */ void -builtin(const char *name, int (*func) ARGS((char **))) +builtin(name, func) + const char *name; + int (*func) ARGS((char **)); { register struct tbl *tp; Tflag flag; @@ -970,10 +987,11 @@ builtin(const char *name, int (*func) ARGS((char **))) /* * find command * either function, hashed command, or built-in (in that order) - * flags is FC_* */ struct tbl * -findcom(const char *name, int flags) +findcom(name, flags) + const char *name; + int flags; /* FC_* */ { static struct tbl temp; unsigned int h = hash(name); @@ -1073,10 +1091,10 @@ findcom(const char *name, int flags) /* * flush executable commands with relative paths - * all - just relative or all */ void -flushcom(int all) +flushcom(all) + int all; /* just relative or all */ { struct tbl *tp; struct tstate ts; @@ -1091,11 +1109,12 @@ flushcom(int all) } } -/* Check if path is something we want to find. Returns -1 for failure. - * errnop is set if canidate found, but not suitable - */ +/* Check if path is something we want to find. Returns -1 for failure. */ int -search_access(const char *pathx, int mode, int *errnop) +search_access(pathx, mode, errnop) + const char *pathx; + int mode; + int *errnop; /* set if candidate found, but not suitable */ { #ifndef OS2 int ret, err = 0; @@ -1161,9 +1180,11 @@ search_access(const char *pathx, int mode, int *errnop) } #ifdef OS2 -/* errnop is set if candidate found, but not suitable */ static int -search_access1(const char *pathx, int mode, int *errnop) +search_access1(pathx, mode, errnop) + const char *pathx; + int mode; + int *errnop; /* set if candidate found, but not suitable */ { int ret, err = 0; struct stat statb; @@ -1185,11 +1206,13 @@ search_access1(const char *pathx, int mode, int *errnop) /* * search for command with PATH - * mode == R_OK or X_OK - * errnop is set if candidate found, but not suitable */ char * -search(const char *name, const char *pathx, int mode, int *errnop) +search(name, pathx, mode, errnop) + const char *name; + const char *pathx; + int mode; /* R_OK or X_OK */ + int *errnop; /* set if candidate found, but not suitable */ { const char *sp, *p; char *xp; @@ -1255,7 +1278,9 @@ search(const char *name, const char *pathx, int mode, int *errnop) } static int -call_builtin(struct tbl *tp, char **wp) +call_builtin(tp, wp) + struct tbl *tp; + char **wp; { int rv; @@ -1276,7 +1301,9 @@ call_builtin(struct tbl *tp, char **wp) * set up redirection, saving old fd's in e->savefd */ static int -iosetup(register struct ioword *iop, struct tbl *tp) +iosetup(iop, tp) + register struct ioword *iop; + struct tbl *tp; { register int u = -1; char *cp = iop->name; @@ -1420,7 +1447,9 @@ iosetup(register struct ioword *iop, struct tbl *tp) * if unquoted here, expand here temp file into second temp file. */ static int -herein(const char *content, int sub) +herein(content, sub) + const char *content; + int sub; { volatile int fd = -1; struct source *s, *volatile osource; @@ -1487,7 +1516,9 @@ herein(const char *content, int sub) * print the args in column form - assuming that we can */ static char * -do_selectargs(register char **ap, bool_t print_menu) +do_selectargs(ap, print_menu) + register char **ap; + bool_t print_menu; { static const char *const read_args[] = { "read", "-r", "REPLY", (char *) 0 @@ -1528,7 +1559,11 @@ static char *select_fmt_entry ARGS((void *arg, int i, char *buf, int buflen)); /* format a single select menu item */ static char * -select_fmt_entry(void *arg, int i, char *buf, int buflen) +select_fmt_entry(arg, i, buf, buflen) + void *arg; + int i; + char *buf; + int buflen; { struct select_menu_info *smi = (struct select_menu_info *) arg; @@ -1541,7 +1576,8 @@ select_fmt_entry(void *arg, int i, char *buf, int buflen) * print a select style menu */ int -pr_menu(char *const *ap) +pr_menu(ap) + char *const *ap; { struct select_menu_info smi; char *const *pp; @@ -1584,14 +1620,19 @@ pr_menu(char *const *ap) static char *plain_fmt_entry ARGS((void *arg, int i, char *buf, int buflen)); static char * -plain_fmt_entry(void *arg, int i, char *buf, int buflen) +plain_fmt_entry(arg, i, buf, buflen) + void *arg; + int i; + char *buf; + int buflen; { shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]); return buf; } int -pr_list(char *const *ap) +pr_list(ap) + char *const *ap; { char *const *pp; int nwidth; @@ -1621,7 +1662,9 @@ extern const char db_close[]; * TM_UNOP and TM_BINOP, the returned value is a Test_op). */ static int -dbteste_isa(Test_env *te, Test_meta meta) +dbteste_isa(te, meta) + Test_env *te; + Test_meta meta; { int ret = 0; int uqword; @@ -1660,7 +1703,10 @@ dbteste_isa(Test_env *te, Test_meta meta) } static const char * -dbteste_getopnd(Test_env *te, Test_op op, int do_eval) +dbteste_getopnd(te, op, do_eval) + Test_env *te; + Test_op op; + int do_eval; { char *s = *te->pos.wp; @@ -1681,17 +1727,23 @@ 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) +dbteste_eval(te, op, opnd1, opnd2, do_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(Test_env *te, int offset, const char *msg) +dbteste_error(te, offset, msg) + Test_env *te; + int offset; + const char *msg; { te->flags |= TEF_ERROR; internal_errorf(0, "dbteste_error: %s (offset %d)", msg, offset); } #endif /* KSH */ - diff --git a/bin/ksh/expand.h b/bin/ksh/expand.h index 198c1a056..5618af222 100644 --- a/bin/ksh/expand.h +++ b/bin/ksh/expand.h @@ -107,4 +107,3 @@ typedef struct XPtrV { sizeofN(void*, XPsize(x)), ATEMP) #define XPfree(x) afree((void*) (x).beg, ATEMP) - diff --git a/bin/ksh/expr.c b/bin/ksh/expr.c index 464689cba..6ba91dd3b 100644 --- a/bin/ksh/expr.c +++ b/bin/ksh/expr.c @@ -149,7 +149,10 @@ static struct tbl *intvar ARGS((Expr_state *es, struct tbl *vp)); * parse and evaluate expression */ int -evaluate(const char *expr, long *rval, int error_ok) +evaluate(expr, rval, error_ok) + const char *expr; + long *rval; + int error_ok; { struct tbl v; int ret; @@ -165,7 +168,10 @@ evaluate(const char *expr, long *rval, int error_ok) * parse and evaluate expression, storing result in vp. */ int -v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok) +v_evaluate(vp, expr, error_ok) + struct tbl *vp; + const char *expr; + volatile int error_ok; { struct tbl *v; Expr_state curstate; @@ -217,7 +223,10 @@ v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok) } static void -evalerr(Expr_state *es, enum error_type type, const char *str) +evalerr(es, type, str) + Expr_state *es; + enum error_type type; + const char *str; { char tbuf[2]; const char *s; @@ -273,7 +282,9 @@ evalerr(Expr_state *es, enum error_type type, const char *str) } static struct tbl * -evalexpr(Expr_state *es, enum prec prec) +evalexpr(es, prec) + Expr_state *es; + enum prec prec; { struct tbl *vl, UNINITIALIZED(*vr), *vasn; enum token op; @@ -452,7 +463,8 @@ evalexpr(Expr_state *es, enum prec prec) } static void -token(Expr_state *es) +token(es) + Expr_state *es; { const char *cp; int c; @@ -525,7 +537,11 @@ token(Expr_state *es) /* Do a ++ or -- operation */ static struct tbl * -do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool_t is_prefix) +do_ppmm(es, op, vasn, is_prefix) + Expr_state *es; + enum token op; + struct tbl *vasn; + bool_t is_prefix; { struct tbl *vl; int oval; @@ -545,7 +561,10 @@ 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) +assign_check(es, op, vasn) + 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); @@ -554,7 +573,7 @@ assign_check(Expr_state *es, enum token op, struct tbl *vasn) } static struct tbl * -tempvar(void) +tempvar() { register struct tbl *vp; @@ -569,7 +588,9 @@ tempvar(void) /* cast (string) variable to temporary integer variable */ static struct tbl * -intvar(Expr_state *es, struct tbl *vp) +intvar(es, vp) + Expr_state *es; + struct tbl *vp; { struct tbl *vq; @@ -590,4 +611,3 @@ intvar(Expr_state *es, struct tbl *vp) } return vq; } - diff --git a/bin/ksh/history.c b/bin/ksh/history.c index bda22e933..1758464c7 100644 --- a/bin/ksh/history.c +++ b/bin/ksh/history.c @@ -80,7 +80,8 @@ static Source *hist_source; int -c_fc(char **wp) +c_fc(wp) + char **wp; { struct shf *shf; struct temp UNINITIALIZED(*tf); @@ -297,7 +298,8 @@ c_fc(char **wp) /* Save cmd in history, execute cmd (cmd gets trashed) */ static int -hist_execute(char *cmd) +hist_execute(cmd) + char *cmd; { Source *sold; int ret; @@ -337,7 +339,11 @@ hist_execute(char *cmd) } static int -hist_replace(char **hp, const char *pat, const char *rep, int globalv) +hist_replace(hp, pat, rep, globalv) + char **hp; + const char *pat; + const char *rep; + int globalv; { char *line; @@ -382,7 +388,10 @@ hist_replace(char **hp, const char *pat, const char *rep, int globalv) * pattern is a number or string */ static char ** -hist_get(const char *str, int approx, int allow_cur) +hist_get(str, approx, allow_cur) + const char *str; + int approx; + int allow_cur; { char **hp = (char **) 0; int n; @@ -423,7 +432,8 @@ hist_get(const char *str, int approx, int allow_cur) /* Return a pointer to the newest command in the history */ static char ** -hist_get_newest(int allow_cur) +hist_get_newest(allow_cur) + int allow_cur; { if (histptr < histlist || (!allow_cur && histptr == histlist)) { bi_errorf("no history (yet)"); @@ -436,7 +446,7 @@ hist_get_newest(int allow_cur) /* Return a pointer to the newest command in the history */ static char ** -hist_get_oldest(void) +hist_get_oldest() { if (histptr <= histlist) { bi_errorf("no history (yet)"); @@ -449,7 +459,7 @@ hist_get_oldest(void) /* Back up over last histsave */ /******************************/ static void -histbackup(void) +histbackup() { static int last_line = -1; @@ -465,19 +475,20 @@ histbackup(void) * Return the current position. */ char ** -histpos(void) +histpos() { return current; } int -histN(void) +histN() { return curpos; } int -histnum(int n) +histnum(n) + int n; { int last = histptr - histlist; @@ -498,7 +509,11 @@ histnum(int n) * direction. */ int -findhist(int start, int fwd, const char *str, int anchored) +findhist(start, fwd, str, anchored) + int start; + int fwd; + const char *str; + int anchored; { char **hp; int maxhist = histptr - histlist; @@ -522,7 +537,8 @@ findhist(int start, int fwd, const char *str, int anchored) * this means reallocating the dataspace */ void -sethistsize(int n) +sethistsize(n) + int n; { if (n > 0 && n != histsize) { int cursize = histptr - histlist; @@ -546,7 +562,8 @@ sethistsize(int n) * maintenance */ void -sethistfile(const char *name) +sethistfile(name) + const char *name; { /* if not started then nothing to do */ if (hstarted == 0) @@ -585,7 +602,7 @@ sethistfile(const char *name) * initialise the history vector */ void -init_histvec(void) +init_histvec() { if (histlist == NULL) { histsize = HISTORYSIZE; @@ -597,10 +614,12 @@ init_histvec(void) # ifdef EASY_HISTORY /* * save command in history - * lno and dowrite are ignored for compability with COMPLEX_HISTORY */ void -histsave(int lno, const char *cmd, int dowrite) +histsave(lno, cmd, dowrite) + int lno; /* ignored (compatibility with COMPLEX_HISTORY) */ + const char *cmd; + int dowrite; /* ignored (compatibility with COMPLEX_HISTORY) */ { register char **hp = histptr; char *cp; @@ -624,7 +643,9 @@ histsave(int lno, const char *cmd, int dowrite) * commands */ void -histappend(const char *cmd, int nl_separate) +histappend(cmd, nl_separate) + const char *cmd; + int nl_separate; { int hlen, clen; char *p; @@ -650,7 +671,8 @@ histappend(const char *cmd, int nl_separate) * to save its history. */ void -hist_init(Source *s) +hist_init(s) + Source *s; { char *f; FILE *fh; @@ -715,7 +737,7 @@ hist_init(Source *s) */ void -hist_finish(void) +hist_finish() { static int once; int fd; @@ -775,7 +797,10 @@ hist_finish(void) * save command in history */ void -histsave(int lno, const char *cmd, int dowrite) +histsave(lno, cmd, dowrite) + int lno; + const char *cmd; + int dowrite; { register char **hp; char *c, *cp; @@ -823,7 +848,8 @@ histsave(int lno, const char *cmd, int dowrite) # define COMMAND 0xff void -hist_init(Source *s) +hist_init(s) + Source *s; { unsigned char *base; int lines; @@ -900,7 +926,9 @@ typedef enum state { } State; static int -hist_count_lines(register unsigned char *base, register int bytes) +hist_count_lines(base, bytes) + register unsigned char *base; + register int bytes; { State state = shdr; int lines = 0; @@ -933,7 +961,9 @@ hist_count_lines(register unsigned char *base, register int bytes) * Shrink the history file to histsize lines */ static int -hist_shrink(unsigned char *oldbase, int oldbytes) +hist_shrink(oldbase, oldbytes) + unsigned char *oldbase; + int oldbytes; { int fd; char nfile[1024]; @@ -985,7 +1015,10 @@ hist_shrink(unsigned char *oldbase, int oldbytes) * return the pointer and the number of bytes left */ static unsigned char * -hist_skip_back(unsigned char *base, int *bytes, int no) +hist_skip_back(base, bytes, no) + unsigned char *base; + int *bytes; + int no; { register int lines = 0; register unsigned char *ep; @@ -1011,7 +1044,10 @@ hist_skip_back(unsigned char *base, int *bytes, int no) * load the history structure from the stored data */ static void -histload(Source *s, register unsigned char *base, register int bytes) +histload(s, base, bytes) + Source *s; + register unsigned char *base; + register int bytes; { State state; int lno = 0; @@ -1061,7 +1097,10 @@ histload(Source *s, register unsigned char *base, register int bytes) * Insert a line into the history at a specified number */ static void -histinsert(Source *s, int lno, unsigned char *line) +histinsert(s, lno, line) + Source *s; + int lno; + unsigned char *line; { register char **hp; @@ -1081,7 +1120,9 @@ histinsert(Source *s, int lno, unsigned char *line) * and we should read those commands to update our history */ static void -writehistfile(int lno, char *cmd) +writehistfile(lno, cmd) + int lno; + char *cmd; { int sizenow; unsigned char *base; @@ -1137,7 +1178,7 @@ bad: } void -hist_finish(void) +hist_finish() { (void) flock(histfd, LOCK_UN); (void) close(histfd); @@ -1148,7 +1189,8 @@ hist_finish(void) * add magic to the history file */ static int -sprinkle(int fd) +sprinkle(fd) + int fd; { static unsigned char mag[] = { HMAGIC1, HMAGIC2 }; @@ -1160,21 +1202,24 @@ sprinkle(int fd) /* No history to be compiled in: dummy routines to avoid lots more ifdefs */ void -init_histvec(void) +init_histvec() { } void -hist_init(Source *s) +hist_init(s) + Source *s; { } void -hist_finish(void) +hist_finish() { } void -histsave(int lno, const char *cmd, int dowrite) +histsave(lno, cmd, dowrite) + int lno; + const char *cmd; + int dowrite; { errorf("history not enabled"); } #endif /* HISTORY */ - diff --git a/bin/ksh/io.c b/bin/ksh/io.c index 7f44938c2..b8b3c603b 100644 --- a/bin/ksh/io.c +++ b/bin/ksh/io.c @@ -23,7 +23,13 @@ static int initio_done; /* A shell error occurred (eg, syntax error, etc.) */ void +#ifdef HAVE_PROTOTYPES errorf(const char *fmt, ...) +#else +errorf(fmt, va_alist) + const char *fmt; + va_dcl +#endif { va_list va; @@ -42,7 +48,14 @@ errorf(const char *fmt, ...) /* like errorf(), but no unwind is done */ void +#ifdef HAVE_PROTOTYPES warningf(int fileline, const char *fmt, ...) +#else +warningf(fileline, fmt, va_alist) + int fileline; + const char *fmt; + va_dcl +#endif { va_list va; @@ -58,7 +71,13 @@ warningf(int fileline, const char *fmt, ...) * (also unwinds environments for special builtins). */ void +#ifdef HAVE_PROTOTYPES bi_errorf(const char *fmt, ...) +#else +bi_errorf(fmt, va_alist) + const char *fmt; + va_dcl +#endif { va_list va; @@ -89,7 +108,14 @@ bi_errorf(const char *fmt, ...) /* Called when something that shouldn't happen does */ void +#ifdef HAVE_PROTOTYPES internal_errorf(int jump, const char *fmt, ...) +#else +internal_errorf(jump, fmt, va_alist) + int jump; + const char *fmt; + va_dcl +#endif { va_list va; @@ -106,7 +132,8 @@ internal_errorf(int jump, const char *fmt, ...) /* used by error reporting functions to print "ksh: .kshrc[25]: " */ void -error_prefix(int fileline) +error_prefix(fileline) + int fileline; { /* Avoid foo: foo[2]: ... */ if (!fileline || !source || !source->file @@ -121,7 +148,13 @@ error_prefix(int fileline) /* printf to shl_out (stderr) with flush */ void +#ifdef HAVE_PROTOTYPES shellf(const char *fmt, ...) +#else +shellf(fmt, va_alist) + const char *fmt; + va_dcl +#endif { va_list va; @@ -135,7 +168,13 @@ shellf(const char *fmt, ...) /* printf to shl_stdout (stdout) */ void +#ifdef HAVE_PROTOTYPES shprintf(const char *fmt, ...) +#else +shprintf(fmt, va_alist) + const char *fmt; + va_dcl +#endif { va_list va; @@ -150,7 +189,7 @@ shprintf(const char *fmt, ...) static struct shf *kshdebug_shf; void -kshdebug_init_(void) +kshdebug_init_() { if (kshdebug_shf) shf_close(kshdebug_shf); @@ -165,7 +204,13 @@ kshdebug_init_(void) /* print to debugging log */ void +# ifdef HAVE_PROTOTYPES kshdebug_printf_(const char *fmt, ...) +# else +kshdebug_printf_(fmt, va_alist) + const char *fmt; + va_dcl +# endif { va_list va; @@ -179,7 +224,10 @@ kshdebug_printf_(const char *fmt, ...) } void -kshdebug_dump_(const char *str, const void *mem, int nbytes) +kshdebug_dump_(str, mem, nbytes) + const char *str; + const void *mem; + int nbytes; { int i, j; int nprow = 16; @@ -202,7 +250,8 @@ kshdebug_dump_(const char *str, const void *mem, int nbytes) /* test if we can seek backwards fd (returns 0 or SHF_UNBUF) */ int -can_seek(int fd) +can_seek(fd) + int fd; { struct stat statb; @@ -213,7 +262,7 @@ can_seek(int fd) struct shf shf_iob[3]; void -initio(void) +initio() { shf_fdopen(1, SHF_WR, shl_stdout); /* force buffer allocation */ shf_fdopen(2, SHF_WR, shl_out); @@ -224,7 +273,10 @@ initio(void) /* A dup2() with error checking */ int -ksh_dup2(int ofd, int nfd, int errok) +ksh_dup2(ofd, nfd, errok) + int ofd; + int nfd; + int errok; { int ret = dup2(ofd, nfd); @@ -245,7 +297,9 @@ ksh_dup2(int ofd, int nfd, int errok) * set close-on-exec flag. */ int -savefd(int fd, int noclose) +savefd(fd, noclose) + int fd; + int noclose; { int nfd; @@ -266,7 +320,8 @@ savefd(int fd, int noclose) } void -restfd(int fd, int ofd) +restfd(fd, ofd) + int fd, ofd; { if (fd == 2) shf_flush(&shf_iob[fd]); @@ -279,7 +334,8 @@ restfd(int fd, int ofd) } void -openpipe(register int *pv) +openpipe(pv) + register int *pv; { if (pipe(pv) < 0) errorf("can't create pipe - try again"); @@ -288,7 +344,8 @@ openpipe(register int *pv) } void -closepipe(register int *pv) +closepipe(pv) + register int *pv; { close(pv[0]); close(pv[1]); @@ -298,7 +355,10 @@ closepipe(register int *pv) * a string (the X in 2>&X, read -uX, print -uX) into a file descriptor. */ int -check_fd(char *name, int mode, const char **emsgp) +check_fd(name, mode, emsgp) + char *name; + int mode; + const char **emsgp; { int fd, fl; @@ -353,7 +413,7 @@ check_fd(char *name, int mode, const char **emsgp) #ifdef KSH /* Called once from main */ void -coproc_init(void) +coproc_init() { coproc.read = coproc.readw = coproc.write = -1; coproc.njobs = 0; @@ -362,7 +422,8 @@ coproc_init(void) /* Called by c_read() when eof is read - close fd if it is the co-process fd */ void -coproc_read_close(int fd) +coproc_read_close(fd) + int fd; { if (coproc.read >= 0 && fd == coproc.read) { coproc_readw_close(fd); @@ -375,7 +436,8 @@ coproc_read_close(int fd) * read pipe, so reads will actually terminate. */ void -coproc_readw_close(int fd) +coproc_readw_close(fd) + int fd; { if (coproc.readw >= 0 && coproc.read >= 0 && fd == coproc.read) { close(coproc.readw); @@ -387,7 +449,8 @@ coproc_readw_close(int fd) * when co-process input is dup'd */ void -coproc_write_close(int fd) +coproc_write_close(fd) + int fd; { if (coproc.write >= 0 && fd == coproc.write) { close(coproc.write); @@ -399,7 +462,9 @@ coproc_write_close(int fd) * (Used by check_fd() and by c_read/c_print to deal with -p option). */ int -coproc_getfd(int mode, const char **emsgp) +coproc_getfd(mode, emsgp) + int mode; + const char **emsgp; { int fd = (mode & R_OK) ? coproc.read : coproc.write; @@ -414,7 +479,8 @@ coproc_getfd(int mode, const char **emsgp) * Should be called with SIGCHLD blocked. */ void -coproc_cleanup(int reuse) +coproc_cleanup(reuse) + int reuse; { /* This to allow co-processes to share output pipe */ if (!reuse || coproc.readw < 0 || coproc.read < 0) { @@ -440,7 +506,10 @@ coproc_cleanup(int reuse) */ struct temp * -maketemp(Area *ap, Temp_type type, struct temp **tlist) +maketemp(ap, type, tlist) + Area *ap; + Temp_type type; + struct temp **tlist; { #ifndef __NetBSD__ static unsigned int inc; @@ -497,4 +566,3 @@ maketemp(Area *ap, Temp_type type, struct temp **tlist) return tp; } - diff --git a/bin/ksh/jobs.c b/bin/ksh/jobs.c index 2face6d17..1ef0e8dd7 100644 --- a/bin/ksh/jobs.c +++ b/bin/ksh/jobs.c @@ -66,13 +66,16 @@ int tcsetpgrp ARGS((int fd, pid_t grp)); int tcgetpgrp ARGS((int fd)); int -tcsetpgrp(int fd, pid_t grp) +tcsetpgrp(fd, grp) + int fd; + pid_t grp; { return ioctl(fd, TIOCSPGRP, &grp); } int -tcgetpgrp(int fd) +tcgetpgrp(fd) + int fd; { int r, grp; @@ -228,7 +231,8 @@ static int kill_job ARGS((Job *j, int sig)); /* initialize job control */ void -j_init(int mflagset) +j_init(mflagset) + int mflagset; { child_max = CHILD_MAX; /* so syscon() isn't always being called */ @@ -282,7 +286,7 @@ j_init(int mflagset) /* job cleanup before shell exit */ void -j_exit(void) +j_exit() { /* kill stopped, and possibly running, jobs */ Job *j; @@ -339,7 +343,7 @@ j_exit(void) #ifdef JOBS /* turn job control on or off according to Flag(FMONITOR) */ void -j_change(void) +j_change() { int i; @@ -432,11 +436,12 @@ j_change(void) } #endif /* JOBS */ -/* execute tree in child subprocess - * close_fd used if XPCLOSE or XCCLOSE -*/ +/* execute tree in child subprocess */ int -exchild(struct op *t, int flags, int close_fd) +exchild(t, flags, close_fd) + struct op *t; + int flags; + int close_fd; /* used if XPCLOSE or XCCLOSE */ { static Proc *last_proc; /* for pipelines */ @@ -695,7 +700,7 @@ exchild(struct op *t, int flags, int close_fd) /* start the last job: only used for `command` jobs */ void -startlast(void) +startlast() { #ifdef JOB_SIGS sigset_t omask; @@ -715,7 +720,7 @@ startlast(void) /* wait for last job: only used for `command` jobs */ int -waitlast(void) +waitlast() { int rv; Job *j; @@ -748,7 +753,9 @@ waitlast(void) /* wait for child, interruptable. */ int -waitfor(const char *cp, int *sigp) +waitfor(cp, sigp) + const char *cp; + int *sigp; { int rv; Job *j; @@ -809,7 +816,9 @@ waitfor(const char *cp, int *sigp) /* kill (built-in) a job */ int -j_kill(const char *cp, int sig) +j_kill(cp, sig) + const char *cp; + int sig; { Job *j; int rv = 0; @@ -854,7 +863,9 @@ j_kill(const char *cp, int sig) #ifdef JOBS /* fg and bg built-ins: called only if Flag(FMONITOR) set */ int -j_resume(const char *cp, int bg) +j_resume(cp, bg) + const char *cp; + int bg; { Job *j; Proc *p; @@ -960,7 +971,7 @@ j_resume(const char *cp, int bg) /* are there any running or stopped jobs ? */ int -j_stopped_running(void) +j_stopped_running() { Job *j; int which = 0; @@ -985,11 +996,12 @@ j_stopped_running(void) return 0; } -/* list jobs for jobs built-in - * slp: 0 for short, 1 for long, 3 for pgrp - */ +/* list jobs for jobs built-in */ int -j_jobs(const char *cp, int slp, int nflag) +j_jobs(cp, slp, nflag) + const char *cp; + int slp; /* 0: short, 1: long, 2: pgrp */ + int nflag; { Job *j, *tmp; int how; @@ -1042,7 +1054,7 @@ j_jobs(const char *cp, int slp, int nflag) /* list jobs for top-level notification */ void -j_notify(void) +j_notify() { Job *j, *tmp; #ifdef JOB_SIGS @@ -1074,7 +1086,7 @@ j_notify(void) /* Return pid of last process in last asynchronous job */ pid_t -j_async(void) +j_async() { #ifdef JOB_SIGS sigset_t omask; @@ -1097,7 +1109,8 @@ j_async(void) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static void -j_set_async(Job *j) +j_set_async(j) + Job *j; { Job *jl, *oldest; @@ -1132,7 +1145,8 @@ j_set_async(Job *j) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static void -j_startjob(Job *j) +j_startjob(j) + Job *j; { Proc *p; @@ -1160,11 +1174,12 @@ j_startjob(Job *j) * wait for job to complete or change state * * If jobs are compiled in then this routine expects sigchld to be blocked. - * - * see JW_* for flags parameter */ static int -j_waitj(Job *j, int flags, const char *where) +j_waitj(j, flags, where) + Job *j; + int flags; /* see JW_* */ + const char *where; { int rv; @@ -1299,7 +1314,8 @@ j_waitj(Job *j, int flags, const char *where) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static RETSIGTYPE -j_sigchld(int sig) +j_sigchld(sig) + int sig; { int errno_ = errno; Job *j; @@ -1385,7 +1401,8 @@ found: * If jobs are compiled in then this routine expects sigchld to be blocked. */ static void -check_job(Job *j) +check_job(j) + Job *j; { int jstate; Proc *p; @@ -1493,7 +1510,10 @@ check_job(Job *j) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static void -j_print(Job *j, int how, struct shf *shf) +j_print(j, how, shf) + Job *j; + int how; + struct shf *shf; { Proc *p; int state; @@ -1602,7 +1622,9 @@ j_print(Job *j, int how, struct shf *shf) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static Job * -j_lookup(const char *cp, int *ecodep) +j_lookup(cp, ecodep) + const char *cp; + int *ecodep; { Job *j, *last_match; Proc *p; @@ -1695,7 +1717,7 @@ static Proc *free_procs; * If jobs are compiled in then this routine expects sigchld to be blocked. */ static Job * -new_job(void) +new_job() { int i; Job *newj, *j; @@ -1723,7 +1745,7 @@ new_job(void) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static Proc * -new_proc(void) +new_proc() { Proc *p; @@ -1742,7 +1764,9 @@ new_proc(void) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static void -remove_job(Job *j, const char *where) +remove_job(j, where) + Job *j; + const char *where; { Proc *p, *tmp; Job **prev, *curr; @@ -1782,7 +1806,9 @@ remove_job(Job *j, const char *where) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static void -put_job(Job *j, int where) +put_job(j, where) + Job *j; + int where; { Job **prev, *curr; @@ -1817,7 +1843,9 @@ put_job(Job *j, int where) * If jobs are compiled in then this routine expects sigchld to be blocked. */ static int -kill_job(Job *j, int sig) +kill_job(j, sig) + Job *j; + int sig; { Proc *p; int rval = 0; @@ -1828,4 +1856,3 @@ kill_job(Job *j, int sig) rval = -1; return rval; } - diff --git a/bin/ksh/ksh_dir.h b/bin/ksh/ksh_dir.h index ca51b957d..b0b3db6ed 100644 --- a/bin/ksh/ksh_dir.h +++ b/bin/ksh/ksh_dir.h @@ -25,4 +25,3 @@ extern DIR *ksh_opendir ARGS((const char *d)); #else /* OPENDIR_DOES_NONDIR */ # define ksh_opendir(d) opendir(d) #endif /* OPENDIR_DOES_NONDIR */ - diff --git a/bin/ksh/ksh_limval.h b/bin/ksh/ksh_limval.h index 052fb0c81..42e38bbf5 100644 --- a/bin/ksh/ksh_limval.h +++ b/bin/ksh/ksh_limval.h @@ -23,4 +23,3 @@ #ifndef BITS # define BITS(t) (BITSPERBYTE * sizeof(t)) #endif - diff --git a/bin/ksh/ksh_stat.h b/bin/ksh/ksh_stat.h index 23d4f280a..5f78406f1 100644 --- a/bin/ksh/ksh_stat.h +++ b/bin/ksh/ksh_stat.h @@ -58,4 +58,3 @@ #ifndef S_IXOTH # define S_IXOTH 00001 /* user execute bit */ #endif /* S_IXOTH */ - diff --git a/bin/ksh/ksh_time.h b/bin/ksh/ksh_time.h index e5a84fbe2..79a7b1585 100644 --- a/bin/ksh/ksh_time.h +++ b/bin/ksh/ksh_time.h @@ -25,4 +25,3 @@ extern time_t time ARGS((time_t *)); # define CLK_TCK 60 /* 60HZ */ #endif #endif /* KSH_TIME_H */ - diff --git a/bin/ksh/ksh_times.h b/bin/ksh/ksh_times.h index 009609756..e01215a99 100644 --- a/bin/ksh/ksh_times.h +++ b/bin/ksh/ksh_times.h @@ -18,4 +18,3 @@ extern clock_t ksh_times ARGS((struct tms *)); extern clock_t times ARGS((struct tms *)); #endif /* HAVE_TIMES */ #endif /* KSH_TIMES_H */ - diff --git a/bin/ksh/ksh_wait.h b/bin/ksh/ksh_wait.h index 3ac490035..dba7a27b0 100644 --- a/bin/ksh/ksh_wait.h +++ b/bin/ksh/ksh_wait.h @@ -50,4 +50,3 @@ typedef int WAIT_T; #else /* !HAVE_WAITPID && HAVE_WAIT3 */ # define ksh_waitpid(p, s, o) waitpid((p), (s), (o)) #endif /* !HAVE_WAITPID && HAVE_WAIT3 */ - diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c index dbeeef83b..80ded4ad7 100644 --- a/bin/ksh/lex.c +++ b/bin/ksh/lex.c @@ -103,7 +103,8 @@ static int ignore_backslash_newline; */ int -yylex(int cf) +yylex(cf) + int cf; { Lex_state states[STATE_BSIZE], *statep; State_info state_info; @@ -768,7 +769,7 @@ Done: } static void -gethere(void) +gethere() { register struct ioword **p; @@ -782,7 +783,8 @@ gethere(void) */ static void -readhere(struct ioword *iop) +readhere(iop) + struct ioword *iop; { register int c; char *volatile eof; @@ -840,7 +842,13 @@ readhere(struct ioword *iop) } void +#ifdef HAVE_PROTOTYPES yyerror(const char *fmt, ...) +#else +yyerror(fmt, va_alist) + const char *fmt; + va_dcl +#endif { va_list va; @@ -861,7 +869,9 @@ yyerror(const char *fmt, ...) */ Source * -pushs(int type, Area *areap) +pushs(type, areap) + int type; + Area *areap; { register Source *s; @@ -884,7 +894,7 @@ pushs(int type, Area *areap) } static int -getsc__(void) +getsc__() { register Source *s = source; register int c; @@ -985,7 +995,8 @@ getsc__(void) } static void -getsc_line(Source *s) +getsc_line(s) + Source *s; { char *xp = Xstring(s->xs, xp); int interactive = Flag(FTALKING) && s->type == SSTDIN; @@ -1097,7 +1108,9 @@ getsc_line(Source *s) } void -set_prompt(int to, Source *s) +set_prompt(to, s) + int to; + Source *s; { cur_prompt = to; @@ -1153,7 +1166,9 @@ set_prompt(int to, Source *s) /* See also related routine, promptlen() in edit.c */ void -pprompt(const char *cp, int ntruncate) +pprompt(cp, ntruncate) + const char *cp; + int ntruncate; { #if 0 char nbuf[32]; @@ -1197,7 +1212,9 @@ pprompt(const char *cp, int ntruncate) * the :[-+?=#%] or close-brace. */ static char * -get_brace_var(XString *wsp, char *wp) +get_brace_var(wsp, wp) + XString *wsp; + char *wp; { enum parse_state { PS_INITIAL, PS_SAW_HASH, PS_IDENT, @@ -1272,7 +1289,8 @@ get_brace_var(XString *wsp, char *wp) * (Returned string double null terminated) */ static int -arraysub(char **strp) +arraysub(strp) + char **strp; { XString ws; char *wp; @@ -1299,7 +1317,8 @@ arraysub(char **strp) /* Unget a char: handles case when we are already at the start of the buffer */ static const char * -ungetsc(int c) +ungetsc(c) + int c; { if (backslash_skip) backslash_skip--; @@ -1351,7 +1370,9 @@ getsc_bn ARGS((void)) } static Lex_state * -push_state_(State_info *si, Lex_state *old_end) +push_state_(si, old_end) + State_info *si; + Lex_state *old_end; { Lex_state *new = alloc(sizeof(Lex_state) * STATE_BSIZE, ATEMP); @@ -1362,7 +1383,9 @@ push_state_(State_info *si, Lex_state *old_end) } static Lex_state * -pop_state_(State_info *si, Lex_state *old_end) +pop_state_(si, old_end) + State_info *si; + Lex_state *old_end; { Lex_state *old_base = si->base; @@ -1373,4 +1396,3 @@ pop_state_(State_info *si, Lex_state *old_end) return si->base + STATE_BSIZE - 1; } - diff --git a/bin/ksh/lex.h b/bin/ksh/lex.h index 864c75418..99c06dae1 100644 --- a/bin/ksh/lex.h +++ b/bin/ksh/lex.h @@ -131,4 +131,3 @@ EXTERN char **histlist; /* saved commands */ EXTERN char **histptr; /* last history item */ EXTERN int histsize; /* history size */ #endif /* HISTORY */ - diff --git a/bin/ksh/mail.c b/bin/ksh/mail.c index e7fa636e2..e6a51f960 100644 --- a/bin/ksh/mail.c +++ b/bin/ksh/mail.c @@ -43,7 +43,7 @@ static mbox_t * mballoc ARGS((char *p, char *m)); /* allocate a new mbox */ static void mprintit ARGS((mbox_t *mbp)); void -mcheck(void) +mcheck() { register mbox_t *mbp; time_t now; @@ -87,13 +87,15 @@ mcheck(void) } void -mcset(long interval) +mcset(interval) + long interval; { mailcheck_interval = interval; } void -mbset(register char *p) +mbset(p) + register char *p; { struct stat stbuf; @@ -111,7 +113,8 @@ mbset(register char *p) } void -mpset(register char *mptoparse) +mpset(mptoparse) + register char *mptoparse; { register mbox_t *mbp; register char *mpath, *mmsg, *mval; @@ -150,7 +153,8 @@ mpset(register char *mptoparse) } static void -munset(register mbox_t *mlist) +munset(mlist) +register mbox_t *mlist; { register mbox_t *mbp; @@ -164,7 +168,9 @@ munset(register mbox_t *mlist) } static mbox_t * -mballoc(char *p, char *m) +mballoc(p, m) + char *p; + char *m; { struct stat stbuf; register mbox_t *mbp; @@ -181,7 +187,8 @@ mballoc(char *p, char *m) } static void -mprintit(mbox_t *mbp) +mprintit( mbp ) +mbox_t *mbp; { struct tbl *vp; @@ -193,4 +200,3 @@ mprintit(mbox_t *mbp) unset(vp, 0); } #endif /* KSH */ - diff --git a/bin/ksh/main.c b/bin/ksh/main.c index 3e2ea02e9..1dca7e1f3 100644 --- a/bin/ksh/main.c +++ b/bin/ksh/main.c @@ -454,7 +454,11 @@ main(int argc, char *argv[]) } int -include(const char *name, int argc, char **argv, int intr_ok) +include(name, argc, argv, intr_ok) + const char *name; + int argc; + char **argv; + int intr_ok; { register Source *volatile s = NULL; struct shf *shf; @@ -522,7 +526,8 @@ include(const char *name, int argc, char **argv, int intr_ok) } int -command(const char *comm) +command(comm) + const char *comm; { register Source *s; int r; @@ -536,10 +541,11 @@ command(const char *comm) /* * run the commands from the input source, returning status. - * s - input source */ int -shell(Source *volatile s, int volatile toplevel) +shell(s, toplevel) + Source *volatile s; /* input source */ + int volatile toplevel; { struct op *t; volatile int wastty = s->flags & SF_TTY; @@ -648,7 +654,8 @@ shell(Source *volatile s, int volatile toplevel) /* return to closest error handler or shell(), exit if none found */ void -unwind(int i) +unwind(i) + 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) @@ -682,7 +689,8 @@ unwind(int i) } void -newenv(int type) +newenv(type) + int type; { register struct env *ep; @@ -698,7 +706,7 @@ newenv(int type) } void -quitenv(void) +quitenv() { register struct env *ep = e; register int fd; @@ -750,7 +758,7 @@ quitenv(void) /* Called after a fork to cleanup stuff left over from parents environment */ void -cleanup_parents_env(void) +cleanup_parents_env() { struct env *ep; int fd; @@ -775,7 +783,7 @@ cleanup_parents_env(void) /* Called just before an execve cleanup stuff temporary files */ void -cleanup_proc_env(void) +cleanup_proc_env() { struct env *ep; @@ -785,7 +793,7 @@ cleanup_proc_env(void) /* remove temp files and free ATEMP Area */ static void -reclaim(void) +reclaim() { remove_temps(e->temps); e->temps = NULL; @@ -793,7 +801,8 @@ reclaim(void) } static void -remove_temps(struct temp *tp) +remove_temps(tp) + struct temp *tp; { #ifdef OS2 static struct temp *delayed_remove; @@ -838,7 +847,8 @@ remove_temps(struct temp *tp) /* Returns true if name refers to a restricted shell */ static int -is_restricted(char *name) +is_restricted(name) + char *name; { char *p; @@ -849,10 +859,11 @@ is_restricted(char *name) } void -aerror(Area *ap, const char *msg) +aerror(ap, msg) + Area *ap; + const char *msg; { internal_errorf(1, "alloc: %s", msg); errorf("%s", null); /* this is never executed - keeps gcc quiet */ /*NOTREACHED*/ } - diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c index e6e668ac0..94ae44b2c 100644 --- a/bin/ksh/misc.c +++ b/bin/ksh/misc.c @@ -31,7 +31,9 @@ static const unsigned char *cclass ARGS((const unsigned char *p, int sub)); * Fast character classes */ void -setctypes(register const char *s, register int t) +setctypes(s, t) + register const char *s; + register int t; { register int i; @@ -45,7 +47,7 @@ setctypes(register const char *s, register int t) } void -initctypes(void) +initctypes() { register int c; @@ -66,7 +68,9 @@ initctypes(void) /* convert unsigned long to base N string */ char * -ulton(register unsigned long n, int base) +ulton(n, base) + register unsigned long n; + int base; { register char *p; static char buf [20]; @@ -81,7 +85,9 @@ ulton(register unsigned long n, int base) } char * -str_save(register const char *s, Area *ap) +str_save(s, ap) + register const char *s; + Area *ap; { size_t len; char *p; @@ -99,7 +105,10 @@ str_save(register const char *s, Area *ap) * (unless n < 0). */ char * -str_nsave(register const char *s, int n, Area *ap) +str_nsave(s, n, ap) + register const char *s; + int n; + Area *ap; { char *ns; @@ -112,7 +121,10 @@ str_nsave(register const char *s, int n, Area *ap) /* called from expand.h:XcheckN() to grow buffer */ char * -Xcheck_grow_(XString *xsp, char *xp, int more) +Xcheck_grow_(xsp, xp, more) + XString *xsp; + char *xp; + int more; { char *old_beg = xsp->beg; @@ -185,7 +197,8 @@ const struct option goptions[] = { * translate -o option into F* constant (also used for test -o option) */ int -option(const char *n) +option(n) + const char *n; { int i; @@ -209,7 +222,11 @@ static void printoptions ARGS((int verbose)); /* format a single select menu item */ static char * -options_fmt_entry(void *arg, int i, char *buf, int buflen) +options_fmt_entry(arg, i, buf, buflen) + void *arg; + int i; + char *buf; + int buflen; { struct options_info *oi = (struct options_info *) arg; @@ -220,7 +237,8 @@ options_fmt_entry(void *arg, int i, char *buf, int buflen) } static void -printoptions(int verbose) +printoptions(verbose) + int verbose; { int i; @@ -252,7 +270,7 @@ printoptions(int verbose) } char * -getoptions(void) +getoptions() { size_t i; char m[(int) FNFLAGS + 1]; @@ -265,14 +283,12 @@ getoptions(void) return str_save(m, ATEMP); } -/* change a Flag(*) value; takes care of special actions - * - * f - flag to change - * what - what is changing the flag (command line vs set) - * - */ +/* change a Flag(*) value; takes care of special actions */ void -change_flag(enum sh_flag f, int what, int newval) +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; { int oldval; @@ -330,11 +346,12 @@ change_flag(enum sh_flag f, int what, int newval) /* parse command line & set command arguments. returns the index of * non-option arguments, -1 if there is an error. - * - * what - OF_CMDLINE or OF_SET */ int -parse_args(char **argv, int what, int *setargsp) +parse_args(argv, what, setargsp) + char **argv; + int what; /* OF_CMDLINE or OF_SET */ + int *setargsp; { static char cmd_opts[NELEM(goptions) + 3]; /* o:\0 */ static char set_opts[NELEM(goptions) + 5]; /* Ao;s\0 */ @@ -471,7 +488,9 @@ parse_args(char **argv, int what, int *setargsp) /* parse a decimal number: returns 0 if string isn't a number, 1 otherwise */ int -getn(const char *as, int *ai) +getn(as, ai) + const char *as; + int *ai; { char *p; long n; @@ -487,7 +506,9 @@ getn(const char *as, int *ai) /* getn() that prints error */ int -bi_getn(const char *as, int *ai) +bi_getn(as, ai) + const char *as; + int *ai; { int rv = getn(as, ai); @@ -507,7 +528,9 @@ bi_getn(const char *as, int *ai) */ int -gmatch(const char *s, const char *p, int isfile) +gmatch(s, p, isfile) + const char *s, *p; + int isfile; { const char *se, *pe; @@ -548,7 +571,8 @@ gmatch(const char *s, const char *p, int isfile) - return ? */ int -has_globbing(const char *xp, const char *xpe) +has_globbing(xp, xpe) + const char *xp, *xpe; { const unsigned char *p = (const unsigned char *) xp; const unsigned char *pe = (const unsigned char *) xpe; @@ -602,9 +626,10 @@ has_globbing(const char *xp, const char *xpe) /* Function must return either 0 or 1 (assumed by code for 0x80|'!') */ static int -do_gmatch(const unsigned char *s, const unsigned char *se, - const unsigned char *p, const unsigned char *pe, - int isfile) +do_gmatch(s, se, p, pe, isfile) + const unsigned char *s, *p; + const unsigned char *se, *pe; + int isfile; { register int sc, pc; const unsigned char *prest, *psub, *pnext; @@ -736,7 +761,9 @@ do_gmatch(const unsigned char *s, const unsigned char *se, } static const unsigned char * -cclass(const unsigned char *p, register int sub) +cclass(p, sub) + const unsigned char *p; + register int sub; { register int c, d, not, found = 0; const unsigned char *orig_p = p; @@ -781,7 +808,10 @@ cclass(const unsigned char *p, register int sub) /* Look for next ) or | (if match_sep) in *(foo|bar) pattern */ const unsigned char * -pat_scan(const unsigned char *p, const unsigned char *pe, int match_sep) +pat_scan(p, pe, match_sep) + const unsigned char *p; + const unsigned char *pe; + int match_sep; { int nest = 0; @@ -805,13 +835,11 @@ pat_scan(const unsigned char *p, const unsigned char *pe, int match_sep) */ static void qsort1 ARGS((void **base, void **lim, int (*f)(void *, void *))); -/* - * base - base address - * n - elements - * f - compare function - */ void -qsortp(void **base, size_t n, int (*f)(void*, void*)) +qsortp(base, n, f) + void **base; /* base address */ + size_t n; /* elements */ + int (*f) ARGS((void *, void *)); /* compare function */ { qsort1(base, base + n, f); } @@ -824,7 +852,9 @@ qsortp(void **base, size_t n, int (*f)(void*, void*)) } static void -qsort1(void **base, void **lim, int (*f)(void *, void *)) +qsort1(base, lim, f) + void **base, **lim; + int (*f) ARGS((void *, void *)); { register void **i, **j; register void **lptr, **hptr; @@ -893,14 +923,17 @@ qsort1(void **base, void **lim, int (*f)(void *, void *)) } int -xstrcmp(void *p1, void *p2) +xstrcmp(p1, p2) + void *p1, *p2; { return (strcmp((char *)p1, (char *)p2)); } /* Initialize a Getopt structure */ void -ksh_getopt_reset(Getopt *go, int flags) +ksh_getopt_reset(go, flags) + Getopt *go; + int flags; { go->optind = 1; go->optarg = (char *) 0; @@ -936,7 +969,10 @@ ksh_getopt_reset(Getopt *go, int flags) * in go->info. */ int -ksh_getopt(char **argv, Getopt *go, const char *options) +ksh_getopt(argv, go, options) + char **argv; + Getopt *go; + const char *options; { char c; char *o; @@ -1036,7 +1072,8 @@ ksh_getopt(char **argv, Getopt *go, const char *options) * No trailing newline is printed. */ void -print_value_quoted(const char *s) +print_value_quoted(s) + const char *s; { const char *p; int inquote = 0; @@ -1069,8 +1106,13 @@ print_value_quoted(const char *s) * element */ void -print_columns(struct shf *shf, int n, char *(*func)(void *, int, char *, int), - void *arg, int max_width, int prefcol) +print_columns(shf, n, func, arg, max_width, prefcol) + struct shf *shf; + int n; + char *(*func) ARGS((void *, int, char *, int)); + void *arg; + int max_width; + int prefcol; { char *str = (char *) alloc(max_width + 1, ATEMP); int i; @@ -1116,7 +1158,9 @@ print_columns(struct shf *shf, int n, char *(*func)(void *, int, char *, int), /* Strip any nul bytes from buf - returns new length (nbytes - # of nuls) */ int -strip_nuls(char *buf, int nbytes) +strip_nuls(buf, nbytes) + char *buf; + int nbytes; { char *dst; @@ -1147,7 +1191,10 @@ strip_nuls(char *buf, int nbytes) * Returns dst. */ char * -str_zcpy(char *dst, const char *src, int dsize) +str_zcpy(dst, src, dsize) + char *dst; + const char *src; + int dsize; { if (dsize > 0) { int len = strlen(src); @@ -1164,7 +1211,10 @@ str_zcpy(char *dst, const char *src, int dsize) * and restarts read. */ int -blocking_read(int fd, char *buf, int nbytes) +blocking_read(fd, buf, nbytes) + int fd; + char *buf; + int nbytes; { int ret; int tried_reset = 0; @@ -1193,7 +1243,8 @@ blocking_read(int fd, char *buf, int nbytes) * 1 if it was. */ int -reset_nonblock(int fd) +reset_nonblock(fd) + int fd; { int flags; int blocking_flags; @@ -1249,7 +1300,9 @@ reset_nonblock(int fd) /* Like getcwd(), except bsize is ignored if buf is 0 (MAXPATHLEN is used) */ char * -ksh_get_wd(char *buf, int bsize) +ksh_get_wd(buf, bsize) + char *buf; + int bsize; { #ifdef HAVE_GETCWD char *b; @@ -1309,4 +1362,3 @@ ksh_get_wd(char *buf, int bsize) return b; #endif /* HAVE_GETCWD */ } - diff --git a/bin/ksh/path.c b/bin/ksh/path.c index 0cf77bc0a..31e59b4f9 100644 --- a/bin/ksh/path.c +++ b/bin/ksh/path.c @@ -36,12 +36,14 @@ static char *do_phys_path ARGS((XString *, char *, const char *)); * if there are no more elements. * The return value indicates whether a non-null element from cdpathp * was appended to result. - * - * cdpathp - & of : separated list */ int -make_path(const char *cwd, const char *file, char **cdpathp, XString *xsp, - int *phys_pathp) +make_path(cwd, file, cdpathp, xsp, phys_pathp) + const char *cwd; + const char *file; + char **cdpathp; /* & of : separated list */ + XString *xsp; + int *phys_pathp; { int rval = 0; int use_cdpath = 1; @@ -114,7 +116,8 @@ make_path(const char *cwd, const char *file, char **cdpathp, XString *xsp, * ie, simplify_path("/a/b/c/./../d/..") returns "/a/b" */ void -simplify_path(char *pathx) +simplify_path(pathx) + char *pathx; { char *cur; char *t; @@ -196,7 +199,8 @@ simplify_path(char *pathx) void -set_current_wd(char *pathx) +set_current_wd(pathx) + char *pathx; { int len; char *p = pathx; @@ -215,7 +219,8 @@ set_current_wd(char *pathx) #ifdef S_ISLNK char * -get_phys_path(const char *pathx) +get_phys_path(pathx) + const char *pathx; { XString xs; char *xp; @@ -235,7 +240,10 @@ get_phys_path(const char *pathx) } static char * -do_phys_path(XString *xsp, char *xp, const char *pathx) +do_phys_path(xsp, xp, pathx) + XString *xsp; + char *xp; + const char *pathx; { const char *p, *q; int len, llen; @@ -288,7 +296,7 @@ do_phys_path(XString *xsp, char *xp, const char *pathx) #ifdef TEST -main(int argc, char **argv) +main(argc, argv) { int rv; char *cp, cdpath[256], pwd[256], file[256], result[256]; @@ -308,4 +316,3 @@ main(int argc, char **argv) } } #endif /* TEST */ - diff --git a/bin/ksh/proto.h b/bin/ksh/proto.h index 5dcd70306..3129b7c5a 100644 --- a/bin/ksh/proto.h +++ b/bin/ksh/proto.h @@ -296,4 +296,3 @@ extern int gettimeofday ARGS(( /* struct timeval *, struct timezone * */ )); extern int setrlimit ARGS(( /* int, struct rlimit * */ )); extern int lstat ARGS(( /* const char *, struct stat * */ )); #endif - diff --git a/bin/ksh/sh.h b/bin/ksh/sh.h index f7a405df4..83c3f70c0 100644 --- a/bin/ksh/sh.h +++ b/bin/ksh/sh.h @@ -733,4 +733,3 @@ EXTERN int x_cols I__(80); /* tty columns */ # undef EXTERN #endif #undef I__ - diff --git a/bin/ksh/shf.c b/bin/ksh/shf.c index 71e525241..9913b5a68 100644 --- a/bin/ksh/shf.c +++ b/bin/ksh/shf.c @@ -33,7 +33,11 @@ static int shf_emptybuf ARGS((struct shf *shf, int flags)); * fails. */ struct shf * -shf_open(const char *name, int oflags, int mode, int sflags) +shf_open(name, oflags, mode, sflags) + const char *name; + int oflags; + int mode; + int sflags; { struct shf *shf; int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE; @@ -73,7 +77,10 @@ shf_open(const char *name, int oflags, int mode, int sflags) /* Set up the shf structure for a file descriptor. Doesn't fail. */ struct shf * -shf_fdopen(int fd, int sflags, struct shf *shf) +shf_fdopen(fd, sflags, shf) + int fd; + int sflags; + struct shf *shf; { int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE; @@ -123,7 +130,10 @@ shf_fdopen(int fd, int sflags, struct shf *shf) /* Set up an existing shf (and buffer) to use the given fd */ struct shf * -shf_reopen(int fd, int sflags, struct shf *shf) +shf_reopen(fd, sflags, shf) + int fd; + int sflags; + struct shf *shf; { int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE; @@ -170,7 +180,11 @@ shf_reopen(int fd, int sflags, struct shf *shf) * When writing, a byte is reserved for a trailing null - see shf_sclose(). */ struct shf * -shf_sopen(char *buf, int bsize, int sflags, struct shf *shf) +shf_sopen(buf, bsize, sflags, shf) + char *buf; + int bsize; + int sflags; + struct shf *shf; { /* can't have a read+write string */ if (!(sflags & (SHF_RD | SHF_WR)) @@ -203,7 +217,8 @@ shf_sopen(char *buf, int bsize, int sflags, struct shf *shf) /* Flush and close file descriptor, free the shf structure */ int -shf_close(struct shf *shf) +shf_close(shf) + struct shf *shf; { int ret = 0; @@ -222,7 +237,8 @@ shf_close(struct shf *shf) /* Flush and close file descriptor, don't free file structure */ int -shf_fdclose(struct shf *shf) +shf_fdclose(shf) + struct shf *shf; { int ret = 0; @@ -244,7 +260,8 @@ shf_fdclose(struct shf *shf) * (does not free string if it was allocated). */ char * -shf_sclose(struct shf *shf) +shf_sclose(shf) + struct shf *shf; { unsigned char *s = shf->buf; @@ -260,7 +277,8 @@ shf_sclose(struct shf *shf) /* Flush and free file structure, don't close file descriptor */ int -shf_finish(struct shf *shf) +shf_finish(shf) + struct shf *shf; { int ret = 0; @@ -278,7 +296,8 @@ shf_finish(struct shf *shf) * buffered. Returns 0 for success, EOF for (write) error. */ int -shf_flush(struct shf *shf) +shf_flush(shf) + struct shf *shf; { if (shf->flags & SHF_STRING) return (shf->flags & SHF_WR) ? EOF : 0; @@ -309,7 +328,9 @@ shf_flush(struct shf *shf) * buffer. Returns 0 for success, EOF for (write) error. */ static int -shf_emptybuf(struct shf *shf, int flags) +shf_emptybuf(shf, flags) + struct shf *shf; + int flags; { int ret = 0; @@ -389,7 +410,8 @@ shf_emptybuf(struct shf *shf, int flags) /* Fill up a read buffer. Returns EOF for a read error, 0 otherwise. */ static int -shf_fillbuf(struct shf *shf) +shf_fillbuf(shf) + struct shf *shf; { if (shf->flags & SHF_STRING) return 0; @@ -435,7 +457,10 @@ shf_fillbuf(struct shf *shf) * buffer. Returns 0 for success, EOF otherwise. */ int -shf_seek(struct shf *shf, off_t where, int from) +shf_seek(shf, where, from) + struct shf *shf; + off_t where; + int from; { if (shf->fd < 0) { errno = EINVAL; @@ -480,7 +505,10 @@ shf_seek(struct shf *shf, off_t where, int from) * a read error occurred. */ int -shf_read(char *buf, int bsize, struct shf *shf) +shf_read(buf, bsize, shf) + char *buf; + int bsize; + struct shf *shf; { int orig_bsize = bsize; int ncopy; @@ -514,7 +542,10 @@ shf_read(char *buf, int bsize, struct shf *shf) * end of file, returns a pointer to the null byte in buf otherwise. */ char * -shf_getse(char *buf, int bsize, struct shf *shf) +shf_getse(buf, bsize, shf) + char *buf; + int bsize; + struct shf *shf; { unsigned char *end; int ncopy; @@ -561,7 +592,8 @@ shf_getse(char *buf, int bsize, struct shf *shf) /* Returns the char read. Returns EOF for error and end of file. */ int -shf_getchar(struct shf *shf) +shf_getchar(shf) + struct shf *shf; { if (!(shf->flags & SHF_RD)) internal_errorf(1, "shf_getchar: flags %x", shf->flags); @@ -576,7 +608,9 @@ shf_getchar(struct shf *shf) * successful, EOF if there is no room. */ int -shf_ungetc(int c, struct shf *shf) +shf_ungetc(c, shf) + int c; + struct shf *shf; { if (!(shf->flags & SHF_RD)) internal_errorf(1, "shf_ungetc: flags %x", shf->flags); @@ -611,7 +645,9 @@ shf_ungetc(int c, struct shf *shf) * the char could not be written. */ int -shf_putchar(int c, struct shf *shf) +shf_putchar(c, shf) + int c; + struct shf *shf; { if (!(shf->flags & SHF_WR)) internal_errorf(1, "shf_putchar: flags %x", shf->flags); @@ -653,7 +689,9 @@ shf_putchar(int c, struct shf *shf) * the string could not be written. */ int -shf_puts(const char *s, struct shf *shf) +shf_puts(s, shf) + const char *s; + struct shf *shf; { if (!s) return EOF; @@ -663,7 +701,10 @@ shf_puts(const char *s, struct shf *shf) /* Write a buffer. Returns nbytes if successful, EOF if there is an error. */ int -shf_write(const char *buf, int nbytes, struct shf *shf) +shf_write(buf, nbytes, shf) + const char *buf; + int nbytes; + struct shf *shf; { int orig_nbytes = nbytes; int n; @@ -724,7 +765,14 @@ shf_write(const char *buf, int nbytes, struct shf *shf) } int +#ifdef HAVE_PROTOTYPES shf_fprintf(struct shf *shf, const char *fmt, ...) +#else +shf_fprintf(shf, fmt, va_alist) + struct shf *shf; + const char *fmt; + va_dcl +#endif { va_list args; int n; @@ -737,7 +785,15 @@ shf_fprintf(struct shf *shf, const char *fmt, ...) } int +#ifdef HAVE_PROTOTYPES shf_snprintf(char *buf, int bsize, const char *fmt, ...) +#else +shf_snprintf(buf, bsize, fmt, va_alist) + char *buf; + int bsize; + const char *fmt; + va_dcl +#endif { struct shf shf; va_list args; @@ -756,7 +812,13 @@ shf_snprintf(char *buf, int bsize, const char *fmt, ...) } char * +#ifdef HAVE_PROTOTYPES shf_smprintf(const char *fmt, ...) +#else +shf_smprintf(fmt, va_alist) + char *fmt; + va_dcl +#endif { struct shf shf; va_list args; @@ -816,7 +878,8 @@ shf_smprintf(const char *fmt, ...) #include static double -my_ceil(double d) +my_ceil(d) + double d; { double i; @@ -825,7 +888,10 @@ my_ceil(double d) #endif /* FP */ int -shf_vfprintf(struct shf *shf, const char *fmt, va_list args) +shf_vfprintf(shf, fmt, args) + struct shf *shf; + const char *fmt; + va_list args; { char c, *s; int UNINITIALIZED(tmp); @@ -1234,4 +1300,3 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args) return shf_error(shf) ? EOF : nwritten; } - diff --git a/bin/ksh/shf.h b/bin/ksh/shf.h index 9a6ad08e4..bc8af96c4 100644 --- a/bin/ksh/shf.h +++ b/bin/ksh/shf.h @@ -85,4 +85,3 @@ char *shf_smprintf ARGS((const char *fmt, ...)); int shf_vfprintf ARGS((struct shf *, const char *fmt, va_list args)); #endif /* SHF_H */ - diff --git a/bin/ksh/sigact.c b/bin/ksh/sigact.c index b9f5c458f..80ff9a8e2 100644 --- a/bin/ksh/sigact.c +++ b/bin/ksh/sigact.c @@ -209,7 +209,9 @@ error must know what to implement with int -sigaction(int sig, struct sigaction *act, struct sigaction *oact) +sigaction(sig, act, oact) + int sig; + struct sigaction *act, *oact; { handler_t oldh; @@ -259,7 +261,9 @@ sigaction(int sig, struct sigaction *act, struct sigaction *oact) int -sigaddset(sigset_t *mask, int sig) +sigaddset(mask, sig) + sigset_t *mask; + int sig; { *mask |= sigmask(sig); return 0; @@ -268,7 +272,9 @@ sigaddset(sigset_t *mask, int sig) #ifndef IS_KSH int -sigdelset(sigset_t *mask, int sig) +sigdelset(mask, sig) + sigset_t *mask; + int sig; { *mask &= ~(sigmask(sig)); return 0; @@ -277,7 +283,8 @@ sigdelset(sigset_t *mask, int sig) int -sigemptyset(sigset_t *mask) +sigemptyset(mask) + sigset_t *mask; { *mask = 0; return 0; @@ -286,7 +293,8 @@ sigemptyset(sigset_t *mask) #ifndef IS_KSH int -sigfillset(sigset_t *mask) +sigfillset(mask) + sigset_t *mask; { *mask = ~0; return 0; @@ -296,7 +304,9 @@ sigfillset(sigset_t *mask) #ifndef IS_KSH int -sigismember(sigset_t *mask, int sig) +sigismember(mask, sig) + sigset_t *mask; + int sig; { return ((*mask) & sigmask(sig)); } @@ -305,7 +315,8 @@ sigismember(sigset_t *mask, int sig) #ifndef IS_KSH int -sigpending(sigset_t *set) +sigpending(set) + sigset_t *set; { return 0; /* faking it! */ } @@ -313,7 +324,9 @@ sigpending(sigset_t *set) int -sigprocmask(int how, sigset_t *set, sigset_t *oset) +sigprocmask(how, set, oset) + int how; + sigset_t *set, *oset; { #ifdef USE_SIGSET register int i; @@ -377,7 +390,8 @@ sigprocmask(int how, sigset_t *set, sigset_t *oset) int -sigsuspend(sigset_t *mask) +sigsuspend(mask) + sigset_t *mask; { #ifdef USE_SIGMASK sigpause(*mask); @@ -433,8 +447,9 @@ sigsuspend(sigset_t *mask) */ #ifndef IS_KSH -handler_t -Signal(int sig, handler_t handler) +handler_t Signal(sig, handler) + int sig; + handler_t handler; { struct sigaction act, oact; @@ -453,8 +468,9 @@ Signal(int sig, handler_t handler) * ensure we avoid signal mayhem */ -handler_t -signal(int sig, handler_t handler) +handler_t signal(sig, handler) + int sig; + handler_t handler; { return (Signal(sig, handler)); } @@ -468,4 +484,3 @@ signal(int sig, handler_t handler) * comment-column:40 * End: */ - diff --git a/bin/ksh/sigact.h b/bin/ksh/sigact.h index c0633eb14..e1dce463d 100644 --- a/bin/ksh/sigact.h +++ b/bin/ksh/sigact.h @@ -123,4 +123,3 @@ int sigsuspend ARGS(( sigset_t *mask )); #endif #endif /* ! SA_NOCLDSTOP */ #endif /* _SIGACT_H */ - diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c index e80fd60b4..01cc8ed16 100644 --- a/bin/ksh/syn.c +++ b/bin/ksh/syn.c @@ -67,7 +67,7 @@ static int symbol; /* yylex value */ ((reject) ? (symbol) : (REJECT, symbol = yylex(cf))) static void -yyparse(void) +yyparse() { int c; @@ -82,7 +82,8 @@ yyparse(void) } static struct op * -pipeline(int cf) +pipeline(cf) + int cf; { register struct op *t, *p, *tl = NULL; @@ -102,7 +103,7 @@ pipeline(int cf) } static struct op * -andor(void) +andor() { register struct op *t, *p; register int c; @@ -120,7 +121,8 @@ andor(void) } static struct op * -c_list(int multi) +c_list(multi) + int multi; { register struct op *t = NULL, *p, *tl = NULL; register int c; @@ -157,7 +159,8 @@ c_list(int multi) } static struct ioword * -synio(int cf) +synio(cf) + int cf; { register struct ioword *iop; int ishere; @@ -181,14 +184,16 @@ synio(int cf) } static void -musthave(int c, int cf) +musthave(c, cf) + int c, cf; { if ((token(cf)) != c) syntaxerr((char *) 0); } static struct op * -nested(int type, int smark, int emark) +nested(type, smark, emark) + int type, smark, emark; { register struct op *t; struct nesting_state old_nesting; @@ -201,7 +206,8 @@ nested(int type, int smark, int emark) } static struct op * -get_command(int cf) +get_command(cf) + int cf; { register struct op *t; register int c, iopn = 0, syniocf; @@ -417,7 +423,7 @@ get_command(int cf) } static struct op * -dogroup(void) +dogroup() { register int c; register struct op *list; @@ -440,7 +446,7 @@ dogroup(void) } static struct op * -thenpart(void) +thenpart() { register struct op *t; @@ -454,7 +460,7 @@ thenpart(void) } static struct op * -elsepart(void) +elsepart() { register struct op *t; @@ -477,7 +483,7 @@ elsepart(void) } static struct op * -caselist(void) +caselist() { register struct op *t, *tl; int c; @@ -503,7 +509,8 @@ caselist(void) } static struct op * -casepart(int endtok) +casepart(endtok) + int endtok; { register struct op *t; register int c; @@ -530,10 +537,10 @@ casepart(int endtok) return (t); } - -/* ksh_func - function foo { ... } vs foo() { .. } */ static struct op * -function_body(char *name, int ksh_func) +function_body(name, ksh_func) + char *name; + int ksh_func; /* function foo { ... } vs foo() { .. } */ { char *sname, *p; struct op *t; @@ -592,7 +599,7 @@ function_body(char *name, int ksh_func) } static char ** -wordlist(void) +wordlist() { register int c; XPtrV args; @@ -622,7 +629,10 @@ wordlist(void) */ static struct op * -block(int type, struct op *t1, struct op *t2, char **wp) +block(type, t1, t2, wp) + int type; + struct op *t1, *t2; + char **wp; { register struct op *t; @@ -677,7 +687,7 @@ const struct tokeninfo { }; void -initkeywords(void) +initkeywords() { register struct tokeninfo const *tt; register struct tbl *p; @@ -694,7 +704,8 @@ initkeywords(void) } static void -syntaxerr(const char *what) +syntaxerr(what) + const char *what; { char redir[6]; /* 2<<- is the longest redirection, I think */ const char *s; @@ -746,7 +757,9 @@ syntaxerr(const char *what) } static void -nesting_push(struct nesting_state *save, int tok) +nesting_push(save, tok) + struct nesting_state *save; + int tok; { *save = nesting; nesting.start_token = tok; @@ -754,13 +767,15 @@ nesting_push(struct nesting_state *save, int tok) } static void -nesting_pop(struct nesting_state *saved) +nesting_pop(saved) + struct nesting_state *saved; { nesting = *saved; } static struct op * -newtp(int type) +newtp(type) + int type; { register struct op *t; @@ -775,7 +790,8 @@ newtp(int type) } struct op * -compile(Source *s) +compile(s) + Source *s; { nesting.start_token = 0; nesting.start_line = 0; @@ -796,7 +812,8 @@ compile(Source *s) * $ */ static int -assign_command(char *s) +assign_command(s) + char *s; { char c = *s; @@ -810,7 +827,8 @@ assign_command(char *s) /* Check if we are in the middle of reading an alias */ static int -inalias(struct source *s) +inalias(s) + struct source *s; { for (; s && s->type == SALIAS; s = s->next) if (!(s->flags & SF_ALIASEND)) @@ -843,7 +861,9 @@ const char db_gthan[] = { CHAR, '>', EOS }; * TM_UNOP and TM_BINOP, the returned value is a Test_op). */ static int -dbtestp_isa(Test_env *te, Test_meta meta) +dbtestp_isa(te, meta) + Test_env *te; + Test_meta meta; { int c = tpeek(ARRAYVAR | (meta == TM_BINOP ? 0 : CONTIN)); int uqword = 0; @@ -891,7 +911,10 @@ dbtestp_isa(Test_env *te, Test_meta meta) } static const char * -dbtestp_getopnd(Test_env *te, Test_op op, int do_eval) +dbtestp_getopnd(te, op, do_eval) + Test_env *te; + Test_op op; + int do_eval; { int c = tpeek(ARRAYVAR); @@ -905,14 +928,21 @@ 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) +dbtestp_eval(te, op, opnd1, opnd2, do_eval) + Test_env *te; + Test_op op; + const char *opnd1; + const char *opnd2; + int do_eval; { return 1; } static void -dbtestp_error(Test_env *te, int offset, const char *msg) +dbtestp_error(te, offset, msg) + Test_env *te; + int offset; + const char *msg; { te->flags |= TEF_ERROR; @@ -926,4 +956,3 @@ dbtestp_error(Test_env *te, int offset, const char *msg) syntaxerr(msg); } #endif /* KSH */ - diff --git a/bin/ksh/table.c b/bin/ksh/table.c index 97b599bc8..025b56d27 100644 --- a/bin/ksh/table.c +++ b/bin/ksh/table.c @@ -19,7 +19,8 @@ static int tnamecmp ARGS((void *p1, void *p2)); unsigned int -hash(register const char *n) +hash(n) + register const char * n; { register unsigned int h = 0; @@ -29,7 +30,10 @@ hash(register const char *n) } void -tinit(register struct table *tp, register Area *ap, int tsize) +tinit(tp, ap, tsize) + register struct table *tp; + register Area *ap; + int tsize; { tp->areap = ap; tp->tbls = NULL; @@ -39,7 +43,9 @@ tinit(register struct table *tp, register Area *ap, int tsize) } static void -texpand(register struct table *tp, int nsize) +texpand(tp, nsize) + register struct table *tp; + int nsize; { register int i; register struct tbl *tblp, **p; @@ -72,13 +78,11 @@ texpand(register struct table *tp, int nsize) afree((void*)otblp, tp->areap); } -/* - * tp - table - * n - name to enter - * h - hash(n) - */ struct tbl * -tsearch(register struct table *tp, register const char *n, unsigned int h) +tsearch(tp, n, h) + register struct table *tp; /* table */ + register const char *n; /* name to enter */ + unsigned int h; /* hash(n) */ { register struct tbl **pp, *p; @@ -97,13 +101,11 @@ tsearch(register struct table *tp, register const char *n, unsigned int h) return NULL; } -/* - * tp - table - * n - name to enter - * h - hash(n) - */ struct tbl * -tenter(register struct table *tp, register const char *n, unsigned int h) +tenter(tp, n, h) + register struct table *tp; /* table */ + register const char *n; /* name to enter */ + unsigned int h; /* hash(n) */ { register struct tbl **pp, *p; register int len; @@ -142,20 +144,24 @@ tenter(register struct table *tp, register const char *n, unsigned int h) } void -tdelete(register struct tbl *p) +tdelete(p) + register struct tbl *p; { p->flag = 0; } void -twalk(struct tstate *ts, struct table *tp) +twalk(ts, tp) + struct tstate *ts; + struct table *tp; { ts->left = tp->size; ts->next = tp->tbls; } struct tbl * -tnext(struct tstate *ts) +tnext(ts) + struct tstate *ts; { while (--ts->left >= 0) { struct tbl *p = *ts->next++; @@ -166,13 +172,15 @@ tnext(struct tstate *ts) } static int -tnamecmp(void *p1, void *p2) +tnamecmp(p1, p2) + void *p1, *p2; { return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name); } struct tbl ** -tsort(register struct table *tp) +tsort(tp) + register struct table *tp; { register int i; register struct tbl **p, **sp, **dp; @@ -195,7 +203,8 @@ tsort(register struct table *tp) void tprintinfo ARGS((struct table *tp)); void -tprintinfo(struct table *tp) +tprintinfo(tp) + struct table *tp; { struct tbl *te; char *n; @@ -236,4 +245,3 @@ tprintinfo(struct table *tp) (totncmp % nentries) * 100 / nentries); } #endif /* PERF_DEBUG */ - diff --git a/bin/ksh/table.h b/bin/ksh/table.h index c558643a0..9dc42c851 100644 --- a/bin/ksh/table.h +++ b/bin/ksh/table.h @@ -179,4 +179,3 @@ EXTERN char *tmpdir; /* TMPDIR value */ EXTERN const char *prompt; EXTERN int cur_prompt; /* PS1 or PS2 */ EXTERN int current_lineno; /* LINENO value */ - diff --git a/bin/ksh/trap.c b/bin/ksh/trap.c index c4c4d575b..fa212aab5 100644 --- a/bin/ksh/trap.c +++ b/bin/ksh/trap.c @@ -28,7 +28,7 @@ Trap sigtraps[SIGNALS+1] = { static struct sigaction Sigact_ign, Sigact_trap; void -inittraps(void) +inittraps() { #ifdef HAVE_SYS_SIGLIST # ifndef SYS_SIGLIST_DECLARED @@ -65,7 +65,7 @@ inittraps(void) static RETSIGTYPE alarm_catcher ARGS((int sig)); void -alarm_init(void) +alarm_init() { sigtraps[SIGALRM].flags |= TF_SHELL_USES; setsig(&sigtraps[SIGALRM], alarm_catcher, @@ -73,7 +73,8 @@ alarm_init(void) } static RETSIGTYPE -alarm_catcher(int sig) +alarm_catcher(sig) + int sig; { int errno_ = errno; @@ -92,7 +93,9 @@ alarm_catcher(int sig) #endif /* KSH */ Trap * -gettrap(const char *name, int igncase) +gettrap(name, igncase) + const char *name; + int igncase; { int i; register Trap *p; @@ -126,7 +129,8 @@ gettrap(const char *name, int igncase) * trap signal handler */ RETSIGTYPE -trapsig(int i) +trapsig(i) + int i; { Trap *p = &sigtraps[i]; int errno_ = errno; @@ -152,7 +156,7 @@ trapsig(int i) * work if user has trapped SIGINT. */ void -intrcheck(void) +intrcheck() { if (intrsig) runtraps(TF_DFL_INTR|TF_FATAL); @@ -162,7 +166,7 @@ intrcheck(void) * termination has been received. */ int -fatal_trap_check(void) +fatal_trap_check() { int i; Trap *p; @@ -180,7 +184,7 @@ fatal_trap_check(void) * is set. */ int -trap_pending(void) +trap_pending() { int i; Trap *p; @@ -198,7 +202,8 @@ trap_pending(void) * can interrupt commands. */ void -runtraps(int flag) +runtraps(flag) + int flag; { int i; register Trap *p; @@ -227,7 +232,8 @@ runtraps(int flag) } void -runtrap(Trap *p) +runtrap(p) + Trap *p; { int i = p->signal; char *trapstr = p->trap; @@ -273,7 +279,7 @@ runtrap(Trap *p) /* clear pending traps and reset user's trap handlers; used after fork(2) */ void -cleartraps(void) +cleartraps() { int i; Trap *p; @@ -290,7 +296,7 @@ cleartraps(void) /* restore signals just before an exec(2) */ void -restoresigs(void) +restoresigs() { int i; Trap *p; @@ -302,7 +308,9 @@ restoresigs(void) } void -settrap(Trap *p, char *s) +settrap(p, s) + Trap *p; + char *s; { handler_t f; @@ -341,7 +349,7 @@ settrap(Trap *p, char *s) * kill shell (unless user catches it and exits) */ int -block_pipe(void) +block_pipe() { int restore_dfl = 0; Trap *p = &sigtraps[SIGPIPE]; @@ -359,7 +367,8 @@ block_pipe(void) /* Called by c_print() to undo whatever block_pipe() did */ void -restore_pipe(int restore_dfl) +restore_pipe(restore_dfl) + int restore_dfl; { if (restore_dfl) setsig(&sigtraps[SIGPIPE], SIG_DFL, SS_RESTORE_CURR); @@ -370,7 +379,10 @@ restore_pipe(int restore_dfl) * FTALKING. */ int -setsig(Trap *p, handler_t f, int flags) +setsig(p, f, flags) + Trap *p; + handler_t f; + int flags; { struct sigaction sigact; @@ -421,7 +433,9 @@ setsig(Trap *p, handler_t f, int flags) /* control what signal is set to before an exec() */ void -setexecsig(Trap *p, int restore) +setexecsig(p, restore) + Trap *p; + int restore; { /* XXX debugging */ if (!(p->flags & (TF_ORIG_IGN|TF_ORIG_DFL))) @@ -444,4 +458,3 @@ setexecsig(Trap *p, int restore) break; } } - diff --git a/bin/ksh/tree.c b/bin/ksh/tree.c index 7fc78b8a2..96450221f 100644 --- a/bin/ksh/tree.c +++ b/bin/ksh/tree.c @@ -28,7 +28,10 @@ static void iofree ARGS((struct ioword **iow, Area *ap)); */ static void -ptree(register struct op *t, int indent, register struct shf *shf) +ptree(t, indent, shf) + register struct op *t; + int indent; + register struct shf *shf; { register char **w; struct ioword **ioact; @@ -212,7 +215,10 @@ ptree(register struct op *t, int indent, register struct shf *shf) } static void -pioact(register struct shf *shf, int indent, register struct ioword *iop) +pioact(shf, indent, iop) + register struct shf *shf; + int indent; + register struct ioword *iop; { int flag = iop->flag; int type = flag & IOTYPE; @@ -270,7 +276,9 @@ pioact(register struct shf *shf, int indent, register struct ioword *iop) */ static void -tputC(register int c, register struct shf *shf) +tputC(c, shf) + register int c; + register struct shf *shf; { if ((c&0x60) == 0) { /* C0|C1 */ tputc((c&0x80) ? '$' : '^', shf); @@ -283,7 +291,9 @@ tputC(register int c, register struct shf *shf) } static void -tputS(register char *wp, register struct shf *shf) +tputS(wp, shf) + register char *wp; + register struct shf *shf; { register int c, quoted=0; @@ -365,7 +375,15 @@ tputS(register char *wp, register struct shf *shf) */ /* VARARGS */ int +#ifdef HAVE_PROTOTYPES fptreef(struct shf *shf, int indent, const char *fmt, ...) +#else +fptreef(shf, indent, fmt, va_alist) + struct shf *shf; + int indent; + const char *fmt; + va_dcl +#endif { va_list va; @@ -378,7 +396,15 @@ fptreef(struct shf *shf, int indent, const char *fmt, ...) /* VARARGS */ char * +#ifdef HAVE_PROTOTYPES snptreef(char *s, int n, const char *fmt, ...) +#else +snptreef(s, n, fmt, va_alist) + char *s; + int n; + const char *fmt; + va_dcl +#endif { va_list va; struct shf shf; @@ -393,8 +419,11 @@ snptreef(char *s, int n, const char *fmt, ...) } static void -vfptreef(register struct shf *shf, int indent, const char *fmt, - register va_list va) +vfptreef(shf, indent, fmt, va) + register struct shf *shf; + int indent; + const char *fmt; + register va_list va; { register int c; @@ -462,7 +491,9 @@ vfptreef(register struct shf *shf, int indent, const char *fmt, */ struct op * -tcopy(register struct op *t, Area *ap) +tcopy(t, ap) + register struct op *t; + Area *ap; { register struct op *r; register char **tw, **rw; @@ -511,7 +542,9 @@ tcopy(register struct op *t, Area *ap) } char * -wdcopy(const char *wp, Area *ap) +wdcopy(wp, ap) + const char *wp; + Area *ap; { size_t len = wdscan(wp, EOS) - wp; return memcpy(alloc(len, ap), wp, len); @@ -519,7 +552,9 @@ wdcopy(const char *wp, Area *ap) /* return the position of prefix c in wp plus 1 */ char * -wdscan(register const char *wp, register int c) +wdscan(wp, c) + register const char *wp; + register int c; { register int nest = 0; @@ -575,7 +610,8 @@ wdscan(register const char *wp, register int c) * (string is allocated from ATEMP) */ char * -wdstrip(const char *wp) +wdstrip(wp) + const char *wp; { struct shf shf; int c; @@ -642,7 +678,9 @@ wdstrip(const char *wp) } static struct ioword ** -iocopy(register struct ioword **iow, Area *ap) +iocopy(iow, ap) + register struct ioword **iow; + Area *ap; { register struct ioword **ior; register int i; @@ -675,7 +713,9 @@ iocopy(register struct ioword **iow, Area *ap) */ void -tfree(register struct op *t, Area *ap) +tfree(t, ap) + register struct op *t; + Area *ap; { register char **w; @@ -707,7 +747,9 @@ tfree(register struct op *t, Area *ap) } static void -iofree(struct ioword **iow, Area *ap) +iofree(iow, ap) + struct ioword **iow; + Area *ap; { register struct ioword **iop; register struct ioword *p; @@ -722,4 +764,3 @@ iofree(struct ioword **iow, Area *ap) afree((void*)p, ap); } } - diff --git a/bin/ksh/tree.h b/bin/ksh/tree.h index 59873b2c4..b0aea1e1c 100644 --- a/bin/ksh/tree.h +++ b/bin/ksh/tree.h @@ -140,4 +140,3 @@ struct ioword { #define DB_AND 3 /* && -> -a conversion */ #define DB_BE 4 /* an inserted -BE */ #define DB_PAT 5 /* a pattern argument */ - diff --git a/bin/ksh/tty.c b/bin/ksh/tty.c index c913f6529..8a60d7329 100644 --- a/bin/ksh/tty.c +++ b/bin/ksh/tty.c @@ -14,7 +14,9 @@ __RCSID("$NetBSD: tty.c,v 1.4 2003/06/23 11:39:06 agc Exp $"); #undef EXTERN int -get_tty(int fd, TTY_state *ts) +get_tty(fd, ts) + int fd; + TTY_state *ts; { int ret; @@ -42,7 +44,10 @@ get_tty(int fd, TTY_state *ts) } int -set_tty(int fd, TTY_state *ts, int flags) +set_tty(fd, ts, flags) + int fd; + TTY_state *ts; + int flags; { int ret = 0; @@ -101,7 +106,8 @@ set_tty(int fd, TTY_state *ts, int flags) * foreground job completion and for setting up tty process group. */ void -tty_init(int init_ttystate) +tty_init(init_ttystate) + int init_ttystate; { int do_close = 1; int tfd; @@ -172,11 +178,10 @@ tty_init(int init_ttystate) } void -tty_close(void) +tty_close() { if (tty_fd >= 0) { close(tty_fd); tty_fd = -1; } } - diff --git a/bin/ksh/tty.h b/bin/ksh/tty.h index f889c6589..08c6b7c59 100644 --- a/bin/ksh/tty.h +++ b/bin/ksh/tty.h @@ -108,4 +108,3 @@ extern void tty_close ARGS((void)); # undef EXTERN #endif #undef I__ - diff --git a/bin/ksh/var.c b/bin/ksh/var.c index 5af76453a..b98a5dd36 100644 --- a/bin/ksh/var.c +++ b/bin/ksh/var.c @@ -38,7 +38,7 @@ static struct tbl *arraysearch ARGS((struct tbl *, int)); * assume caller has allocated and set up e->loc */ void -newblock(void) +newblock() { register struct block *l; static char *const empty[] = {null}; @@ -64,7 +64,7 @@ newblock(void) * pop a block handling special variables */ void -popblock(void) +popblock() { register struct block *l = e->loc; register struct tbl *vp, **vpp = l->vars.tbls, *vq; @@ -87,7 +87,7 @@ popblock(void) /* called by main() to initialize variable data structures */ void -initvar(void) +initvar() { static const struct { const char *name; @@ -136,7 +136,10 @@ initvar(void) const char *array_index_calc(const char *n, bool_t *arrayp, int *valp); const char * -array_index_calc(const char *n, bool_t *arrayp, int *valp) +array_index_calc(n, arrayp, valp) + const char *n; + bool_t *arrayp; + int *valp; { const char *p; int len; @@ -166,7 +169,8 @@ array_index_calc(const char *n, bool_t *arrayp, int *valp) * Search for variable, if not found create globally. */ struct tbl * -global(register const char *n) +global(n) + register const char *n; { register struct block *l = e->loc; register struct tbl *vp; @@ -248,7 +252,9 @@ global(register const char *n) * Search for local variable, if not found create locally. */ struct tbl * -local(register const char *n, bool_t copy) +local(n, copy) + register const char *n; + bool_t copy; { register struct block *l = e->loc; register struct tbl *vp; @@ -292,7 +298,8 @@ local(register const char *n, bool_t copy) /* get variable string value */ char * -str_val(register struct tbl *vp) +str_val(vp) + register struct tbl *vp; { char *s; @@ -344,7 +351,8 @@ str_val(register struct tbl *vp) /* get variable integer value, with error checking */ long -intval(register struct tbl *vp) +intval(vp) + register struct tbl *vp; { long num; int base; @@ -358,7 +366,10 @@ intval(register struct tbl *vp) /* set variable to string value */ int -setstr(register struct tbl *vq, const char *s, int error_ok) +setstr(vq, s, error_ok) + register struct tbl *vq; + const char *s; + int error_ok; { char *fs = NULL; int no_ro_check = error_ok & 0x4; @@ -402,7 +413,9 @@ setstr(register struct tbl *vq, const char *s, int error_ok) /* set variable to integer */ void -setint(register struct tbl *vq, long n) +setint(vq, n) + register struct tbl *vq; + long n; { if (!(vq->flag&INTEGER)) { register struct tbl *vp = &vtemp; @@ -420,7 +433,9 @@ setint(register struct tbl *vq, long n) } int -getint(struct tbl *vp, long *nump) +getint(vp, nump) + struct tbl *vp; + long *nump; { register char *s; register int c; @@ -484,7 +499,8 @@ getint(struct tbl *vp, long *nump) * (vq and vp may be the same) */ struct tbl * -setint_v(register struct tbl *vq, register struct tbl *vp) +setint_v(vq, vp) + register struct tbl *vq, *vp; { int base; long num; @@ -505,7 +521,9 @@ setint_v(register struct tbl *vq, register struct tbl *vp) } static char * -formatstr(struct tbl *vp, const char *s) +formatstr(vp, s) + struct tbl *vp; + const char *s; { int olen, nlen; char *p, *q; @@ -567,7 +585,9 @@ formatstr(struct tbl *vp, const char *s) * make vp->val.s be "name=value" for quick exporting. */ static void -export(register struct tbl *vp, const char *val) +export(vp, val) + register struct tbl *vp; + const char *val; { register char *xp; char *op = (vp->flag&ALLOC) ? vp->val.s : NULL; @@ -591,7 +611,10 @@ export(register struct tbl *vp, const char *val) * LCASEV, UCASEV_AL), and optionally set its value if an assignment. */ struct tbl * -typeset(register const char *var, Tflag set, Tflag clr, int field, int base) +typeset(var, set, clr, field, base) + register const char *var; + Tflag clr, set; + int field, base; { register struct tbl *vp; struct tbl *vpbase, *t; @@ -742,7 +765,9 @@ typeset(register const char *var, Tflag set, Tflag clr, int field, int base) * the name lookup (eg, x[2]). */ void -unset(register struct tbl *vp, int array_ref) +unset(vp, array_ref) + register struct tbl *vp; + int array_ref; { if (vp->flag & ALLOC) afree((void*)vp->val.s, vp->areap); @@ -770,7 +795,9 @@ unset(register struct tbl *vp, int array_ref) * null if whole string is legal). */ char * -skip_varname(const char *s, int aok) +skip_varname(s, aok) + const char *s; + int aok; { int alen; @@ -783,11 +810,11 @@ skip_varname(const char *s, int aok) return (char *) __UNCONST(s); } -/* Return a pointer to the first character past any legal variable name. - * aok - skip array de-reference? - */ +/* Return a pointer to the first character past any legal variable name. */ char * -skip_wdvarname(const char *s, int aok) +skip_wdvarname(s, aok) + const char *s; + int aok; /* skip array de-reference? */ { if (s[0] == CHAR && letter(s[1])) { do @@ -818,7 +845,9 @@ skip_wdvarname(const char *s, int aok) /* Check if coded string s is a variable name */ int -is_wdvarname(const char *s, int aok) +is_wdvarname(s, aok) + const char *s; + int aok; { char *p = skip_wdvarname(s, aok); @@ -827,7 +856,8 @@ is_wdvarname(const char *s, int aok) /* Check if coded string s is a variable assignment */ int -is_wdvarassign(const char *s) +is_wdvarassign(s) + const char *s; { char *p = skip_wdvarname(s, TRUE); @@ -838,7 +868,7 @@ is_wdvarassign(const char *s) * Make the exported environment from the exported names in the dictionary. */ char ** -makenv(void) +makenv() { struct block *l = e->loc; XPtrV env; @@ -880,7 +910,7 @@ makenv(void) * if the parent doesn't use $RANDOM. */ void -change_random(void) +change_random() { rand(); } @@ -891,7 +921,8 @@ change_random(void) /* Test if name is a special parameter */ static int -special(register const char *name) +special(name) + register const char * name; { register struct tbl *tp; @@ -901,7 +932,8 @@ special(register const char *name) /* Make a variable non-special */ static void -unspecial(register const char *name) +unspecial(name) + register const char * name; { register struct tbl *tp; @@ -916,7 +948,8 @@ static time_t seconds; /* time SECONDS last set */ static int user_lineno; /* what user set $LINENO to */ static void -getspec(register struct tbl *vp) +getspec(vp) + register struct tbl *vp; { switch (special(vp->name)) { #ifdef KSH @@ -957,7 +990,8 @@ getspec(register struct tbl *vp) } static void -setspec(register struct tbl *vp) +setspec(vp) + register struct tbl *vp; { char *s; @@ -1057,7 +1091,8 @@ setspec(register struct tbl *vp) } static void -unsetspec(register struct tbl *vp) +unsetspec(vp) + register struct tbl *vp; { switch (special(vp->name)) { case V_PATH: @@ -1115,7 +1150,9 @@ unsetspec(register struct tbl *vp) * vp, indexed by val. */ static struct tbl * -arraysearch(struct tbl *vp, int val) +arraysearch(vp, val) + struct tbl *vp; + int val; { struct tbl *prev, *curr, *new; size_t namelen = strlen(vp->name) + 1; @@ -1159,7 +1196,8 @@ arraysearch(struct tbl *vp, int val) * bracket. */ int -array_ref_len(const char *cp) +array_ref_len(cp) + const char *cp; { const char *s = cp; int c; @@ -1177,7 +1215,8 @@ array_ref_len(const char *cp) * Make a copy of the base of an array name */ char * -arrayname(const char *str) +arrayname(str) + const char *str; { const char *p; @@ -1191,7 +1230,10 @@ arrayname(const char *str) /* Set (or overwrite, if !reset) the array variable var to the values in vals. */ void -set_array(const char *var, int reset, char **vals) +set_array(var, reset, vals) + const char *var; + int reset; + char **vals; { struct tbl *vp, *vq; int i; @@ -1216,4 +1258,3 @@ set_array(const char *var, int reset, char **vals) setstr(vq, vals[i], KSH_RETURN_ERROR); } } - diff --git a/bin/ksh/version.c b/bin/ksh/version.c index 774d914f1..3db43d0e4 100644 --- a/bin/ksh/version.c +++ b/bin/ksh/version.c @@ -14,4 +14,3 @@ __RCSID("$NetBSD: version.c,v 1.5 2005/06/26 19:09:00 christos Exp $"); char ksh_version [] = "@(#)PD KSH v5.2.14 99/07/13.2"; - diff --git a/bin/ksh/vi.c b/bin/ksh/vi.c index b139b0eca..ed3d06fc6 100644 --- a/bin/ksh/vi.c +++ b/bin/ksh/vi.c @@ -194,7 +194,9 @@ enum expand_mode { NONE, EXPAND, COMPLETE, PRINT }; static enum expand_mode expanded = NONE;/* last input was expanded */ int -x_vi(char *buf, size_t len) +x_vi(buf, len) + char *buf; + size_t len; { int c; @@ -254,7 +256,8 @@ x_vi(char *buf, size_t len) } static int -vi_hook(int ch) +vi_hook(ch) + int ch; { static char curcmd[MAXVICMD]; static char locpat[SRCHLEN]; @@ -551,7 +554,9 @@ vi_hook(int ch) } static void -vi_reset(char *buf, size_t len) +vi_reset(buf, len) + char *buf; + size_t len; { state = VNORMAL; ohnum = hnum = hlast = histnum(-1) + 1; @@ -565,7 +570,8 @@ vi_reset(char *buf, size_t len) } static int -nextstate(int ch) +nextstate(ch) + int ch; { if (is_extend(ch)) return VEXTCMD; @@ -584,7 +590,8 @@ nextstate(int ch) } static int -vi_insert(int ch) +vi_insert(ch) + int ch; { int tcursor; @@ -716,7 +723,9 @@ vi_insert(int ch) } static int -vi_cmd(int argcnt, const char *cmd) +vi_cmd(argcnt, cmd) + int argcnt; + const char *cmd; { int ncursor; int cur, c1, c2, c3 = 0; @@ -1167,7 +1176,10 @@ vi_cmd(int argcnt, const char *cmd) } static int -domove(int argcnt, const char *cmd, int sub) +domove(argcnt, cmd, sub) + int argcnt; + const char *cmd; + int sub; { int bcount, UNINITIALIZED(i), t; int UNINITIALIZED(ncursor); @@ -1314,7 +1326,8 @@ domove(int argcnt, const char *cmd, int sub) } static int -redo_insert(int count) +redo_insert(count) + int count; { while (count-- > 0) if (putbuf(ibuf, inslen, insert==REPLACE) != 0) @@ -1326,7 +1339,8 @@ redo_insert(int count) } static void -yank_range(int a, int b) +yank_range(a, b) + int a, b; { yanklen = b - a; if (yanklen != 0) @@ -1334,7 +1348,8 @@ yank_range(int a, int b) } static int -bracktype(int ch) +bracktype(ch) + int ch; { switch (ch) { @@ -1379,7 +1394,7 @@ static char holdbuf[CMDLEN]; /* place to hold last edit buffer */ static int holdlen; /* length of holdbuf */ static void -save_cbuf(void) +save_cbuf() { memmove(holdbuf, es->cbuf, es->linelen); holdlen = es->linelen; @@ -1387,7 +1402,7 @@ save_cbuf(void) } static void -restore_cbuf(void) +restore_cbuf() { es->cursor = 0; es->linelen = holdlen; @@ -1396,7 +1411,8 @@ restore_cbuf(void) /* return a new edstate */ static struct edstate * -save_edstate(struct edstate *old) +save_edstate(old) + struct edstate *old; { struct edstate *new; @@ -1411,7 +1427,8 @@ save_edstate(struct edstate *old) } static void -restore_edstate(struct edstate *new, struct edstate *old) +restore_edstate(new, old) + struct edstate *old, *new; { memcpy(new->cbuf, old->cbuf, old->linelen); new->linelen = old->linelen; @@ -1421,7 +1438,8 @@ restore_edstate(struct edstate *new, struct edstate *old) } static void -free_edstate(struct edstate *old) +free_edstate(old) + struct edstate *old; { afree(old->cbuf, APERM); afree((char *)old, APERM); @@ -1430,7 +1448,9 @@ free_edstate(struct edstate *old) static void -edit_reset(char *buf, size_t len) +edit_reset(buf, len) + char *buf; + size_t len; { const char *p; @@ -1470,13 +1490,18 @@ edit_reset(char *buf, size_t len) * this is used for calling x_escape() in complete_word() */ static int -x_vi_putbuf(const char *s, size_t len) +x_vi_putbuf(s, len) + const char *s; + size_t len; { return putbuf(s, len, 0); } static int -putbuf(const char *buf, int len, int repl) +putbuf(buf, len, repl) + const char *buf; + int len; + int repl; { if (len == 0) return 0; @@ -1498,7 +1523,8 @@ putbuf(const char *buf, int len, int repl) } static void -del_range(int a, int b) +del_range(a, b) + int a, b; { if (es->linelen != b) memmove(&es->cbuf[a], &es->cbuf[b], es->linelen - b); @@ -1506,7 +1532,11 @@ del_range(int a, int b) } static int -findch(int ch, int cnt, int forw, int incl) +findch(ch, cnt, forw, incl) + int ch; + int cnt; + int forw; + int incl; { int ncursor; @@ -1535,6 +1565,7 @@ findch(int ch, int cnt, int forw, int incl) static int forwword(argcnt) + int argcnt; { int ncursor; @@ -1556,7 +1587,8 @@ forwword(argcnt) } static int -backword(int argcnt) +backword(argcnt) + int argcnt; { int ncursor; @@ -1581,7 +1613,8 @@ backword(int argcnt) } static int -endword(int argcnt) +endword(argcnt) + int argcnt; { int ncursor; @@ -1607,7 +1640,8 @@ endword(int argcnt) } static int -Forwword(int argcnt) +Forwword(argcnt) + int argcnt; { int ncursor; @@ -1622,7 +1656,8 @@ Forwword(int argcnt) } static int -Backword(int argcnt) +Backword(argcnt) + int argcnt; { int ncursor; @@ -1638,7 +1673,8 @@ Backword(int argcnt) } static int -Endword(int argcnt) +Endword(argcnt) + int argcnt; { int ncursor; @@ -1658,7 +1694,9 @@ Endword(int argcnt) } static int -grabhist(int save, int n) +grabhist(save, n) + int save; + int n; { char *hptr; @@ -1685,7 +1723,9 @@ grabhist(int save, int n) } static int -grabsearch(int save, int start, int fwd, char *pat) +grabsearch(save, start, fwd, pat) + int save, start, fwd; + char *pat; { char *hptr; int hist; @@ -1719,7 +1759,8 @@ grabsearch(int save, int start, int fwd, char *pat) } static void -redraw_line(int newlinex) +redraw_line(newlinex) + int newlinex; { (void) memset(wbuf[win], ' ', wbuf_len); if (newlinex) { @@ -1732,7 +1773,8 @@ redraw_line(int newlinex) } static void -refresh(int leftside) +refresh(leftside) + int leftside; { if (leftside < 0) leftside = lastref; @@ -1745,7 +1787,7 @@ refresh(int leftside) } static int -outofwin(void) +outofwin() { int cur, col; @@ -1761,7 +1803,7 @@ outofwin(void) } static void -rewindow(void) +rewindow() { register int tcur, tcol; int holdcur1, holdcol1; @@ -1785,7 +1827,8 @@ rewindow(void) } static int -newcol(int ch, int col) +newcol(ch, col) + int ch, col; { if (ch == '\t') return (col | 7) + 1; @@ -1793,7 +1836,9 @@ newcol(int ch, int col) } static void -display(char *wb1, char *wb2, int leftside) +display(wb1, wb2, leftside) + char *wb1, *wb2; + int leftside; { unsigned char ch; char *twb1, *twb2, mc; @@ -1886,7 +1931,9 @@ display(char *wb1, char *wb2, int leftside) } static void -ed_mov_opt(int col, char *wb) +ed_mov_opt(col, wb) + int col; + char *wb; { if (col < cur_col) { if (col + 1 < cur_col - col) { @@ -1910,7 +1957,8 @@ ed_mov_opt(int col, char *wb) /* replace word with all expansions (ie, expand word*) */ static int -expand_word(int commandx) +expand_word(commandx) + int commandx; { static struct edstate *buf; int rval = 0; @@ -1964,7 +2012,9 @@ expand_word(int commandx) } static int -complete_word(int commandx, int count) +complete_word(commandx, count) + int commandx; + int count; { static struct edstate *buf; int rval = 0; @@ -2071,7 +2121,9 @@ complete_word(int commandx, int count) } static int -print_expansions(struct edstate *ex, int commandx) +print_expansions(ex, commandx) + struct edstate *ex; + int commandx; { int nwords; int start, end; @@ -2093,7 +2145,8 @@ print_expansions(struct edstate *ex, int commandx) /* How long is char when displayed (not counting tabs) */ static int -char_len(int c) +char_len(c) + int c; { int len = 1; @@ -2108,7 +2161,8 @@ char_len(int c) /* Similar to x_zotc(emacs.c), but no tab weirdness */ static void -x_vi_zotc(int c) +x_vi_zotc(c) + int c; { if (Flag(FVISHOW8) && (c & 0x80)) { x_puts("M-"); @@ -2122,13 +2176,14 @@ x_vi_zotc(int c) } static void -vi_pprompt(int full) +vi_pprompt(full) + int full; { pprompt(prompt + (full ? 0 : prompt_skip), prompt_trunc); } static void -vi_error(void) +vi_error() { /* Beem out of any macros as soon as an error occurs */ vi_macro_reset(); @@ -2137,7 +2192,7 @@ vi_error(void) } static void -vi_macro_reset(void) +vi_macro_reset() { if (macro.p) { afree(macro.buf, APERM); @@ -2146,4 +2201,3 @@ vi_macro_reset(void) } #endif /* VI */ -