Revert "Cleanup: ksh: convert all K&R-style funtion definitions to ANSI-style"

This reverts commit e47e5f1694.
This commit is contained in:
Santurysim 2021-06-23 11:11:23 +03:00
parent 61b7efb091
commit 0cb589cee4
45 changed files with 1456 additions and 652 deletions

View File

@ -18,7 +18,8 @@ __RCSID("$NetBSD: c_ksh.c,v 1.18 2011/10/16 17:12:11 joerg Exp $");
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
int int
c_cd(char **wp) c_cd(wp)
char **wp;
{ {
int optc; int optc;
int physical = Flag(FPHYSICAL); int physical = Flag(FPHYSICAL);
@ -185,7 +186,8 @@ c_cd(char **wp)
} }
int int
c_pwd(char **wp) c_pwd(wp)
char **wp;
{ {
int optc; int optc;
int physical = Flag(FPHYSICAL); int physical = Flag(FPHYSICAL);
@ -231,7 +233,8 @@ c_pwd(char **wp)
} }
int int
c_print(char **wp) c_print(wp)
char **wp;
{ {
#define PO_NL BIT(0) /* print newline */ #define PO_NL BIT(0) /* print newline */
#define PO_EXPAND BIT(1) /* expand backslash sequences */ #define PO_EXPAND BIT(1) /* expand backslash sequences */
@ -454,7 +457,8 @@ c_print(char **wp)
} }
int int
c_whence(char **wp) c_whence(wp)
char **wp;
{ {
struct tbl *tp; struct tbl *tp;
char *id; char *id;
@ -576,7 +580,8 @@ c_whence(char **wp)
/* Deal with command -vV - command -p dealt with in comexec() */ /* Deal with command -vV - command -p dealt with in comexec() */
int int
c_command(char **wp) c_command(wp)
char **wp;
{ {
/* Let c_whence do the work. Note that c_command() must be /* Let c_whence do the work. Note that c_command() must be
* a distinct function from c_whence() (tested in comexec()). * a distinct function from c_whence() (tested in comexec()).
@ -586,7 +591,8 @@ c_command(char **wp)
/* typeset, export, and readonly */ /* typeset, export, and readonly */
int int
c_typeset(char **wp) c_typeset(wp)
char **wp;
{ {
struct block *l = e->loc; struct block *l = e->loc;
struct tbl *vp, **p; struct tbl *vp, **p;
@ -882,7 +888,8 @@ c_typeset(char **wp)
} }
int int
c_alias(char **wp) c_alias(wp)
char **wp;
{ {
struct table *t = &aliases; struct table *t = &aliases;
int rv = 0, rflag = 0, tflag, Uflag = 0, pflag = 0; int rv = 0, rflag = 0, tflag, Uflag = 0, pflag = 0;
@ -1018,7 +1025,8 @@ c_alias(char **wp)
} }
int int
c_unalias(char **wp) c_unalias(wp)
char **wp;
{ {
register struct table *t = &aliases; register struct table *t = &aliases;
register struct tbl *ap; register struct tbl *ap;
@ -1071,7 +1079,8 @@ c_unalias(char **wp)
#ifdef KSH #ifdef KSH
int int
c_let(char **wp) c_let(wp)
char **wp;
{ {
int rv = 1; int rv = 1;
long val; long val;
@ -1090,7 +1099,8 @@ c_let(char **wp)
#endif /* KSH */ #endif /* KSH */
int int
c_jobs(char **wp) c_jobs(wp)
char **wp;
{ {
int optc; int optc;
int flag = 0; int flag = 0;
@ -1128,7 +1138,8 @@ c_jobs(char **wp)
#ifdef JOBS #ifdef JOBS
int int
c_fgbg(char **wp) c_fgbg(wp)
char **wp;
{ {
int bg = strcmp(*wp, "bg") == 0; int bg = strcmp(*wp, "bg") == 0;
int UNINITIALIZED(rv); 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 */ /* format a single kill item */
static char * 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; struct kill_info *ki = (struct kill_info *) arg;
@ -1180,7 +1195,8 @@ kill_fmt_entry(void *arg, int i, char *buf, int buflen)
int int
c_kill(char **wp) c_kill(wp)
char **wp;
{ {
Trap *t = (Trap *) 0; Trap *t = (Trap *) 0;
char *p; char *p;
@ -1291,7 +1307,8 @@ c_kill(char **wp)
} }
void void
getopts_reset(int val) getopts_reset(val)
int val;
{ {
if (val >= 1) { if (val >= 1) {
ksh_getopt_reset(&user_opt, ksh_getopt_reset(&user_opt,
@ -1301,7 +1318,8 @@ getopts_reset(int val)
} }
int int
c_getopts(char **wp) c_getopts(wp)
char **wp;
{ {
int argc; int argc;
const char *options; const char *options;
@ -1400,7 +1418,8 @@ c_getopts(char **wp)
#ifdef EMACS #ifdef EMACS
int int
c_bind(char **wp) c_bind(wp)
char **wp;
{ {
int rv = 0, macro = 0, list = 0; int rv = 0, macro = 0, list = 0;
register char *cp; register char *cp;
@ -1469,4 +1488,3 @@ const struct builtin kshbuiltins [] = {
#endif #endif
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -20,13 +20,15 @@ static char *clocktos ARGS((clock_t t));
/* :, false and true */ /* :, false and true */
int int
c_label(char **wp) c_label(wp)
char **wp;
{ {
return wp[0][0] == 'f' ? 1 : 0; return wp[0][0] == 'f' ? 1 : 0;
} }
int int
c_shift(char **wp) c_shift(wp)
char **wp;
{ {
register struct block *l = e->loc; register struct block *l = e->loc;
register int n; register int n;
@ -57,7 +59,8 @@ c_shift(char **wp)
} }
int int
c_umask(char **wp) c_umask(wp)
char **wp;
{ {
register int i; register int i;
register char *cp; register char *cp;
@ -176,7 +179,8 @@ c_umask(char **wp)
} }
int int
c_dot(char **wp) c_dot(wp)
char **wp;
{ {
char *file, *cp; char *file, *cp;
char **argv; char **argv;
@ -214,7 +218,8 @@ c_dot(char **wp)
} }
int int
c_wait(char **wp) c_wait(wp)
char **wp;
{ {
int UNINITIALIZED(rv); int UNINITIALIZED(rv);
int sig; int sig;
@ -236,7 +241,8 @@ c_wait(char **wp)
} }
int int
c_read(char **wp) c_read(wp)
char **wp;
{ {
register int c = 0; register int c = 0;
int expandv = 1, history = 0; int expandv = 1, history = 0;
@ -422,7 +428,8 @@ c_read(char **wp)
} }
int int
c_eval(char **wp) c_eval(wp)
char **wp;
{ {
register struct source *s; register struct source *s;
int rv; int rv;
@ -465,7 +472,8 @@ c_eval(char **wp)
} }
int int
c_trap(char **wp) c_trap(wp)
char **wp;
{ {
int i; int i;
char *s; char *s;
@ -526,7 +534,8 @@ c_trap(char **wp)
} }
int int
c_exitreturn(char **wp) c_exitreturn(wp)
char **wp;
{ {
int how = LEXIT; int how = LEXIT;
int n; int n;
@ -568,7 +577,8 @@ c_exitreturn(char **wp)
} }
int int
c_brkcont(char **wp) c_brkcont(wp)
char **wp;
{ {
int n, quit; int n, quit;
struct env *ep, *last_ep = (struct env *) 0; struct env *ep, *last_ep = (struct env *) 0;
@ -622,7 +632,8 @@ c_brkcont(char **wp)
} }
int int
c_set(char **wp) c_set(wp)
char **wp;
{ {
int argi, setargs; int argi, setargs;
struct block *l = e->loc; struct block *l = e->loc;
@ -657,7 +668,8 @@ c_set(char **wp)
} }
int int
c_unset(char **wp) c_unset(wp)
char **wp;
{ {
register char *id; register char *id;
int optc, unset_var = 1; int optc, unset_var = 1;
@ -694,7 +706,8 @@ c_unset(char **wp)
} }
int int
c_times(char **wp) c_times(wp)
char **wp;
{ {
struct tms all; struct tms all;
@ -711,7 +724,9 @@ c_times(char **wp)
* time pipeline (really a statement, not a built-in command) * time pipeline (really a statement, not a built-in command)
*/ */
int int
timex(struct op *t, int f) timex(t, f)
struct op *t;
int f;
{ {
#define TF_NOARGS BIT(0) #define TF_NOARGS BIT(0)
#define TF_NOREAL BIT(1) /* don't report real time */ #define TF_NOREAL BIT(1) /* don't report real time */
@ -766,7 +781,9 @@ timex(struct op *t, int f)
} }
void void
timex_hook(struct op *t, char ** volatile *app) timex_hook(t, app)
struct op *t;
char ** volatile *app;
{ {
char **wp = *app; char **wp = *app;
int optc; int optc;
@ -799,7 +816,8 @@ timex_hook(struct op *t, char ** volatile *app)
} }
static char * static char *
clocktos(clock_t t) clocktos(t)
clock_t t;
{ {
static char temp[22]; /* enough for 64 bit clock_t */ static char temp[22]; /* enough for 64 bit clock_t */
register int i; register int i;
@ -824,7 +842,8 @@ clocktos(clock_t t)
/* exec with no args - args case is taken care of in comexec() */ /* exec with no args - args case is taken care of in comexec() */
int int
c_exec(char **wp) c_exec(wp)
char ** wp;
{ {
int i; int i;
@ -851,7 +870,8 @@ c_exec(char **wp)
/* dummy function, special case in comexec() */ /* dummy function, special case in comexec() */
int int
c_builtin(char **wp) c_builtin(wp)
char ** wp;
{ {
return 0; return 0;
} }
@ -897,4 +917,3 @@ const struct builtin shbuiltins [] = {
#endif /* OS2 */ #endif /* OS2 */
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -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 *)); static void ptest_error ARGS((Test_env *, int, const char *));
int int
c_test(char **wp) c_test(wp)
char **wp;
{ {
int argc; int argc;
int res; int res;
@ -190,7 +191,10 @@ c_test(char **wp)
*/ */
Test_op 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; char sc1;
const struct t_op *otab; const struct t_op *otab;
@ -210,7 +214,12 @@ test_isop(Test_env *te, Test_meta meta, const char *s)
} }
int 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 res;
int not; 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 */ /* Nasty kludge to handle Korn's bizarre /dev/fd hack */
static int 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) #if !defined(HAVE_DEV_FD)
int fd; int fd;
@ -431,7 +442,9 @@ test_stat(const char *pathx, struct stat *statb)
* non-directories when running as root. * non-directories when running as root.
*/ */
static int static int
test_eaccess(const char *pathx, int mode) test_eaccess(pathx, mode)
const char *pathx;
int mode;
{ {
int res; int res;
@ -472,7 +485,8 @@ test_eaccess(const char *pathx, int mode)
} }
int int
test_parse(Test_env *te) test_parse(te)
Test_env *te;
{ {
int res; int res;
@ -485,7 +499,9 @@ test_parse(Test_env *te)
} }
static int static int
test_oexpr(Test_env *te, int do_eval) test_oexpr(te, do_eval)
Test_env *te;
int do_eval;
{ {
int res; int res;
@ -498,7 +514,9 @@ test_oexpr(Test_env *te, int do_eval)
} }
static int static int
test_aexpr(Test_env *te, int do_eval) test_aexpr(te, do_eval)
Test_env *te;
int do_eval;
{ {
int res; int res;
@ -511,7 +529,9 @@ test_aexpr(Test_env *te, int do_eval)
} }
static int 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)) if (!(te->flags & TEF_ERROR) && (*te->isa)(te, TM_NOT))
return !test_nexpr(te, do_eval); return !test_nexpr(te, do_eval);
@ -519,7 +539,9 @@ test_nexpr(Test_env *te, int do_eval)
} }
static int 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; const char *opnd1, *opnd2;
int res; 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). * TM_UNOP and TM_BINOP, the returned value is a Test_op).
*/ */
static int 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 */ /* Order important - indexed by Test_meta values */
static const char *const tokens[] = { static const char *const tokens[] = {
@ -604,7 +628,10 @@ ptest_isa(Test_env *te, Test_meta meta)
} }
static const char * 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) if (te->pos.wp >= te->wp_end)
return op == TO_FILTT ? "1" : (const char *) 0; 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 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); return test_eval(te, op, opnd1, opnd2, do_eval);
} }
static void 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 *op = te->pos.wp + offset >= te->wp_end ?
(const char *) 0 : te->pos.wp[offset]; (const char *) 0 : te->pos.wp[offset];
@ -629,4 +664,3 @@ ptest_error(Test_env *te, int offset, const char *msg)
else else
bi_errorf("%s", msg); bi_errorf("%s", msg);
} }

View File

@ -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, int test_eval ARGS((Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval)); const char *opnd2, int do_eval));
int test_parse ARGS((Test_env *te)); int test_parse ARGS((Test_env *te));

View File

@ -47,7 +47,8 @@ extern long ulimit();
#endif /* RLIM_INFINITY */ #endif /* RLIM_INFINITY */
int int
c_ulimit(char **wp) c_ulimit(wp)
char **wp;
{ {
static const struct limits { static const struct limits {
const char *name; const char *name;
@ -289,4 +290,3 @@ c_ulimit(char **wp)
} }
return 0; return 0;
} }

View File

@ -55,4 +55,3 @@
# define GCC_FUNC_ATTR(x) # define GCC_FUNC_ATTR(x)
# define GCC_FUNC_ATTR2(x,y) # define GCC_FUNC_ATTR2(x,y)
#endif /* HAVE_GCC_FUNC_ATTR */ #endif /* HAVE_GCC_FUNC_ATTR */

View File

@ -87,7 +87,8 @@ x_init()
#if defined(TIOCGWINSZ) #if defined(TIOCGWINSZ)
static RETSIGTYPE static RETSIGTYPE
x_sigwinch(int sig) x_sigwinch(sig)
int sig;
{ {
got_sigwinch = 1; got_sigwinch = 1;
return RETSIGVAL; return RETSIGVAL;
@ -128,7 +129,9 @@ check_sigwinch ARGS((void))
* read an edited command line * read an edited command line
*/ */
int int
x_read(char *buf, size_t len) x_read(buf, len)
char *buf;
size_t len;
{ {
int i; int i;
@ -178,26 +181,29 @@ x_getc()
} }
void void
x_flush(void) x_flush()
{ {
shf_flush(shl_out); shf_flush(shl_out);
} }
void void
x_putc(int c) x_putc(c)
int c;
{ {
shf_putc(c, shl_out); shf_putc(c, shl_out);
} }
void void
x_puts(const char *s) x_puts(s)
const char *s;
{ {
while (*s != 0) while (*s != 0)
shf_putc(*s++, shl_out); shf_putc(*s++, shl_out);
} }
bool_t bool_t
x_mode(bool_t onoff) x_mode(onoff)
bool_t onoff;
{ {
static bool_t x_cur_mode; static bool_t x_cur_mode;
bool_t prev; bool_t prev;
@ -330,7 +336,9 @@ x_mode(bool_t onoff)
* length * length
*/ */
int int
promptlen(const char *cp, const char **spp) promptlen(cp, spp)
const char *cp;
const char **spp;
{ {
int count = 0; int count = 0;
const char *sp = cp; const char *sp = cp;
@ -370,7 +378,8 @@ promptlen(const char *cp, const char **spp)
} }
void void
set_editmode(const char *ed) set_editmode(ed)
const char *ed;
{ {
static const enum sh_flag edit_flags[] = { static const enum sh_flag edit_flags[] = {
#ifdef EMACS #ifdef EMACS
@ -404,7 +413,10 @@ set_editmode(const char *ed)
* moved to the start of the line after (un)commenting. * moved to the start of the line after (un)commenting.
*/ */
int 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 i, j;
int len = *lenp; int len = *lenp;
@ -482,7 +494,10 @@ x_complete_word(str, slen, is_command, nwordsp, ret)
#endif /* 0 */ #endif /* 0 */
void 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 use_copy = 0;
int prefix_len; int prefix_len;
@ -538,7 +553,11 @@ x_print_expansions(int nwords, char *const *words, int is_command)
* - returns number of matching strings * - returns number of matching strings
*/ */
static int 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 *toglob;
char **words; char **words;
@ -626,7 +645,9 @@ static int path_order_cmp(const void *aa, const void *bb);
/* Compare routine used in x_command_glob() */ /* Compare routine used in x_command_glob() */
static int 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 *a = (const struct path_order_info *) aa;
const struct path_order_info *b = (const struct path_order_info *) bb; 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 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 *toglob;
char *pat; char *pat;
@ -731,8 +756,12 @@ x_command_glob(int flags, const char *str, int slen, char ***wordsp)
|| (c) == '`' || (c) == '=' || (c) == ':' ) || (c) == '`' || (c) == '=' || (c) == ':' )
static int static int
x_locate_word(const char *buf, int buflen, int pos, int *startp, x_locate_word(buf, buflen, pos, startp, is_commandp)
int *is_commandp) const char *buf;
int buflen;
int pos;
int *startp;
int *is_commandp;
{ {
int p; int p;
int start, end; int start, end;
@ -784,8 +813,15 @@ x_locate_word(const char *buf, int buflen, int pos, int *startp,
} }
int int
x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp, x_cf_glob(flags, buf, buflen, pos, startp, endp, wordsp, is_commandp)
int *endp, char ***wordsp, int *is_commandp) int flags;
const char *buf;
int buflen;
int pos;
int *startp;
int *endp;
char ***wordsp;
int *is_commandp;
{ {
int len; int len;
int nwords; int nwords;
@ -821,7 +857,9 @@ x_cf_glob(int flags, const char *buf, int buflen, int pos, int *startp,
* new string is returned. * new string is returned.
*/ */
static char * static char *
add_glob(const char *str, int slen) add_glob(str, slen)
const char *str;
int slen;
{ {
char *toglob; char *toglob;
char *s; char *s;
@ -860,7 +898,9 @@ add_glob(const char *str, int slen)
* Find longest common prefix * Find longest common prefix
*/ */
int int
x_longest_prefix(int nwords, char *const *words) x_longest_prefix(nwords, words)
int nwords;
char *const *words;
{ {
int i, j; int i, j;
int prefix_len; int prefix_len;
@ -881,7 +921,9 @@ x_longest_prefix(int nwords, char *const *words)
} }
void void
x_free_words(int nwords, char **words) x_free_words(nwords, words)
int nwords;
char **words;
{ {
int i; int i;
@ -904,7 +946,9 @@ x_free_words(int nwords, char **words)
* 0 * 0
*/ */
int int
x_basename(const char *s, const char *se) x_basename(s, se)
const char *s;
const char *se;
{ {
const char *p; const char *p;
@ -929,7 +973,10 @@ x_basename(const char *s, const char *se)
* are added to wp. * are added to wp.
*/ */
static void 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 tstate ts;
struct tbl *te; struct tbl *te;
@ -941,7 +988,11 @@ glob_table(const char *pat, XPtrV *wp, struct table *tp)
} }
static void 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; const char *sp, *p;
char *xp; char *xp;
@ -1011,7 +1062,10 @@ glob_path(int flags, const char *pat, XPtrV *wp, const char *xpath)
* keybinding-specific function * keybinding-specific function
*/ */
int 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; size_t add, wlen;
const char *ifs = str_val(local("IFS", 0)); 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); return (rval);
} }
#endif /* EDIT */ #endif /* EDIT */

View File

@ -85,4 +85,3 @@ int x_vi ARGS((char *buf, size_t len));
* comment-column:40 * comment-column:40
* End: * End:
*/ */

View File

@ -414,7 +414,8 @@ x_emacs(buf, len)
} }
static int static int
x_insert(int c) x_insert(c)
int c;
{ {
char str[2]; char str[2];
@ -433,7 +434,8 @@ x_insert(int c)
} }
static int static int
x_ins_string(int c) x_ins_string(c)
int c;
{ {
if (macroptr) { if (macroptr) {
x_e_putc(BEL); 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);
static int static int
x_do_ins(const char *cp, int len) x_do_ins(cp, len)
const char *cp;
int len;
{ {
if (xep+len >= xend) { if (xep+len >= xend) {
x_e_putc(BEL); x_e_putc(BEL);
@ -465,7 +469,8 @@ x_do_ins(const char *cp, int len)
} }
static int static int
x_ins(char *s) x_ins(s)
char *s;
{ {
char *cp = xcp; char *cp = xcp;
register int adj = x_adj_done; register int adj = x_adj_done;
@ -495,7 +500,9 @@ x_ins(char *s)
* this is used for x_escape() in do_complete() * this is used for x_escape() in do_complete()
*/ */
static int static int
x_emacs_putbuf(const char *s, size_t len) x_emacs_putbuf(s, len)
const char *s;
size_t len;
{ {
int rval; int rval;
@ -505,7 +512,8 @@ x_emacs_putbuf(const char *s, size_t len)
} }
static int static int
x_del_back(int c) x_del_back(c)
int c;
{ {
int col = xcp - xbuf; int col = xcp - xbuf;
@ -521,7 +529,8 @@ x_del_back(int c)
} }
static int static int
x_del_char(int c) x_del_char(c)
int c;
{ {
int nleft = xep - xcp; 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) */ /* Delete nc chars to the right of the cursor (including cursor position) */
static void static void
x_delete(int nc, int push) x_delete(nc, push)
int nc;
int push;
{ {
int i,j; int i,j;
char *cp; char *cp;
@ -592,35 +603,39 @@ x_delete(int nc, int push)
} }
static int static int
x_del_bword(int c) x_del_bword(c)
int c;
{ {
x_delete(x_bword(), TRUE); x_delete(x_bword(), TRUE);
return KSTD; return KSTD;
} }
static int static int
x_mv_bword(int c) x_mv_bword(c)
int c;
{ {
(void)x_bword(); (void)x_bword();
return KSTD; return KSTD;
} }
static int static int
x_mv_fword(int c) x_mv_fword(c)
int c;
{ {
x_goto(xcp + x_fword()); x_goto(xcp + x_fword());
return KSTD; return KSTD;
} }
static int static int
x_del_fword(int c) x_del_fword(c)
int c;
{ {
x_delete(x_fword(), TRUE); x_delete(x_fword(), TRUE);
return KSTD; return KSTD;
} }
static int static int
x_bword(void) x_bword()
{ {
int nc = 0; int nc = 0;
register char *cp = xcp; register char *cp = xcp;
@ -647,7 +662,7 @@ x_bword(void)
} }
static int static int
x_fword(void) x_fword()
{ {
int nc = 0; int nc = 0;
register char *cp = xcp; register char *cp = xcp;
@ -673,7 +688,8 @@ x_fword(void)
} }
static void static void
x_goto(register char *cp) x_goto(cp)
register char *cp;
{ {
if (cp < xbp || cp >= (xbp + x_displen)) if (cp < xbp || cp >= (xbp + x_displen))
{ {
@ -700,7 +716,8 @@ x_goto(register char *cp)
} }
static void static void
x_bs(int c) x_bs(c)
int c;
{ {
register int i; register int i;
i = x_size(c); i = x_size(c);
@ -709,7 +726,8 @@ x_bs(int c)
} }
static int static int
x_size_str(register char *cp) x_size_str(cp)
register char *cp;
{ {
register int size = 0; register int size = 0;
while (*cp) while (*cp)
@ -718,7 +736,8 @@ x_size_str(register char *cp)
} }
static int static int
x_size(int c) x_size(c)
int c;
{ {
if (c=='\t') if (c=='\t')
return 4; /* Kludge, tabs are always four spaces. */ return 4; /* Kludge, tabs are always four spaces. */
@ -728,7 +747,8 @@ x_size(int c)
} }
static void static void
x_zots(register char *str) x_zots(str)
register char *str;
{ {
register int adj = x_adj_done; register int adj = x_adj_done;
@ -738,7 +758,8 @@ x_zots(register char *str)
} }
static void static void
x_zotc(int c) x_zotc(c)
int c;
{ {
if (c == '\t') { if (c == '\t') {
/* Kludge, tabs are always four spaces. */ /* Kludge, tabs are always four spaces. */
@ -751,7 +772,8 @@ x_zotc(int c)
} }
static int static int
x_mv_back(int c) x_mv_back(c)
int c;
{ {
int col = xcp - xbuf; int col = xcp - xbuf;
@ -766,7 +788,8 @@ x_mv_back(int c)
} }
static int static int
x_mv_forw(int c) x_mv_forw(c)
int c;
{ {
int nleft = xep - xcp; int nleft = xep - xcp;
@ -781,7 +804,8 @@ x_mv_forw(int c)
} }
static int static int
x_search_char_forw(int c) x_search_char_forw(c)
int c;
{ {
char *cp = xcp; char *cp = xcp;
@ -801,7 +825,8 @@ x_search_char_forw(int c)
} }
static int static int
x_search_char_back(int c) x_search_char_back(c)
int c;
{ {
char *cp = xcp, *p; char *cp = xcp, *p;
@ -822,7 +847,8 @@ x_search_char_back(int c)
} }
static int static int
x_newline(int c) x_newline(c)
int c;
{ {
x_e_putc('\r'); x_e_putc('\r');
x_e_putc('\n'); x_e_putc('\n');
@ -832,7 +858,8 @@ x_newline(int c)
} }
static int static int
x_end_of_text(int c) x_end_of_text(c)
int c;
{ {
return KEOL; 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. * want so we'll simply go to the oldest one.
*/ */
static int static int
x_goto_hist(int c) x_goto_hist(c)
int c;
{ {
if (x_arg_defaulted) if (x_arg_defaulted)
x_load_hist(histlist); x_load_hist(histlist);
@ -860,7 +888,8 @@ x_goto_hist(int c)
} }
static void static void
x_load_hist(register char **hp) x_load_hist(hp)
register char **hp;
{ {
int oldsize; int oldsize;
@ -881,14 +910,16 @@ x_load_hist(register char **hp)
} }
static int static int
x_nl_next_com(int c) x_nl_next_com(c)
int c;
{ {
x_nextcmd = source->line - (histptr - x_histp) + 1; x_nextcmd = source->line - (histptr - x_histp) + 1;
return (x_newline(c)); return (x_newline(c));
} }
static int static int
x_eot_del(int c) x_eot_del(c)
int c;
{ {
if (xep == xbuf && x_arg_defaulted) if (xep == xbuf && x_arg_defaulted)
return (x_end_of_text(c)); return (x_end_of_text(c));
@ -898,7 +929,8 @@ x_eot_del(int c)
/* reverse incremental history search */ /* reverse incremental history search */
static int static int
x_search_hist(int c) x_search_hist(c)
int c;
{ {
int offset = -1; /* offset of match in xbuf, else -1 */ int offset = -1; /* offset of match in xbuf, else -1 */
char pat [256+1]; /* pattern buffer */ char pat [256+1]; /* pattern buffer */
@ -960,7 +992,10 @@ x_search_hist(int c)
/* search backward from current line */ /* search backward from current line */
static int static int
x_search(char *pat, int sameline, int offset) x_search(pat, sameline, offset)
char *pat;
int sameline;
int offset;
{ {
register char **hp; register char **hp;
int i; 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 */ /* return position of first match of pattern in string, else -1 */
static int static int
x_match(char *str, char *pat) x_match(str, pat)
char *str, *pat;
{ {
if (*pat == '^') { if (*pat == '^') {
return (strncmp(str, pat+1, strlen(pat+1)) == 0) ? 0 : -1; return (strncmp(str, pat+1, strlen(pat+1)) == 0) ? 0 : -1;
@ -993,7 +1029,8 @@ x_match(char *str, char *pat)
} }
static int static int
x_del_line(int c) x_del_line(c)
int c;
{ {
int i, j; int i, j;
@ -1011,21 +1048,24 @@ x_del_line(int c)
} }
static int static int
x_mv_end(int c) x_mv_end(c)
int c;
{ {
x_goto(xep); x_goto(xep);
return KSTD; return KSTD;
} }
static int static int
x_mv_begin(int c) x_mv_begin(c)
int c;
{ {
x_goto(xbuf); x_goto(xbuf);
return KSTD; return KSTD;
} }
static int static int
x_draw_line(int c) x_draw_line(c)
int c;
{ {
x_redraw(-1); x_redraw(-1);
return KSTD; return KSTD;
@ -1037,7 +1077,8 @@ x_draw_line(int c)
* redrawing. * redrawing.
*/ */
static void static void
x_redraw(int limit) x_redraw(limit)
int limit;
{ {
int i, j; int i, j;
char *cp; char *cp;
@ -1092,7 +1133,8 @@ x_redraw(int limit)
} }
static int static int
x_transpose(int c) x_transpose(c)
int c;
{ {
char tmp; char tmp;
@ -1144,21 +1186,24 @@ x_transpose(int c)
} }
static int static int
x_literal(int c) x_literal(c)
int c;
{ {
x_curprefix = -1; x_curprefix = -1;
return KSTD; return KSTD;
} }
static int static int
x_meta1(int c) x_meta1(c)
int c;
{ {
x_curprefix = 1; x_curprefix = 1;
return KSTD; return KSTD;
} }
static int static int
x_meta2(int c) x_meta2(c)
int c;
{ {
x_curprefix = 2; x_curprefix = 2;
return KSTD; return KSTD;
@ -1166,7 +1211,8 @@ x_meta2(int c)
#ifdef OS2 #ifdef OS2
static int static int
x_meta3(int c) x_meta3(c)
int c;
{ {
x_curprefix = 3; x_curprefix = 3;
return KSTD; return KSTD;
@ -1174,7 +1220,8 @@ x_meta3(int c)
#endif /* OS2 */ #endif /* OS2 */
static int static int
x_kill(int c) x_kill(c)
int c;
{ {
int col = xcp - xbuf; int col = xcp - xbuf;
int lastcol = xep - xbuf; int lastcol = xep - xbuf;
@ -1194,7 +1241,8 @@ x_kill(int c)
} }
static void static void
x_push(int nchars) x_push(nchars)
int nchars;
{ {
char *cp = str_nsave(xcp, nchars, AEDIT); char *cp = str_nsave(xcp, nchars, AEDIT);
if (killstack[killsp]) if (killstack[killsp])
@ -1204,7 +1252,8 @@ x_push(int nchars)
} }
static int static int
x_yank(int c) x_yank(c)
int c;
{ {
if (killsp == 0) if (killsp == 0)
killtp = KILLSIZE; killtp = KILLSIZE;
@ -1222,7 +1271,8 @@ x_yank(int c)
} }
static int static int
x_meta_yank(int c) x_meta_yank(c)
int c;
{ {
int len; int len;
if ((x_last_command != XFUNC_yank && x_last_command != XFUNC_meta_yank) if ((x_last_command != XFUNC_yank && x_last_command != XFUNC_meta_yank)
@ -1246,7 +1296,8 @@ x_meta_yank(int c)
} }
static int static int
x_abort(int c) x_abort(c)
int c;
{ {
/* x_zotc(c); */ /* x_zotc(c); */
xlp = xep = xcp = xbp = xbuf; xlp = xep = xcp = xbp = xbuf;
@ -1256,14 +1307,16 @@ x_abort(int c)
} }
static int static int
x_error(int c) x_error(c)
int c;
{ {
x_e_putc(BEL); x_e_putc(BEL);
return KSTD; return KSTD;
} }
static int static int
x_stuffreset(int c) x_stuffreset(c)
int c;
{ {
#ifdef TIOCSTI #ifdef TIOCSTI
(void)x_stuff(c); (void)x_stuff(c);
@ -1279,7 +1332,8 @@ x_stuffreset(int c)
} }
static int static int
x_stuff(int c) x_stuff(c)
int c;
{ {
#if 0 || defined TIOCSTI #if 0 || defined TIOCSTI
char ch = c; char ch = c;
@ -1293,7 +1347,9 @@ x_stuff(int c)
} }
static char * static char *
x_mapin(const char *cp, Area *area) x_mapin(cp, area)
const char *cp;
Area *area;
{ {
char *new, *op; char *new, *op;
@ -1323,7 +1379,8 @@ x_mapin(const char *cp, Area *area)
} }
static char * static char *
x_mapout(int c) x_mapout(c)
int c;
{ {
static char buf[8]; static char buf[8];
register char *p = buf; register char *p = buf;
@ -1344,7 +1401,8 @@ x_mapout(int c)
} }
static void static void
x_print(int prefix, int key) x_print(prefix, key)
int prefix, key;
{ {
if (prefix == 1) if (prefix == 1)
shprintf("%s", x_mapout(x_prefix1)); shprintf("%s", x_mapout(x_prefix1));
@ -1361,10 +1419,11 @@ x_print(int prefix, int key)
shprintf("'%s'\n", x_atab[prefix][key]); shprintf("'%s'\n", x_atab[prefix][key]);
} }
/* macro for bind -m */
/* list for bind -l */
int 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; Findex f;
int prefix, key; int prefix, key;
@ -1458,7 +1517,7 @@ x_bind(const char *a1, const char *a2, int macro, int list)
} }
void void
x_init_emacs(void) x_init_emacs()
{ {
size_t i; size_t i;
register int j; 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);
static void 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 */ /* Has user already bound this key? If so, don't override it */
if (x_bound[((p) * X_TABSZ + (k)) / 8] if (x_bound[((p) * X_TABSZ + (k)) / 8]
@ -1505,7 +1566,8 @@ bind_if_not_bound(int p, int k, int func)
} }
void void
x_emacs_keys(X_chars *ec) x_emacs_keys(ec)
X_chars *ec;
{ {
if (ec->erase >= 0) { if (ec->erase >= 0) {
bind_if_not_bound(0, ec->erase, XFUNC_del_back); bind_if_not_bound(0, ec->erase, XFUNC_del_back);
@ -1522,14 +1584,16 @@ x_emacs_keys(X_chars *ec)
} }
static int static int
x_set_mark(int c) x_set_mark(c)
int c;
{ {
xmp = xcp; xmp = xcp;
return KSTD; return KSTD;
} }
static int static int
x_kill_region(int c) x_kill_region(c)
int c;
{ {
int rsize; int rsize;
char *xr; char *xr;
@ -1552,7 +1616,8 @@ x_kill_region(int c)
} }
static int static int
x_xchg_point_mark(int c) x_xchg_point_mark(c)
int c;
{ {
char *tmp; char *tmp;
@ -1567,7 +1632,8 @@ x_xchg_point_mark(int c)
} }
static int static int
x_version(int c) x_version(c)
int c;
{ {
char *o_xbuf = xbuf, *o_xend = xend; char *o_xbuf = xbuf, *o_xend = xend;
char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp; char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
@ -1596,14 +1662,16 @@ x_version(int c)
} }
static int static int
x_noop(int c) x_noop(c)
int c;
{ {
return KSTD; return KSTD;
} }
#ifdef SILLY #ifdef SILLY
static int static int
x_game_of_life(int c) x_game_of_life(c)
int c;
{ {
char newbuf [256+1]; char newbuf [256+1];
register char *ip, *op; register char *ip, *op;
@ -1659,49 +1727,57 @@ x_game_of_life(int c)
static int static int
x_comp_comm(int c) x_comp_comm(c)
int c;
{ {
do_complete(XCF_COMMAND, CT_COMPLETE); do_complete(XCF_COMMAND, CT_COMPLETE);
return KSTD; return KSTD;
} }
static int static int
x_list_comm(int c) x_list_comm(c)
int c;
{ {
do_complete(XCF_COMMAND, CT_LIST); do_complete(XCF_COMMAND, CT_LIST);
return KSTD; return KSTD;
} }
static int static int
x_complete(int c) x_complete(c)
int c;
{ {
do_complete(XCF_COMMAND_FILE, CT_COMPLETE); do_complete(XCF_COMMAND_FILE, CT_COMPLETE);
return KSTD; return KSTD;
} }
static int static int
x_enumerate(int c) x_enumerate(c)
int c;
{ {
do_complete(XCF_COMMAND_FILE, CT_LIST); do_complete(XCF_COMMAND_FILE, CT_LIST);
return KSTD; return KSTD;
} }
static int static int
x_comp_file(int c) x_comp_file(c)
int c;
{ {
do_complete(XCF_FILE, CT_COMPLETE); do_complete(XCF_FILE, CT_COMPLETE);
return KSTD; return KSTD;
} }
static int static int
x_list_file(int c) x_list_file(c)
int c;
{ {
do_complete(XCF_FILE, CT_LIST); do_complete(XCF_FILE, CT_LIST);
return KSTD; return KSTD;
} }
static int static int
x_comp_list(int c) x_comp_list(c)
int c;
{ {
do_complete(XCF_COMMAND_FILE, CT_COMPLIST); do_complete(XCF_COMMAND_FILE, CT_COMPLIST);
return KSTD; return KSTD;
} }
static int static int
x_expand(int c) x_expand(c)
int c;
{ {
char **words; char **words;
int nwords = 0; int nwords = 0;
@ -1734,9 +1810,10 @@ x_expand(int c)
} }
/* type == 0 for list, 1 for complete and 2 for complete-list */ /* type == 0 for list, 1 for complete and 2 for complete-list */
/* flags == XCF_{COMMAND,FILE,COMMAND_FILE}*/
static void 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; char **words;
int nwords; int nwords;
@ -1801,7 +1878,7 @@ do_complete(int flags, Comp_type type)
*/ */
static void static void
x_adjust(void) x_adjust()
{ {
x_adj_done++; /* flag the fact that we were called. */ x_adj_done++; /* flag the fact that we were called. */
/* /*
@ -1817,13 +1894,14 @@ x_adjust(void)
static int unget_char = -1; static int unget_char = -1;
static void static void
x_e_ungetc(int c) x_e_ungetc(c)
int c;
{ {
unget_char = c; unget_char = c;
} }
static int static int
x_e_getc(void) x_e_getc()
{ {
int c; int c;
@ -1843,7 +1921,8 @@ x_e_getc(void)
} }
static void static void
x_e_putc(int c) x_e_putc(c)
int c;
{ {
if (c == '\r' || c == '\n') if (c == '\r' || c == '\n')
x_col = 0; x_col = 0;
@ -1873,7 +1952,8 @@ x_e_putc(int c)
#ifdef DEBUG #ifdef DEBUG
static int static int
x_debug_info(int c) x_debug_info(c)
int c;
{ {
x_flush(); x_flush();
shellf("\nksh debug:\n"); shellf("\nksh debug:\n");
@ -1890,7 +1970,8 @@ x_debug_info(int c)
#endif #endif
static void static void
x_e_puts(const char *s) x_e_puts(s)
const char *s;
{ {
register int adj = x_adj_done; register int adj = x_adj_done;
@ -1909,7 +1990,8 @@ x_e_puts(const char *s)
*/ */
static int static int
x_set_arg(int c) x_set_arg(c)
int c;
{ {
int n = 0; int n = 0;
int first = 1; int first = 1;
@ -1932,7 +2014,8 @@ x_set_arg(int c)
/* Comment or uncomment the current line. */ /* Comment or uncomment the current line. */
static int static int
x_comment(int c) x_comment(c)
int c;
{ {
int oldsize = x_size_str(xbuf); int oldsize = x_size_str(xbuf);
int len = xep - xbuf; int len = xep - xbuf;
@ -1968,7 +2051,8 @@ x_comment(int c)
*/ */
static int static int
x_prev_histword(int c) x_prev_histword(c)
int c;
{ {
register char *rcp; register char *rcp;
char *cp; char *cp;
@ -2017,21 +2101,24 @@ x_prev_histword(int c)
/* Uppercase N(1) words */ /* Uppercase N(1) words */
static int static int
x_fold_upper(int c) x_fold_upper(c)
int c;
{ {
return x_fold_case('U'); return x_fold_case('U');
} }
/* Lowercase N(1) words */ /* Lowercase N(1) words */
static int static int
x_fold_lower(int c) x_fold_lower(c)
int c;
{ {
return x_fold_case('L'); return x_fold_case('L');
} }
/* Lowercase N(1) words */ /* Lowercase N(1) words */
static int static int
x_fold_capitalize(int c) x_fold_capitalize(c)
int c;
{ {
return x_fold_case('C'); return x_fold_case('C');
} }
@ -2048,7 +2135,8 @@ x_fold_capitalize(int c)
*/ */
static int static int
x_fold_case(int c) x_fold_case(c)
int c;
{ {
char *cp = xcp; char *cp = xcp;
@ -2115,7 +2203,7 @@ x_fold_case(int c)
*/ */
static char * static char *
x_lastcp(void) x_lastcp()
{ {
register char *rcp; register char *rcp;
register int i; register int i;
@ -2131,4 +2219,3 @@ x_lastcp(void)
} }
#endif /* EDIT */ #endif /* EDIT */

View File

@ -64,7 +64,9 @@ static void alt_expand ARGS((XPtrV *wp, char *start, char *exp_start,
/* compile and expand word */ /* compile and expand word */
char * char *
substitute(const char *cp, int f) substitute(cp, f)
const char *cp;
int f;
{ {
struct source *s, *sold; struct source *s, *sold;
@ -83,7 +85,9 @@ substitute(const char *cp, int f)
* expand arg-list * expand arg-list
*/ */
char ** char **
eval(register char **ap, int f) eval(ap, f)
register char **ap;
int f;
{ {
XPtrV w; XPtrV w;
@ -108,7 +112,9 @@ eval(register char **ap, int f)
* expand string * expand string
*/ */
char * char *
evalstr(char *cp, int f) evalstr(cp, f)
char *cp;
int f;
{ {
XPtrV w; XPtrV w;
@ -124,7 +130,9 @@ evalstr(char *cp, int f)
* used from iosetup to expand redirection files * used from iosetup to expand redirection files
*/ */
char * char *
evalonestr(register char *cp, int f) evalonestr(cp, f)
register char *cp;
int f;
{ {
XPtrV w; XPtrV w;
@ -156,12 +164,11 @@ typedef struct SubType {
struct SubType *next; /* poped type (to avoid re-allocating) */ struct SubType *next; /* poped type (to avoid re-allocating) */
} SubType; } SubType;
/* cp - input word
* wp - output words
* f - DO* flags
*/
void 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 UNINITIALIZED(c);
register int type; /* expansion type */ register int type; /* expansion type */
@ -675,7 +682,7 @@ expand(char *cp, register XPtrV *wp, int f)
quote &= ~2; /* undo temporary */ quote &= ~2; /* undo temporary */
if (make_magic) { if (make_magic) {
make_magic = 0; make_magic = 0;
fdo |= DOMAGIC_ | (f & DOGLOB); fdo |= DOMAGIC_ | (f & DOGLOB);
*dp++ = MAGIC; *dp++ = MAGIC;
} else if (ISMAGIC(c)) { } else if (ISMAGIC(c)) {
@ -690,11 +697,14 @@ expand(char *cp, register XPtrV *wp, int f)
/* /*
* Prepare to generate the string returned by ${} substitution. * Prepare to generate the string returned by ${} substitution.
* stypep: becomes qualifier type
* slenp: " " len (=, :=, etc) valid iff *stypep != 0
*/ */
static int 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 c;
int state; /* next state: XBASE, XARG, XSUB, XNULLSUB */ 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. * Run the command in $(...) and read its output.
*/ */
static int static int
comsub(register Expand *xp, char *cp) comsub(xp, cp)
register Expand *xp;
char *cp;
{ {
Source *s, *sold; Source *s, *sold;
register struct op *t; register struct op *t;
@ -893,7 +905,10 @@ comsub(register Expand *xp, char *cp)
*/ */
static char * 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 *end = strchr(str, 0);
register char *p, c; 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... */ /* XXX cp not const 'cause slashes are temporarily replaced with nulls... */
static void 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); int oldsize = XPsize(*wp);
@ -963,7 +981,10 @@ glob(char *cp, register XPtrV *wp, int markdirs)
* the number of matches found. * the number of matches found.
*/ */
int int
glob_str(char *cp, XPtrV *wp, int markdirs) glob_str(cp, wp, markdirs)
char *cp;
XPtrV *wp;
int markdirs;
{ {
int oldsize = XPsize(*wp); int oldsize = XPsize(*wp);
XString xs; XString xs;
@ -976,15 +997,13 @@ glob_str(char *cp, XPtrV *wp, int markdirs)
return XPsize(*wp) - oldsize; return XPsize(*wp) - oldsize;
} }
/*
* xs - dest string
* xpp - prt to dest end
* sp - source path
* wp - output list
* check - GF_* paths
*/
static void 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 */ register char *np; /* next source component */
char *xp = *xpp; char *xp = *xpp;
@ -1168,7 +1187,10 @@ copy_non_glob(xs, xpp, p)
/* remove MAGIC from string */ /* remove MAGIC from string */
char * 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; char *d, *s;
@ -1198,7 +1220,11 @@ debunk(char *dp, const char *sp, size_t dlen)
* past the name, otherwise returns 0. * past the name, otherwise returns 0.
*/ */
static char * 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; XString ts;
char *dp = *dpp; char *dp = *dpp;
@ -1236,7 +1262,8 @@ maybe_expand_tilde(char *p, XString *dsp, char **dpp, int isassign)
*/ */
static char * static char *
tilde(char *cp) tilde(cp)
char *cp;
{ {
char *dp; char *dp;
@ -1262,7 +1289,8 @@ tilde(char *cp)
*/ */
static char * static char *
homedir(char *name) homedir(name)
char *name;
{ {
register struct tbl *ap; register struct tbl *ap;
@ -1294,7 +1322,11 @@ homedir(char *name)
#ifdef BRACE_EXPAND #ifdef BRACE_EXPAND
static void 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); int UNINITIALIZED(count);
char *brace_start, *brace_end, *UNINITIALIZED(comma); 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; return;
} }
#endif /* BRACE_EXPAND */ #endif /* BRACE_EXPAND */

View File

@ -58,7 +58,8 @@ static char clexec_tab[MAXFD+1];
* we now use this function always. * we now use this function always.
*/ */
int int
fd_clexec(int fd) fd_clexec(fd)
int fd;
{ {
#ifndef F_SETFD #ifndef F_SETFD
if (fd >= 0 && fd < sizeof(clexec_tab)) { if (fd >= 0 && fd < sizeof(clexec_tab)) {
@ -76,7 +77,9 @@ fd_clexec(int fd)
* execute command tree * execute command tree
*/ */
int 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; int i;
volatile int rv = 0; volatile int rv = 0;
@ -447,7 +450,11 @@ execute(struct op * volatile t, volatile int flags)
*/ */
static int 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 i;
int leave = LLEAVE; int leave = LLEAVE;
@ -749,7 +756,9 @@ comexec(struct op *t, struct tbl *volatile tp, register char **ap, int volatile
} }
static void static void
scriptexec(register struct op *tp, register char **ap) scriptexec(tp, ap)
register struct op *tp;
register char **ap;
{ {
char *shellv; char *shellv;
@ -861,7 +870,8 @@ scriptexec(register struct op *tp, register char **ap)
} }
int int
shcomexec(register char **wp) shcomexec(wp)
register char **wp;
{ {
register struct tbl *tp; register struct tbl *tp;
@ -876,7 +886,10 @@ shcomexec(register char **wp)
* is created if none is found. * is created if none is found.
*/ */
struct tbl * 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 block *l;
struct tbl *tp = (struct tbl *) 0; 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. * function did not exist, returns 0 otherwise.
*/ */
int int
define(const char *name, struct op *t) define(name, t)
const char *name;
struct op *t;
{ {
struct tbl *tp; struct tbl *tp;
int was_set = 0; int was_set = 0;
@ -944,7 +959,9 @@ define(const char *name, struct op *t)
* add builtin * add builtin
*/ */
void void
builtin(const char *name, int (*func) ARGS((char **))) builtin(name, func)
const char *name;
int (*func) ARGS((char **));
{ {
register struct tbl *tp; register struct tbl *tp;
Tflag flag; Tflag flag;
@ -970,10 +987,11 @@ builtin(const char *name, int (*func) ARGS((char **)))
/* /*
* find command * find command
* either function, hashed command, or built-in (in that order) * either function, hashed command, or built-in (in that order)
* flags is FC_*
*/ */
struct tbl * struct tbl *
findcom(const char *name, int flags) findcom(name, flags)
const char *name;
int flags; /* FC_* */
{ {
static struct tbl temp; static struct tbl temp;
unsigned int h = hash(name); unsigned int h = hash(name);
@ -1073,10 +1091,10 @@ findcom(const char *name, int flags)
/* /*
* flush executable commands with relative paths * flush executable commands with relative paths
* all - just relative or all
*/ */
void void
flushcom(int all) flushcom(all)
int all; /* just relative or all */
{ {
struct tbl *tp; struct tbl *tp;
struct tstate ts; struct tstate ts;
@ -1091,11 +1109,12 @@ flushcom(int all)
} }
} }
/* Check if path is something we want to find. Returns -1 for failure. /* Check if path is something we want to find. Returns -1 for failure. */
* errnop is set if canidate found, but not suitable
*/
int 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 #ifndef OS2
int ret, err = 0; int ret, err = 0;
@ -1161,9 +1180,11 @@ search_access(const char *pathx, int mode, int *errnop)
} }
#ifdef OS2 #ifdef OS2
/* errnop is set if candidate found, but not suitable */
static int 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; int ret, err = 0;
struct stat statb; struct stat statb;
@ -1185,11 +1206,13 @@ search_access1(const char *pathx, int mode, int *errnop)
/* /*
* search for command with PATH * search for command with PATH
* mode == R_OK or X_OK
* errnop is set if candidate found, but not suitable
*/ */
char * 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; const char *sp, *p;
char *xp; char *xp;
@ -1255,7 +1278,9 @@ search(const char *name, const char *pathx, int mode, int *errnop)
} }
static int static int
call_builtin(struct tbl *tp, char **wp) call_builtin(tp, wp)
struct tbl *tp;
char **wp;
{ {
int rv; int rv;
@ -1276,7 +1301,9 @@ call_builtin(struct tbl *tp, char **wp)
* set up redirection, saving old fd's in e->savefd * set up redirection, saving old fd's in e->savefd
*/ */
static int static int
iosetup(register struct ioword *iop, struct tbl *tp) iosetup(iop, tp)
register struct ioword *iop;
struct tbl *tp;
{ {
register int u = -1; register int u = -1;
char *cp = iop->name; 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. * if unquoted here, expand here temp file into second temp file.
*/ */
static int static int
herein(const char *content, int sub) herein(content, sub)
const char *content;
int sub;
{ {
volatile int fd = -1; volatile int fd = -1;
struct source *s, *volatile osource; 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 * print the args in column form - assuming that we can
*/ */
static char * 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[] = { static const char *const read_args[] = {
"read", "-r", "REPLY", (char *) 0 "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 */ /* format a single select menu item */
static char * 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; 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 * print a select style menu
*/ */
int int
pr_menu(char *const *ap) pr_menu(ap)
char *const *ap;
{ {
struct select_menu_info smi; struct select_menu_info smi;
char *const *pp; 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 ARGS((void *arg, int i, char *buf, int buflen));
static char * 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]); shf_snprintf(buf, buflen, "%s", ((char *const *)arg)[i]);
return buf; return buf;
} }
int int
pr_list(char *const *ap) pr_list(ap)
char *const *ap;
{ {
char *const *pp; char *const *pp;
int nwidth; int nwidth;
@ -1621,7 +1662,9 @@ extern const char db_close[];
* TM_UNOP and TM_BINOP, the returned value is a Test_op). * TM_UNOP and TM_BINOP, the returned value is a Test_op).
*/ */
static int static int
dbteste_isa(Test_env *te, Test_meta meta) dbteste_isa(te, meta)
Test_env *te;
Test_meta meta;
{ {
int ret = 0; int ret = 0;
int uqword; int uqword;
@ -1660,7 +1703,10 @@ dbteste_isa(Test_env *te, Test_meta meta)
} }
static const char * 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; char *s = *te->pos.wp;
@ -1681,17 +1727,23 @@ dbteste_getopnd(Test_env *te, Test_op op, int do_eval)
} }
static int static int
dbteste_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, dbteste_eval(te, op, opnd1, opnd2, do_eval)
int 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); return test_eval(te, op, opnd1, opnd2, do_eval);
} }
static void 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; te->flags |= TEF_ERROR;
internal_errorf(0, "dbteste_error: %s (offset %d)", msg, offset); internal_errorf(0, "dbteste_error: %s (offset %d)", msg, offset);
} }
#endif /* KSH */ #endif /* KSH */

View File

@ -107,4 +107,3 @@ typedef struct XPtrV {
sizeofN(void*, XPsize(x)), ATEMP) sizeofN(void*, XPsize(x)), ATEMP)
#define XPfree(x) afree((void*) (x).beg, ATEMP) #define XPfree(x) afree((void*) (x).beg, ATEMP)

View File

@ -149,7 +149,10 @@ static struct tbl *intvar ARGS((Expr_state *es, struct tbl *vp));
* parse and evaluate expression * parse and evaluate expression
*/ */
int 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; struct tbl v;
int ret; int ret;
@ -165,7 +168,10 @@ evaluate(const char *expr, long *rval, int error_ok)
* parse and evaluate expression, storing result in vp. * parse and evaluate expression, storing result in vp.
*/ */
int 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; struct tbl *v;
Expr_state curstate; Expr_state curstate;
@ -217,7 +223,10 @@ v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok)
} }
static void 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]; char tbuf[2];
const char *s; const char *s;
@ -273,7 +282,9 @@ evalerr(Expr_state *es, enum error_type type, const char *str)
} }
static struct tbl * 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; struct tbl *vl, UNINITIALIZED(*vr), *vasn;
enum token op; enum token op;
@ -452,7 +463,8 @@ evalexpr(Expr_state *es, enum prec prec)
} }
static void static void
token(Expr_state *es) token(es)
Expr_state *es;
{ {
const char *cp; const char *cp;
int c; int c;
@ -525,7 +537,11 @@ token(Expr_state *es)
/* Do a ++ or -- operation */ /* Do a ++ or -- operation */
static struct tbl * 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; struct tbl *vl;
int oval; int oval;
@ -545,7 +561,10 @@ do_ppmm(Expr_state *es, enum token op, struct tbl *vasn, bool_t is_prefix)
} }
static void 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)) if (vasn->name[0] == '\0' && !(vasn->flag & EXPRLVALUE))
evalerr(es, ET_LVALUE, opinfo[(int) op].name); 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 * static struct tbl *
tempvar(void) tempvar()
{ {
register struct tbl *vp; register struct tbl *vp;
@ -569,7 +588,9 @@ tempvar(void)
/* cast (string) variable to temporary integer variable */ /* cast (string) variable to temporary integer variable */
static struct tbl * static struct tbl *
intvar(Expr_state *es, struct tbl *vp) intvar(es, vp)
Expr_state *es;
struct tbl *vp;
{ {
struct tbl *vq; struct tbl *vq;
@ -590,4 +611,3 @@ intvar(Expr_state *es, struct tbl *vp)
} }
return vq; return vq;
} }

View File

@ -80,7 +80,8 @@ static Source *hist_source;
int int
c_fc(char **wp) c_fc(wp)
char **wp;
{ {
struct shf *shf; struct shf *shf;
struct temp UNINITIALIZED(*tf); struct temp UNINITIALIZED(*tf);
@ -297,7 +298,8 @@ c_fc(char **wp)
/* Save cmd in history, execute cmd (cmd gets trashed) */ /* Save cmd in history, execute cmd (cmd gets trashed) */
static int static int
hist_execute(char *cmd) hist_execute(cmd)
char *cmd;
{ {
Source *sold; Source *sold;
int ret; int ret;
@ -337,7 +339,11 @@ hist_execute(char *cmd)
} }
static int 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; char *line;
@ -382,7 +388,10 @@ hist_replace(char **hp, const char *pat, const char *rep, int globalv)
* pattern is a number or string * pattern is a number or string
*/ */
static char ** 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; char **hp = (char **) 0;
int n; 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 */ /* Return a pointer to the newest command in the history */
static char ** static char **
hist_get_newest(int allow_cur) hist_get_newest(allow_cur)
int allow_cur;
{ {
if (histptr < histlist || (!allow_cur && histptr == histlist)) { if (histptr < histlist || (!allow_cur && histptr == histlist)) {
bi_errorf("no history (yet)"); 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 */ /* Return a pointer to the newest command in the history */
static char ** static char **
hist_get_oldest(void) hist_get_oldest()
{ {
if (histptr <= histlist) { if (histptr <= histlist) {
bi_errorf("no history (yet)"); bi_errorf("no history (yet)");
@ -449,7 +459,7 @@ hist_get_oldest(void)
/* Back up over last histsave */ /* Back up over last histsave */
/******************************/ /******************************/
static void static void
histbackup(void) histbackup()
{ {
static int last_line = -1; static int last_line = -1;
@ -465,19 +475,20 @@ histbackup(void)
* Return the current position. * Return the current position.
*/ */
char ** char **
histpos(void) histpos()
{ {
return current; return current;
} }
int int
histN(void) histN()
{ {
return curpos; return curpos;
} }
int int
histnum(int n) histnum(n)
int n;
{ {
int last = histptr - histlist; int last = histptr - histlist;
@ -498,7 +509,11 @@ histnum(int n)
* direction. * direction.
*/ */
int 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; char **hp;
int maxhist = histptr - histlist; int maxhist = histptr - histlist;
@ -522,7 +537,8 @@ findhist(int start, int fwd, const char *str, int anchored)
* this means reallocating the dataspace * this means reallocating the dataspace
*/ */
void void
sethistsize(int n) sethistsize(n)
int n;
{ {
if (n > 0 && n != histsize) { if (n > 0 && n != histsize) {
int cursize = histptr - histlist; int cursize = histptr - histlist;
@ -546,7 +562,8 @@ sethistsize(int n)
* maintenance * maintenance
*/ */
void void
sethistfile(const char *name) sethistfile(name)
const char *name;
{ {
/* if not started then nothing to do */ /* if not started then nothing to do */
if (hstarted == 0) if (hstarted == 0)
@ -585,7 +602,7 @@ sethistfile(const char *name)
* initialise the history vector * initialise the history vector
*/ */
void void
init_histvec(void) init_histvec()
{ {
if (histlist == NULL) { if (histlist == NULL) {
histsize = HISTORYSIZE; histsize = HISTORYSIZE;
@ -597,10 +614,12 @@ init_histvec(void)
# ifdef EASY_HISTORY # ifdef EASY_HISTORY
/* /*
* save command in history * save command in history
* lno and dowrite are ignored for compability with COMPLEX_HISTORY
*/ */
void 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; register char **hp = histptr;
char *cp; char *cp;
@ -624,7 +643,9 @@ histsave(int lno, const char *cmd, int dowrite)
* commands * commands
*/ */
void void
histappend(const char *cmd, int nl_separate) histappend(cmd, nl_separate)
const char *cmd;
int nl_separate;
{ {
int hlen, clen; int hlen, clen;
char *p; char *p;
@ -650,7 +671,8 @@ histappend(const char *cmd, int nl_separate)
* to save its history. * to save its history.
*/ */
void void
hist_init(Source *s) hist_init(s)
Source *s;
{ {
char *f; char *f;
FILE *fh; FILE *fh;
@ -715,7 +737,7 @@ hist_init(Source *s)
*/ */
void void
hist_finish(void) hist_finish()
{ {
static int once; static int once;
int fd; int fd;
@ -775,7 +797,10 @@ hist_finish(void)
* save command in history * save command in history
*/ */
void void
histsave(int lno, const char *cmd, int dowrite) histsave(lno, cmd, dowrite)
int lno;
const char *cmd;
int dowrite;
{ {
register char **hp; register char **hp;
char *c, *cp; char *c, *cp;
@ -823,7 +848,8 @@ histsave(int lno, const char *cmd, int dowrite)
# define COMMAND 0xff # define COMMAND 0xff
void void
hist_init(Source *s) hist_init(s)
Source *s;
{ {
unsigned char *base; unsigned char *base;
int lines; int lines;
@ -900,7 +926,9 @@ typedef enum state {
} State; } State;
static int 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; State state = shdr;
int lines = 0; int lines = 0;
@ -933,7 +961,9 @@ hist_count_lines(register unsigned char *base, register int bytes)
* Shrink the history file to histsize lines * Shrink the history file to histsize lines
*/ */
static int static int
hist_shrink(unsigned char *oldbase, int oldbytes) hist_shrink(oldbase, oldbytes)
unsigned char *oldbase;
int oldbytes;
{ {
int fd; int fd;
char nfile[1024]; char nfile[1024];
@ -985,7 +1015,10 @@ hist_shrink(unsigned char *oldbase, int oldbytes)
* return the pointer and the number of bytes left * return the pointer and the number of bytes left
*/ */
static unsigned char * 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 int lines = 0;
register unsigned char *ep; 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 * load the history structure from the stored data
*/ */
static void 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; State state;
int lno = 0; 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 * Insert a line into the history at a specified number
*/ */
static void static void
histinsert(Source *s, int lno, unsigned char *line) histinsert(s, lno, line)
Source *s;
int lno;
unsigned char *line;
{ {
register char **hp; 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 * and we should read those commands to update our history
*/ */
static void static void
writehistfile(int lno, char *cmd) writehistfile(lno, cmd)
int lno;
char *cmd;
{ {
int sizenow; int sizenow;
unsigned char *base; unsigned char *base;
@ -1137,7 +1178,7 @@ bad:
} }
void void
hist_finish(void) hist_finish()
{ {
(void) flock(histfd, LOCK_UN); (void) flock(histfd, LOCK_UN);
(void) close(histfd); (void) close(histfd);
@ -1148,7 +1189,8 @@ hist_finish(void)
* add magic to the history file * add magic to the history file
*/ */
static int static int
sprinkle(int fd) sprinkle(fd)
int fd;
{ {
static unsigned char mag[] = { HMAGIC1, HMAGIC2 }; 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 */ /* No history to be compiled in: dummy routines to avoid lots more ifdefs */
void void
init_histvec(void) init_histvec()
{ {
} }
void void
hist_init(Source *s) hist_init(s)
Source *s;
{ {
} }
void void
hist_finish(void) hist_finish()
{ {
} }
void void
histsave(int lno, const char *cmd, int dowrite) histsave(lno, cmd, dowrite)
int lno;
const char *cmd;
int dowrite;
{ {
errorf("history not enabled"); errorf("history not enabled");
} }
#endif /* HISTORY */ #endif /* HISTORY */

View File

@ -23,7 +23,13 @@ static int initio_done;
/* A shell error occurred (eg, syntax error, etc.) */ /* A shell error occurred (eg, syntax error, etc.) */
void void
#ifdef HAVE_PROTOTYPES
errorf(const char *fmt, ...) errorf(const char *fmt, ...)
#else
errorf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list va; va_list va;
@ -42,7 +48,14 @@ errorf(const char *fmt, ...)
/* like errorf(), but no unwind is done */ /* like errorf(), but no unwind is done */
void void
#ifdef HAVE_PROTOTYPES
warningf(int fileline, const char *fmt, ...) warningf(int fileline, const char *fmt, ...)
#else
warningf(fileline, fmt, va_alist)
int fileline;
const char *fmt;
va_dcl
#endif
{ {
va_list va; va_list va;
@ -58,7 +71,13 @@ warningf(int fileline, const char *fmt, ...)
* (also unwinds environments for special builtins). * (also unwinds environments for special builtins).
*/ */
void void
#ifdef HAVE_PROTOTYPES
bi_errorf(const char *fmt, ...) bi_errorf(const char *fmt, ...)
#else
bi_errorf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list va; va_list va;
@ -89,7 +108,14 @@ bi_errorf(const char *fmt, ...)
/* Called when something that shouldn't happen does */ /* Called when something that shouldn't happen does */
void void
#ifdef HAVE_PROTOTYPES
internal_errorf(int jump, const char *fmt, ...) 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; va_list va;
@ -106,7 +132,8 @@ internal_errorf(int jump, const char *fmt, ...)
/* used by error reporting functions to print "ksh: .kshrc[25]: " */ /* used by error reporting functions to print "ksh: .kshrc[25]: " */
void void
error_prefix(int fileline) error_prefix(fileline)
int fileline;
{ {
/* Avoid foo: foo[2]: ... */ /* Avoid foo: foo[2]: ... */
if (!fileline || !source || !source->file if (!fileline || !source || !source->file
@ -121,7 +148,13 @@ error_prefix(int fileline)
/* printf to shl_out (stderr) with flush */ /* printf to shl_out (stderr) with flush */
void void
#ifdef HAVE_PROTOTYPES
shellf(const char *fmt, ...) shellf(const char *fmt, ...)
#else
shellf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list va; va_list va;
@ -135,7 +168,13 @@ shellf(const char *fmt, ...)
/* printf to shl_stdout (stdout) */ /* printf to shl_stdout (stdout) */
void void
#ifdef HAVE_PROTOTYPES
shprintf(const char *fmt, ...) shprintf(const char *fmt, ...)
#else
shprintf(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list va; va_list va;
@ -150,7 +189,7 @@ shprintf(const char *fmt, ...)
static struct shf *kshdebug_shf; static struct shf *kshdebug_shf;
void void
kshdebug_init_(void) kshdebug_init_()
{ {
if (kshdebug_shf) if (kshdebug_shf)
shf_close(kshdebug_shf); shf_close(kshdebug_shf);
@ -165,7 +204,13 @@ kshdebug_init_(void)
/* print to debugging log */ /* print to debugging log */
void void
# ifdef HAVE_PROTOTYPES
kshdebug_printf_(const char *fmt, ...) kshdebug_printf_(const char *fmt, ...)
# else
kshdebug_printf_(fmt, va_alist)
const char *fmt;
va_dcl
# endif
{ {
va_list va; va_list va;
@ -179,7 +224,10 @@ kshdebug_printf_(const char *fmt, ...)
} }
void 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 i, j;
int nprow = 16; 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) */ /* test if we can seek backwards fd (returns 0 or SHF_UNBUF) */
int int
can_seek(int fd) can_seek(fd)
int fd;
{ {
struct stat statb; struct stat statb;
@ -213,7 +262,7 @@ can_seek(int fd)
struct shf shf_iob[3]; struct shf shf_iob[3];
void void
initio(void) initio()
{ {
shf_fdopen(1, SHF_WR, shl_stdout); /* force buffer allocation */ shf_fdopen(1, SHF_WR, shl_stdout); /* force buffer allocation */
shf_fdopen(2, SHF_WR, shl_out); shf_fdopen(2, SHF_WR, shl_out);
@ -224,7 +273,10 @@ initio(void)
/* A dup2() with error checking */ /* A dup2() with error checking */
int 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); int ret = dup2(ofd, nfd);
@ -245,7 +297,9 @@ ksh_dup2(int ofd, int nfd, int errok)
* set close-on-exec flag. * set close-on-exec flag.
*/ */
int int
savefd(int fd, int noclose) savefd(fd, noclose)
int fd;
int noclose;
{ {
int nfd; int nfd;
@ -266,7 +320,8 @@ savefd(int fd, int noclose)
} }
void void
restfd(int fd, int ofd) restfd(fd, ofd)
int fd, ofd;
{ {
if (fd == 2) if (fd == 2)
shf_flush(&shf_iob[fd]); shf_flush(&shf_iob[fd]);
@ -279,7 +334,8 @@ restfd(int fd, int ofd)
} }
void void
openpipe(register int *pv) openpipe(pv)
register int *pv;
{ {
if (pipe(pv) < 0) if (pipe(pv) < 0)
errorf("can't create pipe - try again"); errorf("can't create pipe - try again");
@ -288,7 +344,8 @@ openpipe(register int *pv)
} }
void void
closepipe(register int *pv) closepipe(pv)
register int *pv;
{ {
close(pv[0]); close(pv[0]);
close(pv[1]); 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. * a string (the X in 2>&X, read -uX, print -uX) into a file descriptor.
*/ */
int 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; int fd, fl;
@ -353,7 +413,7 @@ check_fd(char *name, int mode, const char **emsgp)
#ifdef KSH #ifdef KSH
/* Called once from main */ /* Called once from main */
void void
coproc_init(void) coproc_init()
{ {
coproc.read = coproc.readw = coproc.write = -1; coproc.read = coproc.readw = coproc.write = -1;
coproc.njobs = 0; 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 */ /* Called by c_read() when eof is read - close fd if it is the co-process fd */
void void
coproc_read_close(int fd) coproc_read_close(fd)
int fd;
{ {
if (coproc.read >= 0 && fd == coproc.read) { if (coproc.read >= 0 && fd == coproc.read) {
coproc_readw_close(fd); coproc_readw_close(fd);
@ -375,7 +436,8 @@ coproc_read_close(int fd)
* read pipe, so reads will actually terminate. * read pipe, so reads will actually terminate.
*/ */
void void
coproc_readw_close(int fd) coproc_readw_close(fd)
int fd;
{ {
if (coproc.readw >= 0 && coproc.read >= 0 && fd == coproc.read) { if (coproc.readw >= 0 && coproc.read >= 0 && fd == coproc.read) {
close(coproc.readw); close(coproc.readw);
@ -387,7 +449,8 @@ coproc_readw_close(int fd)
* when co-process input is dup'd * when co-process input is dup'd
*/ */
void void
coproc_write_close(int fd) coproc_write_close(fd)
int fd;
{ {
if (coproc.write >= 0 && fd == coproc.write) { if (coproc.write >= 0 && fd == coproc.write) {
close(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). * (Used by check_fd() and by c_read/c_print to deal with -p option).
*/ */
int 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; 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. * Should be called with SIGCHLD blocked.
*/ */
void void
coproc_cleanup(int reuse) coproc_cleanup(reuse)
int reuse;
{ {
/* This to allow co-processes to share output pipe */ /* This to allow co-processes to share output pipe */
if (!reuse || coproc.readw < 0 || coproc.read < 0) { if (!reuse || coproc.readw < 0 || coproc.read < 0) {
@ -440,7 +506,10 @@ coproc_cleanup(int reuse)
*/ */
struct temp * 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__ #ifndef __NetBSD__
static unsigned int inc; static unsigned int inc;
@ -497,4 +566,3 @@ maketemp(Area *ap, Temp_type type, struct temp **tlist)
return tp; return tp;
} }

View File

@ -66,13 +66,16 @@ int tcsetpgrp ARGS((int fd, pid_t grp));
int tcgetpgrp ARGS((int fd)); int tcgetpgrp ARGS((int fd));
int int
tcsetpgrp(int fd, pid_t grp) tcsetpgrp(fd, grp)
int fd;
pid_t grp;
{ {
return ioctl(fd, TIOCSPGRP, &grp); return ioctl(fd, TIOCSPGRP, &grp);
} }
int int
tcgetpgrp(int fd) tcgetpgrp(fd)
int fd;
{ {
int r, grp; int r, grp;
@ -228,7 +231,8 @@ static int kill_job ARGS((Job *j, int sig));
/* initialize job control */ /* initialize job control */
void void
j_init(int mflagset) j_init(mflagset)
int mflagset;
{ {
child_max = CHILD_MAX; /* so syscon() isn't always being called */ child_max = CHILD_MAX; /* so syscon() isn't always being called */
@ -282,7 +286,7 @@ j_init(int mflagset)
/* job cleanup before shell exit */ /* job cleanup before shell exit */
void void
j_exit(void) j_exit()
{ {
/* kill stopped, and possibly running, jobs */ /* kill stopped, and possibly running, jobs */
Job *j; Job *j;
@ -339,7 +343,7 @@ j_exit(void)
#ifdef JOBS #ifdef JOBS
/* turn job control on or off according to Flag(FMONITOR) */ /* turn job control on or off according to Flag(FMONITOR) */
void void
j_change(void) j_change()
{ {
int i; int i;
@ -432,11 +436,12 @@ j_change(void)
} }
#endif /* JOBS */ #endif /* JOBS */
/* execute tree in child subprocess /* execute tree in child subprocess */
* close_fd used if XPCLOSE or XCCLOSE
*/
int 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 */ 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 */ /* start the last job: only used for `command` jobs */
void void
startlast(void) startlast()
{ {
#ifdef JOB_SIGS #ifdef JOB_SIGS
sigset_t omask; sigset_t omask;
@ -715,7 +720,7 @@ startlast(void)
/* wait for last job: only used for `command` jobs */ /* wait for last job: only used for `command` jobs */
int int
waitlast(void) waitlast()
{ {
int rv; int rv;
Job *j; Job *j;
@ -748,7 +753,9 @@ waitlast(void)
/* wait for child, interruptable. */ /* wait for child, interruptable. */
int int
waitfor(const char *cp, int *sigp) waitfor(cp, sigp)
const char *cp;
int *sigp;
{ {
int rv; int rv;
Job *j; Job *j;
@ -809,7 +816,9 @@ waitfor(const char *cp, int *sigp)
/* kill (built-in) a job */ /* kill (built-in) a job */
int int
j_kill(const char *cp, int sig) j_kill(cp, sig)
const char *cp;
int sig;
{ {
Job *j; Job *j;
int rv = 0; int rv = 0;
@ -854,7 +863,9 @@ j_kill(const char *cp, int sig)
#ifdef JOBS #ifdef JOBS
/* fg and bg built-ins: called only if Flag(FMONITOR) set */ /* fg and bg built-ins: called only if Flag(FMONITOR) set */
int int
j_resume(const char *cp, int bg) j_resume(cp, bg)
const char *cp;
int bg;
{ {
Job *j; Job *j;
Proc *p; Proc *p;
@ -960,7 +971,7 @@ j_resume(const char *cp, int bg)
/* are there any running or stopped jobs ? */ /* are there any running or stopped jobs ? */
int int
j_stopped_running(void) j_stopped_running()
{ {
Job *j; Job *j;
int which = 0; int which = 0;
@ -985,11 +996,12 @@ j_stopped_running(void)
return 0; return 0;
} }
/* list jobs for jobs built-in /* list jobs for jobs built-in */
* slp: 0 for short, 1 for long, 3 for pgrp
*/
int 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; Job *j, *tmp;
int how; int how;
@ -1042,7 +1054,7 @@ j_jobs(const char *cp, int slp, int nflag)
/* list jobs for top-level notification */ /* list jobs for top-level notification */
void void
j_notify(void) j_notify()
{ {
Job *j, *tmp; Job *j, *tmp;
#ifdef JOB_SIGS #ifdef JOB_SIGS
@ -1074,7 +1086,7 @@ j_notify(void)
/* Return pid of last process in last asynchronous job */ /* Return pid of last process in last asynchronous job */
pid_t pid_t
j_async(void) j_async()
{ {
#ifdef JOB_SIGS #ifdef JOB_SIGS
sigset_t omask; sigset_t omask;
@ -1097,7 +1109,8 @@ j_async(void)
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static void static void
j_set_async(Job *j) j_set_async(j)
Job *j;
{ {
Job *jl, *oldest; 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. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static void static void
j_startjob(Job *j) j_startjob(j)
Job *j;
{ {
Proc *p; Proc *p;
@ -1160,11 +1174,12 @@ j_startjob(Job *j)
* wait for job to complete or change state * wait for job to complete or change state
* *
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*
* see JW_* for flags parameter
*/ */
static int 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; 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. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static RETSIGTYPE static RETSIGTYPE
j_sigchld(int sig) j_sigchld(sig)
int sig;
{ {
int errno_ = errno; int errno_ = errno;
Job *j; Job *j;
@ -1385,7 +1401,8 @@ found:
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static void static void
check_job(Job *j) check_job(j)
Job *j;
{ {
int jstate; int jstate;
Proc *p; Proc *p;
@ -1493,7 +1510,10 @@ check_job(Job *j)
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static void 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; Proc *p;
int state; 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. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static Job * static Job *
j_lookup(const char *cp, int *ecodep) j_lookup(cp, ecodep)
const char *cp;
int *ecodep;
{ {
Job *j, *last_match; Job *j, *last_match;
Proc *p; Proc *p;
@ -1695,7 +1717,7 @@ static Proc *free_procs;
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static Job * static Job *
new_job(void) new_job()
{ {
int i; int i;
Job *newj, *j; Job *newj, *j;
@ -1723,7 +1745,7 @@ new_job(void)
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static Proc * static Proc *
new_proc(void) new_proc()
{ {
Proc *p; Proc *p;
@ -1742,7 +1764,9 @@ new_proc(void)
* If jobs are compiled in then this routine expects sigchld to be blocked. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static void static void
remove_job(Job *j, const char *where) remove_job(j, where)
Job *j;
const char *where;
{ {
Proc *p, *tmp; Proc *p, *tmp;
Job **prev, *curr; 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. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static void static void
put_job(Job *j, int where) put_job(j, where)
Job *j;
int where;
{ {
Job **prev, *curr; 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. * If jobs are compiled in then this routine expects sigchld to be blocked.
*/ */
static int static int
kill_job(Job *j, int sig) kill_job(j, sig)
Job *j;
int sig;
{ {
Proc *p; Proc *p;
int rval = 0; int rval = 0;
@ -1828,4 +1856,3 @@ kill_job(Job *j, int sig)
rval = -1; rval = -1;
return rval; return rval;
} }

View File

@ -25,4 +25,3 @@ extern DIR *ksh_opendir ARGS((const char *d));
#else /* OPENDIR_DOES_NONDIR */ #else /* OPENDIR_DOES_NONDIR */
# define ksh_opendir(d) opendir(d) # define ksh_opendir(d) opendir(d)
#endif /* OPENDIR_DOES_NONDIR */ #endif /* OPENDIR_DOES_NONDIR */

View File

@ -23,4 +23,3 @@
#ifndef BITS #ifndef BITS
# define BITS(t) (BITSPERBYTE * sizeof(t)) # define BITS(t) (BITSPERBYTE * sizeof(t))
#endif #endif

View File

@ -58,4 +58,3 @@
#ifndef S_IXOTH #ifndef S_IXOTH
# define S_IXOTH 00001 /* user execute bit */ # define S_IXOTH 00001 /* user execute bit */
#endif /* S_IXOTH */ #endif /* S_IXOTH */

View File

@ -25,4 +25,3 @@ extern time_t time ARGS((time_t *));
# define CLK_TCK 60 /* 60HZ */ # define CLK_TCK 60 /* 60HZ */
#endif #endif
#endif /* KSH_TIME_H */ #endif /* KSH_TIME_H */

View File

@ -18,4 +18,3 @@ extern clock_t ksh_times ARGS((struct tms *));
extern clock_t times ARGS((struct tms *)); extern clock_t times ARGS((struct tms *));
#endif /* HAVE_TIMES */ #endif /* HAVE_TIMES */
#endif /* KSH_TIMES_H */ #endif /* KSH_TIMES_H */

View File

@ -50,4 +50,3 @@ typedef int WAIT_T;
#else /* !HAVE_WAITPID && HAVE_WAIT3 */ #else /* !HAVE_WAITPID && HAVE_WAIT3 */
# define ksh_waitpid(p, s, o) waitpid((p), (s), (o)) # define ksh_waitpid(p, s, o) waitpid((p), (s), (o))
#endif /* !HAVE_WAITPID && HAVE_WAIT3 */ #endif /* !HAVE_WAITPID && HAVE_WAIT3 */

View File

@ -103,7 +103,8 @@ static int ignore_backslash_newline;
*/ */
int int
yylex(int cf) yylex(cf)
int cf;
{ {
Lex_state states[STATE_BSIZE], *statep; Lex_state states[STATE_BSIZE], *statep;
State_info state_info; State_info state_info;
@ -768,7 +769,7 @@ Done:
} }
static void static void
gethere(void) gethere()
{ {
register struct ioword **p; register struct ioword **p;
@ -782,7 +783,8 @@ gethere(void)
*/ */
static void static void
readhere(struct ioword *iop) readhere(iop)
struct ioword *iop;
{ {
register int c; register int c;
char *volatile eof; char *volatile eof;
@ -840,7 +842,13 @@ readhere(struct ioword *iop)
} }
void void
#ifdef HAVE_PROTOTYPES
yyerror(const char *fmt, ...) yyerror(const char *fmt, ...)
#else
yyerror(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{ {
va_list va; va_list va;
@ -861,7 +869,9 @@ yyerror(const char *fmt, ...)
*/ */
Source * Source *
pushs(int type, Area *areap) pushs(type, areap)
int type;
Area *areap;
{ {
register Source *s; register Source *s;
@ -884,7 +894,7 @@ pushs(int type, Area *areap)
} }
static int static int
getsc__(void) getsc__()
{ {
register Source *s = source; register Source *s = source;
register int c; register int c;
@ -985,7 +995,8 @@ getsc__(void)
} }
static void static void
getsc_line(Source *s) getsc_line(s)
Source *s;
{ {
char *xp = Xstring(s->xs, xp); char *xp = Xstring(s->xs, xp);
int interactive = Flag(FTALKING) && s->type == SSTDIN; int interactive = Flag(FTALKING) && s->type == SSTDIN;
@ -1097,7 +1108,9 @@ getsc_line(Source *s)
} }
void void
set_prompt(int to, Source *s) set_prompt(to, s)
int to;
Source *s;
{ {
cur_prompt = to; cur_prompt = to;
@ -1153,7 +1166,9 @@ set_prompt(int to, Source *s)
/* See also related routine, promptlen() in edit.c */ /* See also related routine, promptlen() in edit.c */
void void
pprompt(const char *cp, int ntruncate) pprompt(cp, ntruncate)
const char *cp;
int ntruncate;
{ {
#if 0 #if 0
char nbuf[32]; char nbuf[32];
@ -1197,7 +1212,9 @@ pprompt(const char *cp, int ntruncate)
* the :[-+?=#%] or close-brace. * the :[-+?=#%] or close-brace.
*/ */
static char * static char *
get_brace_var(XString *wsp, char *wp) get_brace_var(wsp, wp)
XString *wsp;
char *wp;
{ {
enum parse_state { enum parse_state {
PS_INITIAL, PS_SAW_HASH, PS_IDENT, PS_INITIAL, PS_SAW_HASH, PS_IDENT,
@ -1272,7 +1289,8 @@ get_brace_var(XString *wsp, char *wp)
* (Returned string double null terminated) * (Returned string double null terminated)
*/ */
static int static int
arraysub(char **strp) arraysub(strp)
char **strp;
{ {
XString ws; XString ws;
char *wp; char *wp;
@ -1299,7 +1317,8 @@ arraysub(char **strp)
/* Unget a char: handles case when we are already at the start of the buffer */ /* Unget a char: handles case when we are already at the start of the buffer */
static const char * static const char *
ungetsc(int c) ungetsc(c)
int c;
{ {
if (backslash_skip) if (backslash_skip)
backslash_skip--; backslash_skip--;
@ -1351,7 +1370,9 @@ getsc_bn ARGS((void))
} }
static Lex_state * 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); 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 * 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; 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; return si->base + STATE_BSIZE - 1;
} }

View File

@ -131,4 +131,3 @@ EXTERN char **histlist; /* saved commands */
EXTERN char **histptr; /* last history item */ EXTERN char **histptr; /* last history item */
EXTERN int histsize; /* history size */ EXTERN int histsize; /* history size */
#endif /* HISTORY */ #endif /* HISTORY */

View File

@ -43,7 +43,7 @@ static mbox_t * mballoc ARGS((char *p, char *m)); /* allocate a new mbox */
static void mprintit ARGS((mbox_t *mbp)); static void mprintit ARGS((mbox_t *mbp));
void void
mcheck(void) mcheck()
{ {
register mbox_t *mbp; register mbox_t *mbp;
time_t now; time_t now;
@ -87,13 +87,15 @@ mcheck(void)
} }
void void
mcset(long interval) mcset(interval)
long interval;
{ {
mailcheck_interval = interval; mailcheck_interval = interval;
} }
void void
mbset(register char *p) mbset(p)
register char *p;
{ {
struct stat stbuf; struct stat stbuf;
@ -111,7 +113,8 @@ mbset(register char *p)
} }
void void
mpset(register char *mptoparse) mpset(mptoparse)
register char *mptoparse;
{ {
register mbox_t *mbp; register mbox_t *mbp;
register char *mpath, *mmsg, *mval; register char *mpath, *mmsg, *mval;
@ -150,7 +153,8 @@ mpset(register char *mptoparse)
} }
static void static void
munset(register mbox_t *mlist) munset(mlist)
register mbox_t *mlist;
{ {
register mbox_t *mbp; register mbox_t *mbp;
@ -164,7 +168,9 @@ munset(register mbox_t *mlist)
} }
static mbox_t * static mbox_t *
mballoc(char *p, char *m) mballoc(p, m)
char *p;
char *m;
{ {
struct stat stbuf; struct stat stbuf;
register mbox_t *mbp; register mbox_t *mbp;
@ -181,7 +187,8 @@ mballoc(char *p, char *m)
} }
static void static void
mprintit(mbox_t *mbp) mprintit( mbp )
mbox_t *mbp;
{ {
struct tbl *vp; struct tbl *vp;
@ -193,4 +200,3 @@ mprintit(mbox_t *mbp)
unset(vp, 0); unset(vp, 0);
} }
#endif /* KSH */ #endif /* KSH */

View File

@ -454,7 +454,11 @@ main(int argc, char *argv[])
} }
int 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; register Source *volatile s = NULL;
struct shf *shf; struct shf *shf;
@ -522,7 +526,8 @@ include(const char *name, int argc, char **argv, int intr_ok)
} }
int int
command(const char *comm) command(comm)
const char *comm;
{ {
register Source *s; register Source *s;
int r; int r;
@ -536,10 +541,11 @@ command(const char *comm)
/* /*
* run the commands from the input source, returning status. * run the commands from the input source, returning status.
* s - input source
*/ */
int int
shell(Source *volatile s, int volatile toplevel) shell(s, toplevel)
Source *volatile s; /* input source */
int volatile toplevel;
{ {
struct op *t; struct op *t;
volatile int wastty = s->flags & SF_TTY; 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 */ /* return to closest error handler or shell(), exit if none found */
void void
unwind(int i) unwind(i)
int i;
{ {
/* ordering for EXIT vs ERR is a bit odd (this is what at&t ksh does) */ /* 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) if (i == LEXIT || (Flag(FERREXIT) && (i == LERROR || i == LINTR)
@ -682,7 +689,8 @@ unwind(int i)
} }
void void
newenv(int type) newenv(type)
int type;
{ {
register struct env *ep; register struct env *ep;
@ -698,7 +706,7 @@ newenv(int type)
} }
void void
quitenv(void) quitenv()
{ {
register struct env *ep = e; register struct env *ep = e;
register int fd; register int fd;
@ -750,7 +758,7 @@ quitenv(void)
/* Called after a fork to cleanup stuff left over from parents environment */ /* Called after a fork to cleanup stuff left over from parents environment */
void void
cleanup_parents_env(void) cleanup_parents_env()
{ {
struct env *ep; struct env *ep;
int fd; int fd;
@ -775,7 +783,7 @@ cleanup_parents_env(void)
/* Called just before an execve cleanup stuff temporary files */ /* Called just before an execve cleanup stuff temporary files */
void void
cleanup_proc_env(void) cleanup_proc_env()
{ {
struct env *ep; struct env *ep;
@ -785,7 +793,7 @@ cleanup_proc_env(void)
/* remove temp files and free ATEMP Area */ /* remove temp files and free ATEMP Area */
static void static void
reclaim(void) reclaim()
{ {
remove_temps(e->temps); remove_temps(e->temps);
e->temps = NULL; e->temps = NULL;
@ -793,7 +801,8 @@ reclaim(void)
} }
static void static void
remove_temps(struct temp *tp) remove_temps(tp)
struct temp *tp;
{ {
#ifdef OS2 #ifdef OS2
static struct temp *delayed_remove; static struct temp *delayed_remove;
@ -838,7 +847,8 @@ remove_temps(struct temp *tp)
/* Returns true if name refers to a restricted shell */ /* Returns true if name refers to a restricted shell */
static int static int
is_restricted(char *name) is_restricted(name)
char *name;
{ {
char *p; char *p;
@ -849,10 +859,11 @@ is_restricted(char *name)
} }
void void
aerror(Area *ap, const char *msg) aerror(ap, msg)
Area *ap;
const char *msg;
{ {
internal_errorf(1, "alloc: %s", msg); internal_errorf(1, "alloc: %s", msg);
errorf("%s", null); /* this is never executed - keeps gcc quiet */ errorf("%s", null); /* this is never executed - keeps gcc quiet */
/*NOTREACHED*/ /*NOTREACHED*/
} }

View File

@ -31,7 +31,9 @@ static const unsigned char *cclass ARGS((const unsigned char *p, int sub));
* Fast character classes * Fast character classes
*/ */
void void
setctypes(register const char *s, register int t) setctypes(s, t)
register const char *s;
register int t;
{ {
register int i; register int i;
@ -45,7 +47,7 @@ setctypes(register const char *s, register int t)
} }
void void
initctypes(void) initctypes()
{ {
register int c; register int c;
@ -66,7 +68,9 @@ initctypes(void)
/* convert unsigned long to base N string */ /* convert unsigned long to base N string */
char * char *
ulton(register unsigned long n, int base) ulton(n, base)
register unsigned long n;
int base;
{ {
register char *p; register char *p;
static char buf [20]; static char buf [20];
@ -81,7 +85,9 @@ ulton(register unsigned long n, int base)
} }
char * char *
str_save(register const char *s, Area *ap) str_save(s, ap)
register const char *s;
Area *ap;
{ {
size_t len; size_t len;
char *p; char *p;
@ -99,7 +105,10 @@ str_save(register const char *s, Area *ap)
* (unless n < 0). * (unless n < 0).
*/ */
char * 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; char *ns;
@ -112,7 +121,10 @@ str_nsave(register const char *s, int n, Area *ap)
/* called from expand.h:XcheckN() to grow buffer */ /* called from expand.h:XcheckN() to grow buffer */
char * 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; 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) * translate -o option into F* constant (also used for test -o option)
*/ */
int int
option(const char *n) option(n)
const char *n;
{ {
int i; int i;
@ -209,7 +222,11 @@ static void printoptions ARGS((int verbose));
/* format a single select menu item */ /* format a single select menu item */
static char * 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; 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 static void
printoptions(int verbose) printoptions(verbose)
int verbose;
{ {
int i; int i;
@ -252,7 +270,7 @@ printoptions(int verbose)
} }
char * char *
getoptions(void) getoptions()
{ {
size_t i; size_t i;
char m[(int) FNFLAGS + 1]; char m[(int) FNFLAGS + 1];
@ -265,14 +283,12 @@ getoptions(void)
return str_save(m, ATEMP); return str_save(m, ATEMP);
} }
/* change a Flag(*) value; takes care of special actions /* change a Flag(*) value; takes care of special actions */
*
* f - flag to change
* what - what is changing the flag (command line vs set)
*
*/
void 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; 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 /* parse command line & set command arguments. returns the index of
* non-option arguments, -1 if there is an error. * non-option arguments, -1 if there is an error.
*
* what - OF_CMDLINE or OF_SET
*/ */
int 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 cmd_opts[NELEM(goptions) + 3]; /* o:\0 */
static char set_opts[NELEM(goptions) + 5]; /* Ao;s\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 */ /* parse a decimal number: returns 0 if string isn't a number, 1 otherwise */
int int
getn(const char *as, int *ai) getn(as, ai)
const char *as;
int *ai;
{ {
char *p; char *p;
long n; long n;
@ -487,7 +506,9 @@ getn(const char *as, int *ai)
/* getn() that prints error */ /* getn() that prints error */
int int
bi_getn(const char *as, int *ai) bi_getn(as, ai)
const char *as;
int *ai;
{ {
int rv = getn(as, ai); int rv = getn(as, ai);
@ -507,7 +528,9 @@ bi_getn(const char *as, int *ai)
*/ */
int int
gmatch(const char *s, const char *p, int isfile) gmatch(s, p, isfile)
const char *s, *p;
int isfile;
{ {
const char *se, *pe; const char *se, *pe;
@ -548,7 +571,8 @@ gmatch(const char *s, const char *p, int isfile)
- return ? - return ?
*/ */
int 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 *p = (const unsigned char *) xp;
const unsigned char *pe = (const unsigned char *) xpe; 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|'!') */ /* Function must return either 0 or 1 (assumed by code for 0x80|'!') */
static int static int
do_gmatch(const unsigned char *s, const unsigned char *se, do_gmatch(s, se, p, pe, isfile)
const unsigned char *p, const unsigned char *pe, const unsigned char *s, *p;
int isfile) const unsigned char *se, *pe;
int isfile;
{ {
register int sc, pc; register int sc, pc;
const unsigned char *prest, *psub, *pnext; const unsigned char *prest, *psub, *pnext;
@ -736,7 +761,9 @@ do_gmatch(const unsigned char *s, const unsigned char *se,
} }
static const unsigned char * 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; register int c, d, not, found = 0;
const unsigned char *orig_p = p; 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 */ /* Look for next ) or | (if match_sep) in *(foo|bar) pattern */
const unsigned char * 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; 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 *))); static void qsort1 ARGS((void **base, void **lim, int (*f)(void *, void *)));
/*
* base - base address
* n - elements
* f - compare function
*/
void 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); qsort1(base, base + n, f);
} }
@ -824,7 +852,9 @@ qsortp(void **base, size_t n, int (*f)(void*, void*))
} }
static 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 **i, **j;
register void **lptr, **hptr; register void **lptr, **hptr;
@ -893,14 +923,17 @@ qsort1(void **base, void **lim, int (*f)(void *, void *))
} }
int int
xstrcmp(void *p1, void *p2) xstrcmp(p1, p2)
void *p1, *p2;
{ {
return (strcmp((char *)p1, (char *)p2)); return (strcmp((char *)p1, (char *)p2));
} }
/* Initialize a Getopt structure */ /* Initialize a Getopt structure */
void void
ksh_getopt_reset(Getopt *go, int flags) ksh_getopt_reset(go, flags)
Getopt *go;
int flags;
{ {
go->optind = 1; go->optind = 1;
go->optarg = (char *) 0; go->optarg = (char *) 0;
@ -936,7 +969,10 @@ ksh_getopt_reset(Getopt *go, int flags)
* in go->info. * in go->info.
*/ */
int 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 c;
char *o; char *o;
@ -1036,7 +1072,8 @@ ksh_getopt(char **argv, Getopt *go, const char *options)
* No trailing newline is printed. * No trailing newline is printed.
*/ */
void void
print_value_quoted(const char *s) print_value_quoted(s)
const char *s;
{ {
const char *p; const char *p;
int inquote = 0; int inquote = 0;
@ -1069,8 +1106,13 @@ print_value_quoted(const char *s)
* element * element
*/ */
void void
print_columns(struct shf *shf, int n, char *(*func)(void *, int, char *, int), print_columns(shf, n, func, arg, max_width, prefcol)
void *arg, int max_width, int 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); char *str = (char *) alloc(max_width + 1, ATEMP);
int i; 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) */ /* Strip any nul bytes from buf - returns new length (nbytes - # of nuls) */
int int
strip_nuls(char *buf, int nbytes) strip_nuls(buf, nbytes)
char *buf;
int nbytes;
{ {
char *dst; char *dst;
@ -1147,7 +1191,10 @@ strip_nuls(char *buf, int nbytes)
* Returns dst. * Returns dst.
*/ */
char * 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) { if (dsize > 0) {
int len = strlen(src); int len = strlen(src);
@ -1164,7 +1211,10 @@ str_zcpy(char *dst, const char *src, int dsize)
* and restarts read. * and restarts read.
*/ */
int int
blocking_read(int fd, char *buf, int nbytes) blocking_read(fd, buf, nbytes)
int fd;
char *buf;
int nbytes;
{ {
int ret; int ret;
int tried_reset = 0; int tried_reset = 0;
@ -1193,7 +1243,8 @@ blocking_read(int fd, char *buf, int nbytes)
* 1 if it was. * 1 if it was.
*/ */
int int
reset_nonblock(int fd) reset_nonblock(fd)
int fd;
{ {
int flags; int flags;
int blocking_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) */ /* Like getcwd(), except bsize is ignored if buf is 0 (MAXPATHLEN is used) */
char * char *
ksh_get_wd(char *buf, int bsize) ksh_get_wd(buf, bsize)
char *buf;
int bsize;
{ {
#ifdef HAVE_GETCWD #ifdef HAVE_GETCWD
char *b; char *b;
@ -1309,4 +1362,3 @@ ksh_get_wd(char *buf, int bsize)
return b; return b;
#endif /* HAVE_GETCWD */ #endif /* HAVE_GETCWD */
} }

View File

@ -36,12 +36,14 @@ static char *do_phys_path ARGS((XString *, char *, const char *));
* if there are no more elements. * if there are no more elements.
* The return value indicates whether a non-null element from cdpathp * The return value indicates whether a non-null element from cdpathp
* was appended to result. * was appended to result.
*
* cdpathp - & of : separated list
*/ */
int int
make_path(const char *cwd, const char *file, char **cdpathp, XString *xsp, make_path(cwd, file, cdpathp, xsp, phys_pathp)
int *phys_pathp) const char *cwd;
const char *file;
char **cdpathp; /* & of : separated list */
XString *xsp;
int *phys_pathp;
{ {
int rval = 0; int rval = 0;
int use_cdpath = 1; 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" * ie, simplify_path("/a/b/c/./../d/..") returns "/a/b"
*/ */
void void
simplify_path(char *pathx) simplify_path(pathx)
char *pathx;
{ {
char *cur; char *cur;
char *t; char *t;
@ -196,7 +199,8 @@ simplify_path(char *pathx)
void void
set_current_wd(char *pathx) set_current_wd(pathx)
char *pathx;
{ {
int len; int len;
char *p = pathx; char *p = pathx;
@ -215,7 +219,8 @@ set_current_wd(char *pathx)
#ifdef S_ISLNK #ifdef S_ISLNK
char * char *
get_phys_path(const char *pathx) get_phys_path(pathx)
const char *pathx;
{ {
XString xs; XString xs;
char *xp; char *xp;
@ -235,7 +240,10 @@ get_phys_path(const char *pathx)
} }
static char * 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; const char *p, *q;
int len, llen; int len, llen;
@ -288,7 +296,7 @@ do_phys_path(XString *xsp, char *xp, const char *pathx)
#ifdef TEST #ifdef TEST
main(int argc, char **argv) main(argc, argv)
{ {
int rv; int rv;
char *cp, cdpath[256], pwd[256], file[256], result[256]; char *cp, cdpath[256], pwd[256], file[256], result[256];
@ -308,4 +316,3 @@ main(int argc, char **argv)
} }
} }
#endif /* TEST */ #endif /* TEST */

View File

@ -296,4 +296,3 @@ extern int gettimeofday ARGS(( /* struct timeval *, struct timezone * */ ));
extern int setrlimit ARGS(( /* int, struct rlimit * */ )); extern int setrlimit ARGS(( /* int, struct rlimit * */ ));
extern int lstat ARGS(( /* const char *, struct stat * */ )); extern int lstat ARGS(( /* const char *, struct stat * */ ));
#endif #endif

View File

@ -733,4 +733,3 @@ EXTERN int x_cols I__(80); /* tty columns */
# undef EXTERN # undef EXTERN
#endif #endif
#undef I__ #undef I__

View File

@ -33,7 +33,11 @@ static int shf_emptybuf ARGS((struct shf *shf, int flags));
* fails. * fails.
*/ */
struct shf * 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; struct shf *shf;
int bsize = sflags & SHF_UNBUF ? (sflags & SHF_RD ? 1 : 0) : SHF_BSIZE; 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. */ /* Set up the shf structure for a file descriptor. Doesn't fail. */
struct shf * 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; 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 */ /* Set up an existing shf (and buffer) to use the given fd */
struct shf * 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; 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(). * When writing, a byte is reserved for a trailing null - see shf_sclose().
*/ */
struct shf * 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 */ /* can't have a read+write string */
if (!(sflags & (SHF_RD | SHF_WR)) 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 */ /* Flush and close file descriptor, free the shf structure */
int int
shf_close(struct shf *shf) shf_close(shf)
struct shf *shf;
{ {
int ret = 0; int ret = 0;
@ -222,7 +237,8 @@ shf_close(struct shf *shf)
/* Flush and close file descriptor, don't free file structure */ /* Flush and close file descriptor, don't free file structure */
int int
shf_fdclose(struct shf *shf) shf_fdclose(shf)
struct shf *shf;
{ {
int ret = 0; int ret = 0;
@ -244,7 +260,8 @@ shf_fdclose(struct shf *shf)
* (does not free string if it was allocated). * (does not free string if it was allocated).
*/ */
char * char *
shf_sclose(struct shf *shf) shf_sclose(shf)
struct shf *shf;
{ {
unsigned char *s = shf->buf; unsigned char *s = shf->buf;
@ -260,7 +277,8 @@ shf_sclose(struct shf *shf)
/* Flush and free file structure, don't close file descriptor */ /* Flush and free file structure, don't close file descriptor */
int int
shf_finish(struct shf *shf) shf_finish(shf)
struct shf *shf;
{ {
int ret = 0; int ret = 0;
@ -278,7 +296,8 @@ shf_finish(struct shf *shf)
* buffered. Returns 0 for success, EOF for (write) error. * buffered. Returns 0 for success, EOF for (write) error.
*/ */
int int
shf_flush(struct shf *shf) shf_flush(shf)
struct shf *shf;
{ {
if (shf->flags & SHF_STRING) if (shf->flags & SHF_STRING)
return (shf->flags & SHF_WR) ? EOF : 0; 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. * buffer. Returns 0 for success, EOF for (write) error.
*/ */
static int static int
shf_emptybuf(struct shf *shf, int flags) shf_emptybuf(shf, flags)
struct shf *shf;
int flags;
{ {
int ret = 0; 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. */ /* Fill up a read buffer. Returns EOF for a read error, 0 otherwise. */
static int static int
shf_fillbuf(struct shf *shf) shf_fillbuf(shf)
struct shf *shf;
{ {
if (shf->flags & SHF_STRING) if (shf->flags & SHF_STRING)
return 0; return 0;
@ -435,7 +457,10 @@ shf_fillbuf(struct shf *shf)
* buffer. Returns 0 for success, EOF otherwise. * buffer. Returns 0 for success, EOF otherwise.
*/ */
int 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) { if (shf->fd < 0) {
errno = EINVAL; errno = EINVAL;
@ -480,7 +505,10 @@ shf_seek(struct shf *shf, off_t where, int from)
* a read error occurred. * a read error occurred.
*/ */
int 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 orig_bsize = bsize;
int ncopy; 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. * end of file, returns a pointer to the null byte in buf otherwise.
*/ */
char * 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; unsigned char *end;
int ncopy; 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. */ /* Returns the char read. Returns EOF for error and end of file. */
int int
shf_getchar(struct shf *shf) shf_getchar(shf)
struct shf *shf;
{ {
if (!(shf->flags & SHF_RD)) if (!(shf->flags & SHF_RD))
internal_errorf(1, "shf_getchar: flags %x", shf->flags); 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. * successful, EOF if there is no room.
*/ */
int int
shf_ungetc(int c, struct shf *shf) shf_ungetc(c, shf)
int c;
struct shf *shf;
{ {
if (!(shf->flags & SHF_RD)) if (!(shf->flags & SHF_RD))
internal_errorf(1, "shf_ungetc: flags %x", shf->flags); 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. * the char could not be written.
*/ */
int int
shf_putchar(int c, struct shf *shf) shf_putchar(c, shf)
int c;
struct shf *shf;
{ {
if (!(shf->flags & SHF_WR)) if (!(shf->flags & SHF_WR))
internal_errorf(1, "shf_putchar: flags %x", shf->flags); 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. * the string could not be written.
*/ */
int int
shf_puts(const char *s, struct shf *shf) shf_puts(s, shf)
const char *s;
struct shf *shf;
{ {
if (!s) if (!s)
return EOF; 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. */ /* Write a buffer. Returns nbytes if successful, EOF if there is an error. */
int 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 orig_nbytes = nbytes;
int n; int n;
@ -724,7 +765,14 @@ shf_write(const char *buf, int nbytes, struct shf *shf)
} }
int int
#ifdef HAVE_PROTOTYPES
shf_fprintf(struct shf *shf, const char *fmt, ...) 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; va_list args;
int n; int n;
@ -737,7 +785,15 @@ shf_fprintf(struct shf *shf, const char *fmt, ...)
} }
int int
#ifdef HAVE_PROTOTYPES
shf_snprintf(char *buf, int bsize, const char *fmt, ...) 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; struct shf shf;
va_list args; va_list args;
@ -756,7 +812,13 @@ shf_snprintf(char *buf, int bsize, const char *fmt, ...)
} }
char * char *
#ifdef HAVE_PROTOTYPES
shf_smprintf(const char *fmt, ...) shf_smprintf(const char *fmt, ...)
#else
shf_smprintf(fmt, va_alist)
char *fmt;
va_dcl
#endif
{ {
struct shf shf; struct shf shf;
va_list args; va_list args;
@ -816,7 +878,8 @@ shf_smprintf(const char *fmt, ...)
#include <math.h> #include <math.h>
static double static double
my_ceil(double d) my_ceil(d)
double d;
{ {
double i; double i;
@ -825,7 +888,10 @@ my_ceil(double d)
#endif /* FP */ #endif /* FP */
int 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; char c, *s;
int UNINITIALIZED(tmp); int UNINITIALIZED(tmp);
@ -1234,4 +1300,3 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
return shf_error(shf) ? EOF : nwritten; return shf_error(shf) ? EOF : nwritten;
} }

View File

@ -85,4 +85,3 @@ char *shf_smprintf ARGS((const char *fmt, ...));
int shf_vfprintf ARGS((struct shf *, const char *fmt, va_list args)); int shf_vfprintf ARGS((struct shf *, const char *fmt, va_list args));
#endif /* SHF_H */ #endif /* SHF_H */

View File

@ -209,7 +209,9 @@ error must know what to implement with
int int
sigaction(int sig, struct sigaction *act, struct sigaction *oact) sigaction(sig, act, oact)
int sig;
struct sigaction *act, *oact;
{ {
handler_t oldh; handler_t oldh;
@ -259,7 +261,9 @@ sigaction(int sig, struct sigaction *act, struct sigaction *oact)
int int
sigaddset(sigset_t *mask, int sig) sigaddset(mask, sig)
sigset_t *mask;
int sig;
{ {
*mask |= sigmask(sig); *mask |= sigmask(sig);
return 0; return 0;
@ -268,7 +272,9 @@ sigaddset(sigset_t *mask, int sig)
#ifndef IS_KSH #ifndef IS_KSH
int int
sigdelset(sigset_t *mask, int sig) sigdelset(mask, sig)
sigset_t *mask;
int sig;
{ {
*mask &= ~(sigmask(sig)); *mask &= ~(sigmask(sig));
return 0; return 0;
@ -277,7 +283,8 @@ sigdelset(sigset_t *mask, int sig)
int int
sigemptyset(sigset_t *mask) sigemptyset(mask)
sigset_t *mask;
{ {
*mask = 0; *mask = 0;
return 0; return 0;
@ -286,7 +293,8 @@ sigemptyset(sigset_t *mask)
#ifndef IS_KSH #ifndef IS_KSH
int int
sigfillset(sigset_t *mask) sigfillset(mask)
sigset_t *mask;
{ {
*mask = ~0; *mask = ~0;
return 0; return 0;
@ -296,7 +304,9 @@ sigfillset(sigset_t *mask)
#ifndef IS_KSH #ifndef IS_KSH
int int
sigismember(sigset_t *mask, int sig) sigismember(mask, sig)
sigset_t *mask;
int sig;
{ {
return ((*mask) & sigmask(sig)); return ((*mask) & sigmask(sig));
} }
@ -305,7 +315,8 @@ sigismember(sigset_t *mask, int sig)
#ifndef IS_KSH #ifndef IS_KSH
int int
sigpending(sigset_t *set) sigpending(set)
sigset_t *set;
{ {
return 0; /* faking it! */ return 0; /* faking it! */
} }
@ -313,7 +324,9 @@ sigpending(sigset_t *set)
int int
sigprocmask(int how, sigset_t *set, sigset_t *oset) sigprocmask(how, set, oset)
int how;
sigset_t *set, *oset;
{ {
#ifdef USE_SIGSET #ifdef USE_SIGSET
register int i; register int i;
@ -377,7 +390,8 @@ sigprocmask(int how, sigset_t *set, sigset_t *oset)
int int
sigsuspend(sigset_t *mask) sigsuspend(mask)
sigset_t *mask;
{ {
#ifdef USE_SIGMASK #ifdef USE_SIGMASK
sigpause(*mask); sigpause(*mask);
@ -433,8 +447,9 @@ sigsuspend(sigset_t *mask)
*/ */
#ifndef IS_KSH #ifndef IS_KSH
handler_t handler_t Signal(sig, handler)
Signal(int sig, handler_t handler) int sig;
handler_t handler;
{ {
struct sigaction act, oact; struct sigaction act, oact;
@ -453,8 +468,9 @@ Signal(int sig, handler_t handler)
* ensure we avoid signal mayhem * ensure we avoid signal mayhem
*/ */
handler_t handler_t signal(sig, handler)
signal(int sig, handler_t handler) int sig;
handler_t handler;
{ {
return (Signal(sig, handler)); return (Signal(sig, handler));
} }
@ -468,4 +484,3 @@ signal(int sig, handler_t handler)
* comment-column:40 * comment-column:40
* End: * End:
*/ */

View File

@ -123,4 +123,3 @@ int sigsuspend ARGS(( sigset_t *mask ));
#endif #endif
#endif /* ! SA_NOCLDSTOP */ #endif /* ! SA_NOCLDSTOP */
#endif /* _SIGACT_H */ #endif /* _SIGACT_H */

View File

@ -67,7 +67,7 @@ static int symbol; /* yylex value */
((reject) ? (symbol) : (REJECT, symbol = yylex(cf))) ((reject) ? (symbol) : (REJECT, symbol = yylex(cf)))
static void static void
yyparse(void) yyparse()
{ {
int c; int c;
@ -82,7 +82,8 @@ yyparse(void)
} }
static struct op * static struct op *
pipeline(int cf) pipeline(cf)
int cf;
{ {
register struct op *t, *p, *tl = NULL; register struct op *t, *p, *tl = NULL;
@ -102,7 +103,7 @@ pipeline(int cf)
} }
static struct op * static struct op *
andor(void) andor()
{ {
register struct op *t, *p; register struct op *t, *p;
register int c; register int c;
@ -120,7 +121,8 @@ andor(void)
} }
static struct op * static struct op *
c_list(int multi) c_list(multi)
int multi;
{ {
register struct op *t = NULL, *p, *tl = NULL; register struct op *t = NULL, *p, *tl = NULL;
register int c; register int c;
@ -157,7 +159,8 @@ c_list(int multi)
} }
static struct ioword * static struct ioword *
synio(int cf) synio(cf)
int cf;
{ {
register struct ioword *iop; register struct ioword *iop;
int ishere; int ishere;
@ -181,14 +184,16 @@ synio(int cf)
} }
static void static void
musthave(int c, int cf) musthave(c, cf)
int c, cf;
{ {
if ((token(cf)) != c) if ((token(cf)) != c)
syntaxerr((char *) 0); syntaxerr((char *) 0);
} }
static struct op * static struct op *
nested(int type, int smark, int emark) nested(type, smark, emark)
int type, smark, emark;
{ {
register struct op *t; register struct op *t;
struct nesting_state old_nesting; struct nesting_state old_nesting;
@ -201,7 +206,8 @@ nested(int type, int smark, int emark)
} }
static struct op * static struct op *
get_command(int cf) get_command(cf)
int cf;
{ {
register struct op *t; register struct op *t;
register int c, iopn = 0, syniocf; register int c, iopn = 0, syniocf;
@ -417,7 +423,7 @@ get_command(int cf)
} }
static struct op * static struct op *
dogroup(void) dogroup()
{ {
register int c; register int c;
register struct op *list; register struct op *list;
@ -440,7 +446,7 @@ dogroup(void)
} }
static struct op * static struct op *
thenpart(void) thenpart()
{ {
register struct op *t; register struct op *t;
@ -454,7 +460,7 @@ thenpart(void)
} }
static struct op * static struct op *
elsepart(void) elsepart()
{ {
register struct op *t; register struct op *t;
@ -477,7 +483,7 @@ elsepart(void)
} }
static struct op * static struct op *
caselist(void) caselist()
{ {
register struct op *t, *tl; register struct op *t, *tl;
int c; int c;
@ -503,7 +509,8 @@ caselist(void)
} }
static struct op * static struct op *
casepart(int endtok) casepart(endtok)
int endtok;
{ {
register struct op *t; register struct op *t;
register int c; register int c;
@ -530,10 +537,10 @@ casepart(int endtok)
return (t); return (t);
} }
/* ksh_func - function foo { ... } vs foo() { .. } */
static struct op * 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; char *sname, *p;
struct op *t; struct op *t;
@ -592,7 +599,7 @@ function_body(char *name, int ksh_func)
} }
static char ** static char **
wordlist(void) wordlist()
{ {
register int c; register int c;
XPtrV args; XPtrV args;
@ -622,7 +629,10 @@ wordlist(void)
*/ */
static struct op * 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; register struct op *t;
@ -677,7 +687,7 @@ const struct tokeninfo {
}; };
void void
initkeywords(void) initkeywords()
{ {
register struct tokeninfo const *tt; register struct tokeninfo const *tt;
register struct tbl *p; register struct tbl *p;
@ -694,7 +704,8 @@ initkeywords(void)
} }
static void static void
syntaxerr(const char *what) syntaxerr(what)
const char *what;
{ {
char redir[6]; /* 2<<- is the longest redirection, I think */ char redir[6]; /* 2<<- is the longest redirection, I think */
const char *s; const char *s;
@ -746,7 +757,9 @@ syntaxerr(const char *what)
} }
static void static void
nesting_push(struct nesting_state *save, int tok) nesting_push(save, tok)
struct nesting_state *save;
int tok;
{ {
*save = nesting; *save = nesting;
nesting.start_token = tok; nesting.start_token = tok;
@ -754,13 +767,15 @@ nesting_push(struct nesting_state *save, int tok)
} }
static void static void
nesting_pop(struct nesting_state *saved) nesting_pop(saved)
struct nesting_state *saved;
{ {
nesting = *saved; nesting = *saved;
} }
static struct op * static struct op *
newtp(int type) newtp(type)
int type;
{ {
register struct op *t; register struct op *t;
@ -775,7 +790,8 @@ newtp(int type)
} }
struct op * struct op *
compile(Source *s) compile(s)
Source *s;
{ {
nesting.start_token = 0; nesting.start_token = 0;
nesting.start_line = 0; nesting.start_line = 0;
@ -796,7 +812,8 @@ compile(Source *s)
* $ * $
*/ */
static int static int
assign_command(char *s) assign_command(s)
char *s;
{ {
char c = *s; char c = *s;
@ -810,7 +827,8 @@ assign_command(char *s)
/* Check if we are in the middle of reading an alias */ /* Check if we are in the middle of reading an alias */
static int static int
inalias(struct source *s) inalias(s)
struct source *s;
{ {
for (; s && s->type == SALIAS; s = s->next) for (; s && s->type == SALIAS; s = s->next)
if (!(s->flags & SF_ALIASEND)) 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). * TM_UNOP and TM_BINOP, the returned value is a Test_op).
*/ */
static int 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 c = tpeek(ARRAYVAR | (meta == TM_BINOP ? 0 : CONTIN));
int uqword = 0; int uqword = 0;
@ -891,7 +911,10 @@ dbtestp_isa(Test_env *te, Test_meta meta)
} }
static const char * 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); int c = tpeek(ARRAYVAR);
@ -905,14 +928,21 @@ dbtestp_getopnd(Test_env *te, Test_op op, int do_eval)
} }
static int static int
dbtestp_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, dbtestp_eval(te, op, opnd1, opnd2, do_eval)
int do_eval) Test_env *te;
Test_op op;
const char *opnd1;
const char *opnd2;
int do_eval;
{ {
return 1; return 1;
} }
static void 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; te->flags |= TEF_ERROR;
@ -926,4 +956,3 @@ dbtestp_error(Test_env *te, int offset, const char *msg)
syntaxerr(msg); syntaxerr(msg);
} }
#endif /* KSH */ #endif /* KSH */

View File

@ -19,7 +19,8 @@ static int tnamecmp ARGS((void *p1, void *p2));
unsigned int unsigned int
hash(register const char *n) hash(n)
register const char * n;
{ {
register unsigned int h = 0; register unsigned int h = 0;
@ -29,7 +30,10 @@ hash(register const char *n)
} }
void 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->areap = ap;
tp->tbls = NULL; tp->tbls = NULL;
@ -39,7 +43,9 @@ tinit(register struct table *tp, register Area *ap, int tsize)
} }
static void static void
texpand(register struct table *tp, int nsize) texpand(tp, nsize)
register struct table *tp;
int nsize;
{ {
register int i; register int i;
register struct tbl *tblp, **p; register struct tbl *tblp, **p;
@ -72,13 +78,11 @@ texpand(register struct table *tp, int nsize)
afree((void*)otblp, tp->areap); afree((void*)otblp, tp->areap);
} }
/*
* tp - table
* n - name to enter
* h - hash(n)
*/
struct tbl * 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; register struct tbl **pp, *p;
@ -97,13 +101,11 @@ tsearch(register struct table *tp, register const char *n, unsigned int h)
return NULL; return NULL;
} }
/*
* tp - table
* n - name to enter
* h - hash(n)
*/
struct tbl * 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 struct tbl **pp, *p;
register int len; register int len;
@ -142,20 +144,24 @@ tenter(register struct table *tp, register const char *n, unsigned int h)
} }
void void
tdelete(register struct tbl *p) tdelete(p)
register struct tbl *p;
{ {
p->flag = 0; p->flag = 0;
} }
void void
twalk(struct tstate *ts, struct table *tp) twalk(ts, tp)
struct tstate *ts;
struct table *tp;
{ {
ts->left = tp->size; ts->left = tp->size;
ts->next = tp->tbls; ts->next = tp->tbls;
} }
struct tbl * struct tbl *
tnext(struct tstate *ts) tnext(ts)
struct tstate *ts;
{ {
while (--ts->left >= 0) { while (--ts->left >= 0) {
struct tbl *p = *ts->next++; struct tbl *p = *ts->next++;
@ -166,13 +172,15 @@ tnext(struct tstate *ts)
} }
static int static int
tnamecmp(void *p1, void *p2) tnamecmp(p1, p2)
void *p1, *p2;
{ {
return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name); return strcmp(((struct tbl *)p1)->name, ((struct tbl *)p2)->name);
} }
struct tbl ** struct tbl **
tsort(register struct table *tp) tsort(tp)
register struct table *tp;
{ {
register int i; register int i;
register struct tbl **p, **sp, **dp; register struct tbl **p, **sp, **dp;
@ -195,7 +203,8 @@ tsort(register struct table *tp)
void tprintinfo ARGS((struct table *tp)); void tprintinfo ARGS((struct table *tp));
void void
tprintinfo(struct table *tp) tprintinfo(tp)
struct table *tp;
{ {
struct tbl *te; struct tbl *te;
char *n; char *n;
@ -236,4 +245,3 @@ tprintinfo(struct table *tp)
(totncmp % nentries) * 100 / nentries); (totncmp % nentries) * 100 / nentries);
} }
#endif /* PERF_DEBUG */ #endif /* PERF_DEBUG */

View File

@ -179,4 +179,3 @@ EXTERN char *tmpdir; /* TMPDIR value */
EXTERN const char *prompt; EXTERN const char *prompt;
EXTERN int cur_prompt; /* PS1 or PS2 */ EXTERN int cur_prompt; /* PS1 or PS2 */
EXTERN int current_lineno; /* LINENO value */ EXTERN int current_lineno; /* LINENO value */

View File

@ -28,7 +28,7 @@ Trap sigtraps[SIGNALS+1] = {
static struct sigaction Sigact_ign, Sigact_trap; static struct sigaction Sigact_ign, Sigact_trap;
void void
inittraps(void) inittraps()
{ {
#ifdef HAVE_SYS_SIGLIST #ifdef HAVE_SYS_SIGLIST
# ifndef SYS_SIGLIST_DECLARED # ifndef SYS_SIGLIST_DECLARED
@ -65,7 +65,7 @@ inittraps(void)
static RETSIGTYPE alarm_catcher ARGS((int sig)); static RETSIGTYPE alarm_catcher ARGS((int sig));
void void
alarm_init(void) alarm_init()
{ {
sigtraps[SIGALRM].flags |= TF_SHELL_USES; sigtraps[SIGALRM].flags |= TF_SHELL_USES;
setsig(&sigtraps[SIGALRM], alarm_catcher, setsig(&sigtraps[SIGALRM], alarm_catcher,
@ -73,7 +73,8 @@ alarm_init(void)
} }
static RETSIGTYPE static RETSIGTYPE
alarm_catcher(int sig) alarm_catcher(sig)
int sig;
{ {
int errno_ = errno; int errno_ = errno;
@ -92,7 +93,9 @@ alarm_catcher(int sig)
#endif /* KSH */ #endif /* KSH */
Trap * Trap *
gettrap(const char *name, int igncase) gettrap(name, igncase)
const char *name;
int igncase;
{ {
int i; int i;
register Trap *p; register Trap *p;
@ -126,7 +129,8 @@ gettrap(const char *name, int igncase)
* trap signal handler * trap signal handler
*/ */
RETSIGTYPE RETSIGTYPE
trapsig(int i) trapsig(i)
int i;
{ {
Trap *p = &sigtraps[i]; Trap *p = &sigtraps[i];
int errno_ = errno; int errno_ = errno;
@ -152,7 +156,7 @@ trapsig(int i)
* work if user has trapped SIGINT. * work if user has trapped SIGINT.
*/ */
void void
intrcheck(void) intrcheck()
{ {
if (intrsig) if (intrsig)
runtraps(TF_DFL_INTR|TF_FATAL); runtraps(TF_DFL_INTR|TF_FATAL);
@ -162,7 +166,7 @@ intrcheck(void)
* termination has been received. * termination has been received.
*/ */
int int
fatal_trap_check(void) fatal_trap_check()
{ {
int i; int i;
Trap *p; Trap *p;
@ -180,7 +184,7 @@ fatal_trap_check(void)
* is set. * is set.
*/ */
int int
trap_pending(void) trap_pending()
{ {
int i; int i;
Trap *p; Trap *p;
@ -198,7 +202,8 @@ trap_pending(void)
* can interrupt commands. * can interrupt commands.
*/ */
void void
runtraps(int flag) runtraps(flag)
int flag;
{ {
int i; int i;
register Trap *p; register Trap *p;
@ -227,7 +232,8 @@ runtraps(int flag)
} }
void void
runtrap(Trap *p) runtrap(p)
Trap *p;
{ {
int i = p->signal; int i = p->signal;
char *trapstr = p->trap; char *trapstr = p->trap;
@ -273,7 +279,7 @@ runtrap(Trap *p)
/* clear pending traps and reset user's trap handlers; used after fork(2) */ /* clear pending traps and reset user's trap handlers; used after fork(2) */
void void
cleartraps(void) cleartraps()
{ {
int i; int i;
Trap *p; Trap *p;
@ -290,7 +296,7 @@ cleartraps(void)
/* restore signals just before an exec(2) */ /* restore signals just before an exec(2) */
void void
restoresigs(void) restoresigs()
{ {
int i; int i;
Trap *p; Trap *p;
@ -302,7 +308,9 @@ restoresigs(void)
} }
void void
settrap(Trap *p, char *s) settrap(p, s)
Trap *p;
char *s;
{ {
handler_t f; handler_t f;
@ -341,7 +349,7 @@ settrap(Trap *p, char *s)
* kill shell (unless user catches it and exits) * kill shell (unless user catches it and exits)
*/ */
int int
block_pipe(void) block_pipe()
{ {
int restore_dfl = 0; int restore_dfl = 0;
Trap *p = &sigtraps[SIGPIPE]; Trap *p = &sigtraps[SIGPIPE];
@ -359,7 +367,8 @@ block_pipe(void)
/* Called by c_print() to undo whatever block_pipe() did */ /* Called by c_print() to undo whatever block_pipe() did */
void void
restore_pipe(int restore_dfl) restore_pipe(restore_dfl)
int restore_dfl;
{ {
if (restore_dfl) if (restore_dfl)
setsig(&sigtraps[SIGPIPE], SIG_DFL, SS_RESTORE_CURR); setsig(&sigtraps[SIGPIPE], SIG_DFL, SS_RESTORE_CURR);
@ -370,7 +379,10 @@ restore_pipe(int restore_dfl)
* FTALKING. * FTALKING.
*/ */
int int
setsig(Trap *p, handler_t f, int flags) setsig(p, f, flags)
Trap *p;
handler_t f;
int flags;
{ {
struct sigaction sigact; struct sigaction sigact;
@ -421,7 +433,9 @@ setsig(Trap *p, handler_t f, int flags)
/* control what signal is set to before an exec() */ /* control what signal is set to before an exec() */
void void
setexecsig(Trap *p, int restore) setexecsig(p, restore)
Trap *p;
int restore;
{ {
/* XXX debugging */ /* XXX debugging */
if (!(p->flags & (TF_ORIG_IGN|TF_ORIG_DFL))) if (!(p->flags & (TF_ORIG_IGN|TF_ORIG_DFL)))
@ -444,4 +458,3 @@ setexecsig(Trap *p, int restore)
break; break;
} }
} }

View File

@ -28,7 +28,10 @@ static void iofree ARGS((struct ioword **iow, Area *ap));
*/ */
static void 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; register char **w;
struct ioword **ioact; struct ioword **ioact;
@ -212,7 +215,10 @@ ptree(register struct op *t, int indent, register struct shf *shf)
} }
static void 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 flag = iop->flag;
int type = flag & IOTYPE; int type = flag & IOTYPE;
@ -270,7 +276,9 @@ pioact(register struct shf *shf, int indent, register struct ioword *iop)
*/ */
static void 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 */ if ((c&0x60) == 0) { /* C0|C1 */
tputc((c&0x80) ? '$' : '^', shf); tputc((c&0x80) ? '$' : '^', shf);
@ -283,7 +291,9 @@ tputC(register int c, register struct shf *shf)
} }
static void 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; register int c, quoted=0;
@ -365,7 +375,15 @@ tputS(register char *wp, register struct shf *shf)
*/ */
/* VARARGS */ /* VARARGS */
int int
#ifdef HAVE_PROTOTYPES
fptreef(struct shf *shf, int indent, const char *fmt, ...) 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; va_list va;
@ -378,7 +396,15 @@ fptreef(struct shf *shf, int indent, const char *fmt, ...)
/* VARARGS */ /* VARARGS */
char * char *
#ifdef HAVE_PROTOTYPES
snptreef(char *s, int n, const char *fmt, ...) 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; va_list va;
struct shf shf; struct shf shf;
@ -393,8 +419,11 @@ snptreef(char *s, int n, const char *fmt, ...)
} }
static void static void
vfptreef(register struct shf *shf, int indent, const char *fmt, vfptreef(shf, indent, fmt, va)
register va_list va) register struct shf *shf;
int indent;
const char *fmt;
register va_list va;
{ {
register int c; register int c;
@ -462,7 +491,9 @@ vfptreef(register struct shf *shf, int indent, const char *fmt,
*/ */
struct op * struct op *
tcopy(register struct op *t, Area *ap) tcopy(t, ap)
register struct op *t;
Area *ap;
{ {
register struct op *r; register struct op *r;
register char **tw, **rw; register char **tw, **rw;
@ -511,7 +542,9 @@ tcopy(register struct op *t, Area *ap)
} }
char * char *
wdcopy(const char *wp, Area *ap) wdcopy(wp, ap)
const char *wp;
Area *ap;
{ {
size_t len = wdscan(wp, EOS) - wp; size_t len = wdscan(wp, EOS) - wp;
return memcpy(alloc(len, ap), wp, len); 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 */ /* return the position of prefix c in wp plus 1 */
char * char *
wdscan(register const char *wp, register int c) wdscan(wp, c)
register const char *wp;
register int c;
{ {
register int nest = 0; register int nest = 0;
@ -575,7 +610,8 @@ wdscan(register const char *wp, register int c)
* (string is allocated from ATEMP) * (string is allocated from ATEMP)
*/ */
char * char *
wdstrip(const char *wp) wdstrip(wp)
const char *wp;
{ {
struct shf shf; struct shf shf;
int c; int c;
@ -642,7 +678,9 @@ wdstrip(const char *wp)
} }
static struct ioword ** static struct ioword **
iocopy(register struct ioword **iow, Area *ap) iocopy(iow, ap)
register struct ioword **iow;
Area *ap;
{ {
register struct ioword **ior; register struct ioword **ior;
register int i; register int i;
@ -675,7 +713,9 @@ iocopy(register struct ioword **iow, Area *ap)
*/ */
void void
tfree(register struct op *t, Area *ap) tfree(t, ap)
register struct op *t;
Area *ap;
{ {
register char **w; register char **w;
@ -707,7 +747,9 @@ tfree(register struct op *t, Area *ap)
} }
static void static void
iofree(struct ioword **iow, Area *ap) iofree(iow, ap)
struct ioword **iow;
Area *ap;
{ {
register struct ioword **iop; register struct ioword **iop;
register struct ioword *p; register struct ioword *p;
@ -722,4 +764,3 @@ iofree(struct ioword **iow, Area *ap)
afree((void*)p, ap); afree((void*)p, ap);
} }
} }

View File

@ -140,4 +140,3 @@ struct ioword {
#define DB_AND 3 /* && -> -a conversion */ #define DB_AND 3 /* && -> -a conversion */
#define DB_BE 4 /* an inserted -BE */ #define DB_BE 4 /* an inserted -BE */
#define DB_PAT 5 /* a pattern argument */ #define DB_PAT 5 /* a pattern argument */

View File

@ -14,7 +14,9 @@ __RCSID("$NetBSD: tty.c,v 1.4 2003/06/23 11:39:06 agc Exp $");
#undef EXTERN #undef EXTERN
int int
get_tty(int fd, TTY_state *ts) get_tty(fd, ts)
int fd;
TTY_state *ts;
{ {
int ret; int ret;
@ -42,7 +44,10 @@ get_tty(int fd, TTY_state *ts)
} }
int 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; 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. * foreground job completion and for setting up tty process group.
*/ */
void void
tty_init(int init_ttystate) tty_init(init_ttystate)
int init_ttystate;
{ {
int do_close = 1; int do_close = 1;
int tfd; int tfd;
@ -172,11 +178,10 @@ tty_init(int init_ttystate)
} }
void void
tty_close(void) tty_close()
{ {
if (tty_fd >= 0) { if (tty_fd >= 0) {
close(tty_fd); close(tty_fd);
tty_fd = -1; tty_fd = -1;
} }
} }

View File

@ -108,4 +108,3 @@ extern void tty_close ARGS((void));
# undef EXTERN # undef EXTERN
#endif #endif
#undef I__ #undef I__

View File

@ -38,7 +38,7 @@ static struct tbl *arraysearch ARGS((struct tbl *, int));
* assume caller has allocated and set up e->loc * assume caller has allocated and set up e->loc
*/ */
void void
newblock(void) newblock()
{ {
register struct block *l; register struct block *l;
static char *const empty[] = {null}; static char *const empty[] = {null};
@ -64,7 +64,7 @@ newblock(void)
* pop a block handling special variables * pop a block handling special variables
*/ */
void void
popblock(void) popblock()
{ {
register struct block *l = e->loc; register struct block *l = e->loc;
register struct tbl *vp, **vpp = l->vars.tbls, *vq; register struct tbl *vp, **vpp = l->vars.tbls, *vq;
@ -87,7 +87,7 @@ popblock(void)
/* called by main() to initialize variable data structures */ /* called by main() to initialize variable data structures */
void void
initvar(void) initvar()
{ {
static const struct { static const struct {
const char *name; 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);
const char * 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; const char *p;
int len; 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. * Search for variable, if not found create globally.
*/ */
struct tbl * struct tbl *
global(register const char *n) global(n)
register const char *n;
{ {
register struct block *l = e->loc; register struct block *l = e->loc;
register struct tbl *vp; register struct tbl *vp;
@ -248,7 +252,9 @@ global(register const char *n)
* Search for local variable, if not found create locally. * Search for local variable, if not found create locally.
*/ */
struct tbl * 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 block *l = e->loc;
register struct tbl *vp; register struct tbl *vp;
@ -292,7 +298,8 @@ local(register const char *n, bool_t copy)
/* get variable string value */ /* get variable string value */
char * char *
str_val(register struct tbl *vp) str_val(vp)
register struct tbl *vp;
{ {
char *s; char *s;
@ -344,7 +351,8 @@ str_val(register struct tbl *vp)
/* get variable integer value, with error checking */ /* get variable integer value, with error checking */
long long
intval(register struct tbl *vp) intval(vp)
register struct tbl *vp;
{ {
long num; long num;
int base; int base;
@ -358,7 +366,10 @@ intval(register struct tbl *vp)
/* set variable to string value */ /* set variable to string value */
int 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; char *fs = NULL;
int no_ro_check = error_ok & 0x4; 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 */ /* set variable to integer */
void void
setint(register struct tbl *vq, long n) setint(vq, n)
register struct tbl *vq;
long n;
{ {
if (!(vq->flag&INTEGER)) { if (!(vq->flag&INTEGER)) {
register struct tbl *vp = &vtemp; register struct tbl *vp = &vtemp;
@ -420,7 +433,9 @@ setint(register struct tbl *vq, long n)
} }
int int
getint(struct tbl *vp, long *nump) getint(vp, nump)
struct tbl *vp;
long *nump;
{ {
register char *s; register char *s;
register int c; register int c;
@ -484,7 +499,8 @@ getint(struct tbl *vp, long *nump)
* (vq and vp may be the same) * (vq and vp may be the same)
*/ */
struct tbl * struct tbl *
setint_v(register struct tbl *vq, register struct tbl *vp) setint_v(vq, vp)
register struct tbl *vq, *vp;
{ {
int base; int base;
long num; long num;
@ -505,7 +521,9 @@ setint_v(register struct tbl *vq, register struct tbl *vp)
} }
static char * static char *
formatstr(struct tbl *vp, const char *s) formatstr(vp, s)
struct tbl *vp;
const char *s;
{ {
int olen, nlen; int olen, nlen;
char *p, *q; char *p, *q;
@ -567,7 +585,9 @@ formatstr(struct tbl *vp, const char *s)
* make vp->val.s be "name=value" for quick exporting. * make vp->val.s be "name=value" for quick exporting.
*/ */
static void static void
export(register struct tbl *vp, const char *val) export(vp, val)
register struct tbl *vp;
const char *val;
{ {
register char *xp; register char *xp;
char *op = (vp->flag&ALLOC) ? vp->val.s : NULL; 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. * LCASEV, UCASEV_AL), and optionally set its value if an assignment.
*/ */
struct tbl * 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; register struct tbl *vp;
struct tbl *vpbase, *t; 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]). * the name lookup (eg, x[2]).
*/ */
void void
unset(register struct tbl *vp, int array_ref) unset(vp, array_ref)
register struct tbl *vp;
int array_ref;
{ {
if (vp->flag & ALLOC) if (vp->flag & ALLOC)
afree((void*)vp->val.s, vp->areap); 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). * null if whole string is legal).
*/ */
char * char *
skip_varname(const char *s, int aok) skip_varname(s, aok)
const char *s;
int aok;
{ {
int alen; int alen;
@ -783,11 +810,11 @@ skip_varname(const char *s, int aok)
return (char *) __UNCONST(s); return (char *) __UNCONST(s);
} }
/* Return a pointer to the first character past any legal variable name. /* Return a pointer to the first character past any legal variable name. */
* aok - skip array de-reference?
*/
char * 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])) { if (s[0] == CHAR && letter(s[1])) {
do do
@ -818,7 +845,9 @@ skip_wdvarname(const char *s, int aok)
/* Check if coded string s is a variable name */ /* Check if coded string s is a variable name */
int int
is_wdvarname(const char *s, int aok) is_wdvarname(s, aok)
const char *s;
int aok;
{ {
char *p = skip_wdvarname(s, 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 */ /* Check if coded string s is a variable assignment */
int int
is_wdvarassign(const char *s) is_wdvarassign(s)
const char *s;
{ {
char *p = skip_wdvarname(s, TRUE); 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. * Make the exported environment from the exported names in the dictionary.
*/ */
char ** char **
makenv(void) makenv()
{ {
struct block *l = e->loc; struct block *l = e->loc;
XPtrV env; XPtrV env;
@ -880,7 +910,7 @@ makenv(void)
* if the parent doesn't use $RANDOM. * if the parent doesn't use $RANDOM.
*/ */
void void
change_random(void) change_random()
{ {
rand(); rand();
} }
@ -891,7 +921,8 @@ change_random(void)
/* Test if name is a special parameter */ /* Test if name is a special parameter */
static int static int
special(register const char *name) special(name)
register const char * name;
{ {
register struct tbl *tp; register struct tbl *tp;
@ -901,7 +932,8 @@ special(register const char *name)
/* Make a variable non-special */ /* Make a variable non-special */
static void static void
unspecial(register const char *name) unspecial(name)
register const char * name;
{ {
register struct tbl *tp; 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 int user_lineno; /* what user set $LINENO to */
static void static void
getspec(register struct tbl *vp) getspec(vp)
register struct tbl *vp;
{ {
switch (special(vp->name)) { switch (special(vp->name)) {
#ifdef KSH #ifdef KSH
@ -957,7 +990,8 @@ getspec(register struct tbl *vp)
} }
static void static void
setspec(register struct tbl *vp) setspec(vp)
register struct tbl *vp;
{ {
char *s; char *s;
@ -1057,7 +1091,8 @@ setspec(register struct tbl *vp)
} }
static void static void
unsetspec(register struct tbl *vp) unsetspec(vp)
register struct tbl *vp;
{ {
switch (special(vp->name)) { switch (special(vp->name)) {
case V_PATH: case V_PATH:
@ -1115,7 +1150,9 @@ unsetspec(register struct tbl *vp)
* vp, indexed by val. * vp, indexed by val.
*/ */
static struct tbl * static struct tbl *
arraysearch(struct tbl *vp, int val) arraysearch(vp, val)
struct tbl *vp;
int val;
{ {
struct tbl *prev, *curr, *new; struct tbl *prev, *curr, *new;
size_t namelen = strlen(vp->name) + 1; size_t namelen = strlen(vp->name) + 1;
@ -1159,7 +1196,8 @@ arraysearch(struct tbl *vp, int val)
* bracket. * bracket.
*/ */
int int
array_ref_len(const char *cp) array_ref_len(cp)
const char *cp;
{ {
const char *s = cp; const char *s = cp;
int c; int c;
@ -1177,7 +1215,8 @@ array_ref_len(const char *cp)
* Make a copy of the base of an array name * Make a copy of the base of an array name
*/ */
char * char *
arrayname(const char *str) arrayname(str)
const char *str;
{ {
const char *p; 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. /* Set (or overwrite, if !reset) the array variable var to the values in vals.
*/ */
void 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; struct tbl *vp, *vq;
int i; int i;
@ -1216,4 +1258,3 @@ set_array(const char *var, int reset, char **vals)
setstr(vq, vals[i], KSH_RETURN_ERROR); setstr(vq, vals[i], KSH_RETURN_ERROR);
} }
} }

View File

@ -14,4 +14,3 @@ __RCSID("$NetBSD: version.c,v 1.5 2005/06/26 19:09:00 christos Exp $");
char ksh_version [] = char ksh_version [] =
"@(#)PD KSH v5.2.14 99/07/13.2"; "@(#)PD KSH v5.2.14 99/07/13.2";

View File

@ -194,7 +194,9 @@ enum expand_mode { NONE, EXPAND, COMPLETE, PRINT };
static enum expand_mode expanded = NONE;/* last input was expanded */ static enum expand_mode expanded = NONE;/* last input was expanded */
int int
x_vi(char *buf, size_t len) x_vi(buf, len)
char *buf;
size_t len;
{ {
int c; int c;
@ -254,7 +256,8 @@ x_vi(char *buf, size_t len)
} }
static int static int
vi_hook(int ch) vi_hook(ch)
int ch;
{ {
static char curcmd[MAXVICMD]; static char curcmd[MAXVICMD];
static char locpat[SRCHLEN]; static char locpat[SRCHLEN];
@ -551,7 +554,9 @@ vi_hook(int ch)
} }
static void static void
vi_reset(char *buf, size_t len) vi_reset(buf, len)
char *buf;
size_t len;
{ {
state = VNORMAL; state = VNORMAL;
ohnum = hnum = hlast = histnum(-1) + 1; ohnum = hnum = hlast = histnum(-1) + 1;
@ -565,7 +570,8 @@ vi_reset(char *buf, size_t len)
} }
static int static int
nextstate(int ch) nextstate(ch)
int ch;
{ {
if (is_extend(ch)) if (is_extend(ch))
return VEXTCMD; return VEXTCMD;
@ -584,7 +590,8 @@ nextstate(int ch)
} }
static int static int
vi_insert(int ch) vi_insert(ch)
int ch;
{ {
int tcursor; int tcursor;
@ -716,7 +723,9 @@ vi_insert(int ch)
} }
static int static int
vi_cmd(int argcnt, const char *cmd) vi_cmd(argcnt, cmd)
int argcnt;
const char *cmd;
{ {
int ncursor; int ncursor;
int cur, c1, c2, c3 = 0; int cur, c1, c2, c3 = 0;
@ -1167,7 +1176,10 @@ vi_cmd(int argcnt, const char *cmd)
} }
static int 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 bcount, UNINITIALIZED(i), t;
int UNINITIALIZED(ncursor); int UNINITIALIZED(ncursor);
@ -1314,7 +1326,8 @@ domove(int argcnt, const char *cmd, int sub)
} }
static int static int
redo_insert(int count) redo_insert(count)
int count;
{ {
while (count-- > 0) while (count-- > 0)
if (putbuf(ibuf, inslen, insert==REPLACE) != 0) if (putbuf(ibuf, inslen, insert==REPLACE) != 0)
@ -1326,7 +1339,8 @@ redo_insert(int count)
} }
static void static void
yank_range(int a, int b) yank_range(a, b)
int a, b;
{ {
yanklen = b - a; yanklen = b - a;
if (yanklen != 0) if (yanklen != 0)
@ -1334,7 +1348,8 @@ yank_range(int a, int b)
} }
static int static int
bracktype(int ch) bracktype(ch)
int ch;
{ {
switch (ch) { switch (ch) {
@ -1379,7 +1394,7 @@ static char holdbuf[CMDLEN]; /* place to hold last edit buffer */
static int holdlen; /* length of holdbuf */ static int holdlen; /* length of holdbuf */
static void static void
save_cbuf(void) save_cbuf()
{ {
memmove(holdbuf, es->cbuf, es->linelen); memmove(holdbuf, es->cbuf, es->linelen);
holdlen = es->linelen; holdlen = es->linelen;
@ -1387,7 +1402,7 @@ save_cbuf(void)
} }
static void static void
restore_cbuf(void) restore_cbuf()
{ {
es->cursor = 0; es->cursor = 0;
es->linelen = holdlen; es->linelen = holdlen;
@ -1396,7 +1411,8 @@ restore_cbuf(void)
/* return a new edstate */ /* return a new edstate */
static struct edstate * static struct edstate *
save_edstate(struct edstate *old) save_edstate(old)
struct edstate *old;
{ {
struct edstate *new; struct edstate *new;
@ -1411,7 +1427,8 @@ save_edstate(struct edstate *old)
} }
static void 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); memcpy(new->cbuf, old->cbuf, old->linelen);
new->linelen = old->linelen; new->linelen = old->linelen;
@ -1421,7 +1438,8 @@ restore_edstate(struct edstate *new, struct edstate *old)
} }
static void static void
free_edstate(struct edstate *old) free_edstate(old)
struct edstate *old;
{ {
afree(old->cbuf, APERM); afree(old->cbuf, APERM);
afree((char *)old, APERM); afree((char *)old, APERM);
@ -1430,7 +1448,9 @@ free_edstate(struct edstate *old)
static void static void
edit_reset(char *buf, size_t len) edit_reset(buf, len)
char *buf;
size_t len;
{ {
const char *p; const char *p;
@ -1470,13 +1490,18 @@ edit_reset(char *buf, size_t len)
* this is used for calling x_escape() in complete_word() * this is used for calling x_escape() in complete_word()
*/ */
static int 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); return putbuf(s, len, 0);
} }
static int static int
putbuf(const char *buf, int len, int repl) putbuf(buf, len, repl)
const char *buf;
int len;
int repl;
{ {
if (len == 0) if (len == 0)
return 0; return 0;
@ -1498,7 +1523,8 @@ putbuf(const char *buf, int len, int repl)
} }
static void static void
del_range(int a, int b) del_range(a, b)
int a, b;
{ {
if (es->linelen != b) if (es->linelen != b)
memmove(&es->cbuf[a], &es->cbuf[b], 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 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; int ncursor;
@ -1535,6 +1565,7 @@ findch(int ch, int cnt, int forw, int incl)
static int static int
forwword(argcnt) forwword(argcnt)
int argcnt;
{ {
int ncursor; int ncursor;
@ -1556,7 +1587,8 @@ forwword(argcnt)
} }
static int static int
backword(int argcnt) backword(argcnt)
int argcnt;
{ {
int ncursor; int ncursor;
@ -1581,7 +1613,8 @@ backword(int argcnt)
} }
static int static int
endword(int argcnt) endword(argcnt)
int argcnt;
{ {
int ncursor; int ncursor;
@ -1607,7 +1640,8 @@ endword(int argcnt)
} }
static int static int
Forwword(int argcnt) Forwword(argcnt)
int argcnt;
{ {
int ncursor; int ncursor;
@ -1622,7 +1656,8 @@ Forwword(int argcnt)
} }
static int static int
Backword(int argcnt) Backword(argcnt)
int argcnt;
{ {
int ncursor; int ncursor;
@ -1638,7 +1673,8 @@ Backword(int argcnt)
} }
static int static int
Endword(int argcnt) Endword(argcnt)
int argcnt;
{ {
int ncursor; int ncursor;
@ -1658,7 +1694,9 @@ Endword(int argcnt)
} }
static int static int
grabhist(int save, int n) grabhist(save, n)
int save;
int n;
{ {
char *hptr; char *hptr;
@ -1685,7 +1723,9 @@ grabhist(int save, int n)
} }
static int static int
grabsearch(int save, int start, int fwd, char *pat) grabsearch(save, start, fwd, pat)
int save, start, fwd;
char *pat;
{ {
char *hptr; char *hptr;
int hist; int hist;
@ -1719,7 +1759,8 @@ grabsearch(int save, int start, int fwd, char *pat)
} }
static void static void
redraw_line(int newlinex) redraw_line(newlinex)
int newlinex;
{ {
(void) memset(wbuf[win], ' ', wbuf_len); (void) memset(wbuf[win], ' ', wbuf_len);
if (newlinex) { if (newlinex) {
@ -1732,7 +1773,8 @@ redraw_line(int newlinex)
} }
static void static void
refresh(int leftside) refresh(leftside)
int leftside;
{ {
if (leftside < 0) if (leftside < 0)
leftside = lastref; leftside = lastref;
@ -1745,7 +1787,7 @@ refresh(int leftside)
} }
static int static int
outofwin(void) outofwin()
{ {
int cur, col; int cur, col;
@ -1761,7 +1803,7 @@ outofwin(void)
} }
static void static void
rewindow(void) rewindow()
{ {
register int tcur, tcol; register int tcur, tcol;
int holdcur1, holdcol1; int holdcur1, holdcol1;
@ -1785,7 +1827,8 @@ rewindow(void)
} }
static int static int
newcol(int ch, int col) newcol(ch, col)
int ch, col;
{ {
if (ch == '\t') if (ch == '\t')
return (col | 7) + 1; return (col | 7) + 1;
@ -1793,7 +1836,9 @@ newcol(int ch, int col)
} }
static void static void
display(char *wb1, char *wb2, int leftside) display(wb1, wb2, leftside)
char *wb1, *wb2;
int leftside;
{ {
unsigned char ch; unsigned char ch;
char *twb1, *twb2, mc; char *twb1, *twb2, mc;
@ -1886,7 +1931,9 @@ display(char *wb1, char *wb2, int leftside)
} }
static void static void
ed_mov_opt(int col, char *wb) ed_mov_opt(col, wb)
int col;
char *wb;
{ {
if (col < cur_col) { if (col < cur_col) {
if (col + 1 < cur_col - 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*) */ /* replace word with all expansions (ie, expand word*) */
static int static int
expand_word(int commandx) expand_word(commandx)
int commandx;
{ {
static struct edstate *buf; static struct edstate *buf;
int rval = 0; int rval = 0;
@ -1964,7 +2012,9 @@ expand_word(int commandx)
} }
static int static int
complete_word(int commandx, int count) complete_word(commandx, count)
int commandx;
int count;
{ {
static struct edstate *buf; static struct edstate *buf;
int rval = 0; int rval = 0;
@ -2071,7 +2121,9 @@ complete_word(int commandx, int count)
} }
static int static int
print_expansions(struct edstate *ex, int commandx) print_expansions(ex, commandx)
struct edstate *ex;
int commandx;
{ {
int nwords; int nwords;
int start, end; int start, end;
@ -2093,7 +2145,8 @@ print_expansions(struct edstate *ex, int commandx)
/* How long is char when displayed (not counting tabs) */ /* How long is char when displayed (not counting tabs) */
static int static int
char_len(int c) char_len(c)
int c;
{ {
int len = 1; int len = 1;
@ -2108,7 +2161,8 @@ char_len(int c)
/* Similar to x_zotc(emacs.c), but no tab weirdness */ /* Similar to x_zotc(emacs.c), but no tab weirdness */
static void static void
x_vi_zotc(int c) x_vi_zotc(c)
int c;
{ {
if (Flag(FVISHOW8) && (c & 0x80)) { if (Flag(FVISHOW8) && (c & 0x80)) {
x_puts("M-"); x_puts("M-");
@ -2122,13 +2176,14 @@ x_vi_zotc(int c)
} }
static void static void
vi_pprompt(int full) vi_pprompt(full)
int full;
{ {
pprompt(prompt + (full ? 0 : prompt_skip), prompt_trunc); pprompt(prompt + (full ? 0 : prompt_skip), prompt_trunc);
} }
static void static void
vi_error(void) vi_error()
{ {
/* Beem out of any macros as soon as an error occurs */ /* Beem out of any macros as soon as an error occurs */
vi_macro_reset(); vi_macro_reset();
@ -2137,7 +2192,7 @@ vi_error(void)
} }
static void static void
vi_macro_reset(void) vi_macro_reset()
{ {
if (macro.p) { if (macro.p) {
afree(macro.buf, APERM); afree(macro.buf, APERM);
@ -2146,4 +2201,3 @@ vi_macro_reset(void)
} }
#endif /* VI */ #endif /* VI */