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

This was stated in Minix3 wishlist.
This commit is contained in:
Santurysim 2021-03-27 09:31:23 +03:00
parent 4db99f4012
commit e47e5f1694
45 changed files with 652 additions and 1456 deletions

View File

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

View File

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

View File

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

View File

@ -53,3 +53,4 @@ Test_op test_isop ARGS((Test_env *te, Test_meta meta, const char *s));
int test_eval ARGS((Test_env *te, Test_op op, const char *opnd1,
const char *opnd2, int do_eval));
int test_parse ARGS((Test_env *te));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -131,3 +131,4 @@ EXTERN char **histlist; /* saved commands */
EXTERN char **histptr; /* last history item */
EXTERN int histsize; /* history size */
#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));
void
mcheck()
mcheck(void)
{
register mbox_t *mbp;
time_t now;
@ -87,15 +87,13 @@ mcheck()
}
void
mcset(interval)
long interval;
mcset(long interval)
{
mailcheck_interval = interval;
}
void
mbset(p)
register char *p;
mbset(register char *p)
{
struct stat stbuf;
@ -113,8 +111,7 @@ mbset(p)
}
void
mpset(mptoparse)
register char *mptoparse;
mpset(register char *mptoparse)
{
register mbox_t *mbp;
register char *mpath, *mmsg, *mval;
@ -153,8 +150,7 @@ mpset(mptoparse)
}
static void
munset(mlist)
register mbox_t *mlist;
munset(register mbox_t *mlist)
{
register mbox_t *mbp;
@ -168,9 +164,7 @@ register mbox_t *mlist;
}
static mbox_t *
mballoc(p, m)
char *p;
char *m;
mballoc(char *p, char *m)
{
struct stat stbuf;
register mbox_t *mbp;
@ -187,8 +181,7 @@ mballoc(p, m)
}
static void
mprintit( mbp )
mbox_t *mbp;
mprintit(mbox_t *mbp)
{
struct tbl *vp;
@ -200,3 +193,4 @@ mbox_t *mbp;
unset(vp, 0);
}
#endif /* KSH */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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