diff options
62 files changed, 780 insertions, 1412 deletions
diff --git a/bin/sh/alias.c b/bin/sh/alias.c index 3d6d8a1..b899edb 100644 --- a/bin/sh/alias.c +++ b/bin/sh/alias.c @@ -56,14 +56,13 @@ static const char rcsid[] = struct alias *atab[ATABSIZE]; -STATIC void setalias __P((char *, char *)); -STATIC int unalias __P((char *)); -STATIC struct alias **hashalias __P((char *)); +STATIC void setalias(char *, char *); +STATIC int unalias(char *); +STATIC struct alias **hashalias(char *); STATIC void -setalias(name, val) - char *name, *val; +setalias(char *name, char *val) { struct alias *ap, **app; @@ -116,9 +115,8 @@ setalias(name, val) } STATIC int -unalias(name) - char *name; - { +unalias(char *name) +{ struct alias *ap, **app; app = hashalias(name); @@ -158,7 +156,8 @@ SHELLPROC { #endif void -rmaliases() { +rmaliases(void) +{ struct alias *ap, *tmp; int i; @@ -178,9 +177,7 @@ rmaliases() { } struct alias * -lookupalias(name, check) - char *name; - int check; +lookupalias(char *name, int check) { struct alias *ap = *hashalias(name); @@ -199,9 +196,7 @@ lookupalias(name, check) * TODO - sort output */ int -aliascmd(argc, argv) - int argc; - char **argv; +aliascmd(int argc, char **argv) { char *n, *v; int ret = 0; @@ -234,9 +229,7 @@ aliascmd(argc, argv) } int -unaliascmd(argc, argv) - int argc __unused; - char **argv __unused; +unaliascmd(int argc __unused, char **argv __unused) { int i; @@ -253,9 +246,8 @@ unaliascmd(argc, argv) } STATIC struct alias ** -hashalias(p) - char *p; - { +hashalias(char *p) +{ unsigned int hashval; hashval = *p << 4; diff --git a/bin/sh/alias.h b/bin/sh/alias.h index a282a69..a5879ef 100644 --- a/bin/sh/alias.h +++ b/bin/sh/alias.h @@ -46,7 +46,7 @@ struct alias { int flag; }; -struct alias *lookupalias __P((char *, int)); -int aliascmd __P((int, char **)); -int unaliascmd __P((int, char **)); -void rmaliases __P((void)); +struct alias *lookupalias(char *, int); +int aliascmd(int, char **); +int unaliascmd(int, char **); +void rmaliases(void); diff --git a/bin/sh/arith.h b/bin/sh/arith.h index c58cd3c..ba8134e 100644 --- a/bin/sh/arith.h +++ b/bin/sh/arith.h @@ -34,5 +34,5 @@ * $FreeBSD$ */ -int arith __P((char *)); -int expcmd __P((int , char **)); +int arith(char *); +int expcmd(int , char **); diff --git a/bin/sh/arith.y b/bin/sh/arith.y index c565e51..8438e09 100644 --- a/bin/sh/arith.y +++ b/bin/sh/arith.y @@ -105,12 +105,11 @@ static const char rcsid[] = char *arith_buf, *arith_startbuf; extern void arith_lex_reset(); -int yylex __P((void)); -int yyparse __P((void)); +int yylex(void); +int yyparse(void); int -arith(s) - char *s; +arith(char *s) { long result; @@ -125,8 +124,7 @@ arith(s) } void -yyerror(s) - char *s; +yyerror(char *s) { yyerrok; @@ -139,9 +137,7 @@ yyerror(s) * The exp(1) builtin. */ int -expcmd(argc, argv) - int argc; - char **argv; +expcmd(int argc, char **argv) { char *p; char *concat; @@ -178,13 +174,12 @@ expcmd(argc, argv) /*************************/ #ifdef TEST_ARITH #include <stdio.h> -main(argc, argv) - char *argv[]; +main(int argc, char *argv[]) { printf("%d\n", exp(argv[1])); } -error(s) - char *s; + +error(char *s) { fprintf(stderr, "exp: %s\n", s); exit(1); diff --git a/bin/sh/arith_lex.l b/bin/sh/arith_lex.l index 82cd40f..e1ad222 100644 --- a/bin/sh/arith_lex.l +++ b/bin/sh/arith_lex.l @@ -83,6 +83,7 @@ extern char *arith_buf, *arith_startbuf; %% void -arith_lex_reset() { +arith_lex_reset() +{ YY_NEW_FILE; } diff --git a/bin/sh/bltin/bltin.h b/bin/sh/bltin/bltin.h index 5d2b02a..9d6e68d 100644 --- a/bin/sh/bltin/bltin.h +++ b/bin/sh/bltin/bltin.h @@ -83,13 +83,8 @@ #define INITARGS(argv) if ((commandname = argv[0]) == NULL) {fputs("Argc is zero\n", stderr); exit(2);} else #endif -#ifdef __STDC__ pointer stalloc(int); void error(const char *, ...) __printf0like(1, 2); -#else -pointer stalloc(); -void error(); -#endif extern char *commandname; diff --git a/bin/sh/bltin/echo.c b/bin/sh/bltin/echo.c index 850a811..ef82dc6 100644 --- a/bin/sh/bltin/echo.c +++ b/bin/sh/bltin/echo.c @@ -48,9 +48,7 @@ /* #define eflag 1 */ int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { char **ap; char *p; diff --git a/bin/sh/cd.c b/bin/sh/cd.c index bc2f718..03eb462 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -67,18 +67,16 @@ static const char rcsid[] = #include "show.h" #include "cd.h" -STATIC int docd __P((char *, int)); -STATIC char *getcomponent __P((void)); -STATIC void updatepwd __P((char *)); +STATIC int docd(char *, int); +STATIC char *getcomponent(void); +STATIC void updatepwd(char *); char *curdir = NULL; /* current working directory */ char *prevdir; /* previous working directory */ STATIC char *cdcomppath; int -cdcmd(argc, argv) - int argc __unused; - char **argv __unused; +cdcmd(int argc __unused, char **argv __unused) { char *dest; char *path; @@ -126,9 +124,7 @@ cdcmd(argc, argv) * directory name if "print" is nonzero. */ STATIC int -docd(dest, print) - char *dest; - int print; +docd(char *dest, int print) { char *p; char *q; @@ -191,7 +187,7 @@ docd(dest, print) * This routine overwrites the string pointed to by cdcomppath. */ STATIC char * -getcomponent() +getcomponent(void) { char *p; char *start; @@ -217,8 +213,7 @@ getcomponent() * that the current directory has changed. */ STATIC void -updatepwd(dir) - char *dir; +updatepwd(char *dir) { char *new; char *p; @@ -277,9 +272,7 @@ updatepwd(dir) int -pwdcmd(argc, argv) - int argc __unused; - char **argv __unused; +pwdcmd(int argc __unused, char **argv __unused) { if (!getpwd()) error("getcwd() failed: %s", strerror(errno)); @@ -298,7 +291,7 @@ pwdcmd(argc, argv) * directory, this routine returns immediately. */ char * -getpwd() +getpwd(void) { char buf[MAXPWD]; diff --git a/bin/sh/cd.h b/bin/sh/cd.h index 078b40e..043d405 100644 --- a/bin/sh/cd.h +++ b/bin/sh/cd.h @@ -33,6 +33,6 @@ * $FreeBSD$ */ -char *getpwd __P((void)); -int cdcmd __P((int, char **)); -int pwdcmd __P((int, char **)); +char *getpwd(void); +int cdcmd (int, char **); +int pwdcmd(int, char **); diff --git a/bin/sh/error.c b/bin/sh/error.c index 088d3c7..fd25a95 100644 --- a/bin/sh/error.c +++ b/bin/sh/error.c @@ -71,7 +71,7 @@ volatile sig_atomic_t intpending; char *commandname; -static void exverror __P((int, const char *, va_list)) __printf0like(2, 0); +static void exverror(int, const char *, va_list) __printf0like(2, 0); /* * Called to raise an exception. Since C doesn't include exceptions, we @@ -80,8 +80,7 @@ static void exverror __P((int, const char *, va_list)) __printf0like(2, 0); */ void -exraise(e) - int e; +exraise(int e) { if (handler == NULL) abort(); @@ -101,7 +100,8 @@ exraise(e) */ void -onint() { +onint(void) +{ sigset_t sigset; /* @@ -140,10 +140,7 @@ onint() { * formatting. It then raises the error exception. */ static void -exverror(cond, msg, ap) - int cond; - const char *msg; - va_list ap; +exverror(int cond, const char *msg, va_list ap) { CLEAR_PENDING_INT; INTOFF; @@ -165,51 +162,21 @@ exverror(cond, msg, ap) } -#ifdef __STDC__ void error(const char *msg, ...) -#else -void -error(va_alist) - va_dcl -#endif { -#ifndef __STDC__ - const char *msg; -#endif va_list ap; -#ifdef __STDC__ va_start(ap, msg); -#else - va_start(ap); - msg = va_arg(ap, char *); -#endif exverror(EXERROR, msg, ap); va_end(ap); } -#ifdef __STDC__ void exerror(int cond, const char *msg, ...) -#else -void -exerror(va_alist) - va_dcl -#endif { -#ifndef __STDC__ - int cond; - char *msg; -#endif va_list ap; -#ifdef __STDC__ va_start(ap, msg); -#else - va_start(ap); - cond = va_arg(ap, int); - msg = va_arg(ap, char *); -#endif exverror(cond, msg, ap); va_end(ap); } @@ -291,9 +258,7 @@ STATIC const struct errname errormsg[] = { */ char * -errmsg(e, action) - int e; - int action; +errmsg(int e, int action) { struct errname const *ep; static char buf[12]; diff --git a/bin/sh/error.h b/bin/sh/error.h index 938ef91..d4ff7bc 100644 --- a/bin/sh/error.h +++ b/bin/sh/error.h @@ -89,11 +89,11 @@ extern volatile sig_atomic_t intpending; #define CLEAR_PENDING_INT intpending = 0 #define int_pending() intpending -void exraise __P((int)); -void onint __P((void)); -void error __P((const char *, ...)) __printf0like(1, 2); -void exerror __P((int, const char *, ...)) __printf0like(2, 3); -char *errmsg __P((int, int)); +void exraise(int); +void onint(void); +void error(const char *, ...) __printf0like(1, 2); +void exerror(int, const char *, ...) __printf0like(2, 3); +char *errmsg(int, int); /* diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 3ea2626..9f65d90 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -92,14 +92,14 @@ int exitstatus; /* exit status of last command */ int oexitstatus; /* saved exit status */ -STATIC void evalloop __P((union node *)); -STATIC void evalfor __P((union node *)); -STATIC void evalcase __P((union node *, int)); -STATIC void evalsubshell __P((union node *, int)); -STATIC void expredir __P((union node *)); -STATIC void evalpipe __P((union node *)); -STATIC void evalcommand __P((union node *, int, struct backcmd *)); -STATIC void prehash __P((union node *)); +STATIC void evalloop(union node *); +STATIC void evalfor(union node *); +STATIC void evalcase(union node *, int); +STATIC void evalsubshell(union node *, int); +STATIC void expredir(union node *); +STATIC void evalpipe(union node *); +STATIC void evalcommand(union node *, int, struct backcmd *); +STATIC void prehash(union node *); /* @@ -127,9 +127,7 @@ SHELLPROC { */ int -evalcmd(argc, argv) - int argc; - char **argv; +evalcmd(int argc, char **argv) { char *p; char *concat; @@ -161,9 +159,8 @@ evalcmd(argc, argv) */ void -evalstring(s) - char *s; - { +evalstring(char *s) +{ union node *n; struct stackmark smark; @@ -185,9 +182,7 @@ evalstring(s) */ void -evaltree(n, flags) - union node *n; - int flags; +evaltree(union node *n, int flags) { if (n == NULL) { TRACE(("evaltree(NULL) called\n")); @@ -305,8 +300,7 @@ out: STATIC void -evalloop(n) - union node *n; +evalloop(union node *n) { int status; @@ -342,8 +336,7 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) { STATIC void -evalfor(n) - union node *n; +evalfor(union node *n) { struct arglist arglist; union node *argp; @@ -383,9 +376,7 @@ out: STATIC void -evalcase(n, flags) - union node *n; - int flags; +evalcase(union node *n, int flags) { union node *cp; union node *patp; @@ -417,9 +408,7 @@ out: */ STATIC void -evalsubshell(n, flags) - union node *n; - int flags; +evalsubshell(union node *n, int flags) { struct job *jp; int backgnd = (n->type == NBACKGND); @@ -446,8 +435,7 @@ evalsubshell(n, flags) */ STATIC void -expredir(n) - union node *n; +expredir(union node *n) { union node *redir; @@ -484,8 +472,7 @@ expredir(n) */ STATIC void -evalpipe(n) - union node *n; +evalpipe(union node *n) { struct job *jp; struct nodelist *lp; @@ -551,9 +538,7 @@ evalpipe(n) */ void -evalbackcmd(n, result) - union node *n; - struct backcmd *result; +evalbackcmd(union node *n, struct backcmd *result) { int pip[2]; struct job *jp; @@ -603,10 +588,7 @@ out: */ STATIC void -evalcommand(cmd, flags, backcmd) - union node *cmd; - int flags; - struct backcmd *backcmd; +evalcommand(union node *cmd, int flags, struct backcmd *backcmd) { struct stackmark smark; union node *argp; @@ -944,8 +926,7 @@ out: */ STATIC void -prehash(n) - union node *n; +prehash(union node *n) { struct cmdentry entry; @@ -968,9 +949,7 @@ prehash(n) */ int -bltincmd(argc, argv) - int argc __unused; - char **argv __unused; +bltincmd(int argc __unused, char **argv __unused) { listsetvar(cmdenviron); /* @@ -993,9 +972,7 @@ bltincmd(argc, argv) */ int -breakcmd(argc, argv) - int argc; - char **argv; +breakcmd(int argc, char **argv) { int n = argc > 1 ? number(argv[1]) : 1; @@ -1014,9 +991,7 @@ breakcmd(argc, argv) */ int -returncmd(argc, argv) - int argc; - char **argv; +returncmd(int argc, char **argv) { int ret = argc > 1 ? number(argv[1]) : oexitstatus; @@ -1033,27 +1008,21 @@ returncmd(argc, argv) int -falsecmd(argc, argv) - int argc __unused; - char **argv __unused; +falsecmd(int argc __unused, char **argv __unused) { return 1; } int -truecmd(argc, argv) - int argc __unused; - char **argv __unused; +truecmd(int argc __unused, char **argv __unused) { return 0; } int -execcmd(argc, argv) - int argc; - char **argv; +execcmd(int argc, char **argv) { if (argc > 1) { struct strlist *sp; diff --git a/bin/sh/eval.h b/bin/sh/eval.h index 4f0b898..77dbbab 100644 --- a/bin/sh/eval.h +++ b/bin/sh/eval.h @@ -49,17 +49,17 @@ struct backcmd { /* result of evalbackcmd */ struct job *jp; /* job structure for command */ }; -int evalcmd __P((int, char **)); -void evalstring __P((char *)); +int evalcmd(int, char **); +void evalstring(char *); union node; /* BLETCH for ansi C */ -void evaltree __P((union node *, int)); -void evalbackcmd __P((union node *, struct backcmd *)); -int bltincmd __P((int, char **)); -int breakcmd __P((int, char **)); -int returncmd __P((int, char **)); -int falsecmd __P((int, char **)); -int truecmd __P((int, char **)); -int execcmd __P((int, char **)); +void evaltree(union node *, int); +void evalbackcmd(union node *, struct backcmd *); +int bltincmd(int, char **); +int breakcmd(int, char **); +int returncmd(int, char **); +int falsecmd(int, char **); +int truecmd(int, char **); +int execcmd(int, char **); /* in_function returns nonzero if we are currently evaluating a function */ #define in_function() funcnest diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 714ac36..e4948fe 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -99,13 +99,13 @@ STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */ int exerrno = 0; /* Last exec error */ -STATIC void tryexec __P((char *, char **, char **)); +STATIC void tryexec(char *, char **, char **); #ifndef BSD -STATIC void execinterp __P((char **, char **)); +STATIC void execinterp(char **, char **); #endif -STATIC void printentry __P((struct tblentry *, int)); -STATIC struct tblentry *cmdlookup __P((char *, int)); -STATIC void delete_cmd_entry __P((void)); +STATIC void printentry(struct tblentry *, int); +STATIC struct tblentry *cmdlookup(char *, int); +STATIC void delete_cmd_entry(void); @@ -115,10 +115,7 @@ STATIC void delete_cmd_entry __P((void)); */ void -shellexec(argv, envp, path, index) - char **argv, **envp; - char *path; - int index; +shellexec(char **argv, char **envp, char *path, int index) { char *cmdname; int e; @@ -155,11 +152,8 @@ shellexec(argv, envp, path, index) STATIC void -tryexec(cmd, argv, envp) - char *cmd; - char **argv; - char **envp; - { +tryexec(char *cmd, char **argv, char **envp) +{ int e; #ifndef BSD char *p; @@ -207,9 +201,8 @@ tryexec(cmd, argv, envp) #define NEWARGS 5 STATIC void -execinterp(argv, envp) - char **argv, **envp; - { +execinterp(char **argv, char **envp) +{ int n; char *inp; char *outp; @@ -285,10 +278,8 @@ break2:; char *pathopt; char * -padvance(path, name) - char **path; - char *name; - { +padvance(char **path, char *name) +{ char *p, *q; char *start; int len; @@ -325,9 +316,7 @@ padvance(path, name) int -hashcmd(argc, argv) - int argc __unused; - char **argv __unused; +hashcmd(int argc __unused, char **argv __unused) { struct tblentry **pp; struct tblentry *cmdp; @@ -372,10 +361,8 @@ hashcmd(argc, argv) STATIC void -printentry(cmdp, verbose) - struct tblentry *cmdp; - int verbose; - { +printentry(struct tblentry *cmdp, int verbose) +{ int index; char *path; char *name; @@ -418,11 +405,7 @@ printentry(cmdp, verbose) */ void -find_command(name, entry, printerr, path) - char *name; - struct cmdentry *entry; - int printerr; - char *path; +find_command(char *name, struct cmdentry *entry, int printerr, char *path) { struct tblentry *cmdp; int index; @@ -553,8 +536,7 @@ success: */ int -find_builtin(name) - char *name; +find_builtin(char *name) { const struct builtincmd *bp; @@ -573,7 +555,8 @@ find_builtin(name) */ void -hashcd() { +hashcd(void) +{ struct tblentry **pp; struct tblentry *cmdp; @@ -595,8 +578,7 @@ hashcd() { */ void -changepath(newval) - const char *newval; +changepath(const char *newval) { const char *old, *new; int index; @@ -640,8 +622,7 @@ changepath(newval) */ void -clearcmdentry(firstchange) - int firstchange; +clearcmdentry(int firstchange) { struct tblentry **tblp; struct tblentry **pp; @@ -679,7 +660,8 @@ SHELLPROC { #endif void -deletefuncs() { +deletefuncs(void) +{ struct tblentry **tblp; struct tblentry **pp; struct tblentry *cmdp; @@ -714,9 +696,7 @@ struct tblentry **lastcmdentry; STATIC struct tblentry * -cmdlookup(name, add) - char *name; - int add; +cmdlookup(char *name, int add) { int hashval; char *p; @@ -753,7 +733,8 @@ cmdlookup(name, add) */ STATIC void -delete_cmd_entry() { +delete_cmd_entry(void) +{ struct tblentry *cmdp; INTOFF; @@ -765,35 +746,14 @@ delete_cmd_entry() { -#ifdef notdef -void -getcmdentry(name, entry) - char *name; - struct cmdentry *entry; - { - struct tblentry *cmdp = cmdlookup(name, 0); - - if (cmdp) { - entry->u = cmdp->param; - entry->cmdtype = cmdp->cmdtype; - } else { - entry->cmdtype = CMDUNKNOWN; - entry->u.index = 0; - } -} -#endif - - /* * Add a new command entry, replacing any existing command entry for * the same name. */ void -addcmdentry(name, entry) - char *name; - struct cmdentry *entry; - { +addcmdentry(char *name, struct cmdentry *entry) +{ struct tblentry *cmdp; INTOFF; @@ -812,10 +772,8 @@ addcmdentry(name, entry) */ void -defun(name, func) - char *name; - union node *func; - { +defun(char *name, union node *func) +{ struct cmdentry entry; INTOFF; @@ -831,9 +789,8 @@ defun(name, func) */ int -unsetfunc(name) - char *name; - { +unsetfunc(char *name) +{ struct tblentry *cmdp; if ((cmdp = cmdlookup(name, 0)) != NULL && cmdp->cmdtype == CMDFUNCTION) { @@ -849,9 +806,7 @@ unsetfunc(name) */ int -typecmd(argc, argv) - int argc; - char **argv; +typecmd(int argc, char **argv) { struct cmdentry entry; struct tblentry *cmdp; diff --git a/bin/sh/exec.h b/bin/sh/exec.h index bb593f0..2d4743c 100644 --- a/bin/sh/exec.h +++ b/bin/sh/exec.h @@ -56,17 +56,17 @@ struct cmdentry { extern char *pathopt; /* set by padvance */ extern int exerrno; /* last exec error */ -void shellexec __P((char **, char **, char *, int)); -char *padvance __P((char **, char *)); -int hashcmd __P((int, char **)); -void find_command __P((char *, struct cmdentry *, int, char *)); -int find_builtin __P((char *)); -void hashcd __P((void)); -void changepath __P((const char *)); -void deletefuncs __P((void)); -void getcmdentry __P((char *, struct cmdentry *)); -void addcmdentry __P((char *, struct cmdentry *)); -void defun __P((char *, union node *)); -int unsetfunc __P((char *)); -int typecmd __P((int, char **)); -void clearcmdentry __P((int)); +void shellexec(char **, char **, char *, int); +char *padvance(char **, char *); +int hashcmd(int, char **); +void find_command(char *, struct cmdentry *, int, char *); +int find_builtin(char *); +void hashcd(void); +void changepath(const char *); +void deletefuncs(void); +void getcmdentry(char *, struct cmdentry *); +void addcmdentry(char *, struct cmdentry *); +void defun(char *, union node *); +int unsetfunc(char *); +int typecmd(int, char **); +void clearcmdentry(int); diff --git a/bin/sh/expand.c b/bin/sh/expand.c index 8d62830..f6a0a09 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -95,27 +95,27 @@ struct ifsregion ifsfirst; /* first struct in list of ifs regions */ struct ifsregion *ifslastp; /* last struct in list */ struct arglist exparg; /* holds expanded arg list */ -STATIC void argstr __P((char *, int)); -STATIC char *exptilde __P((char *, int)); -STATIC void expbackq __P((union node *, int, int)); -STATIC int subevalvar __P((char *, char *, int, int, int, int)); -STATIC char *evalvar __P((char *, int)); -STATIC int varisset __P((char *, int)); -STATIC void varvalue __P((char *, int, int)); -STATIC void recordregion __P((int, int, int)); -STATIC void removerecordregions __P((int)); -STATIC void ifsbreakup __P((char *, struct arglist *)); -STATIC void expandmeta __P((struct strlist *, int)); -STATIC void expmeta __P((char *, char *)); -STATIC void addfname __P((char *)); -STATIC struct strlist *expsort __P((struct strlist *)); -STATIC struct strlist *msort __P((struct strlist *, int)); -STATIC int pmatch __P((char *, char *, int)); -STATIC char *cvtnum __P((int, char *)); -STATIC int collate_range_cmp __P((int, int)); - -STATIC int collate_range_cmp (c1, c2) - int c1, c2; +STATIC void argstr(char *, int); +STATIC char *exptilde(char *, int); +STATIC void expbackq(union node *, int, int); +STATIC int subevalvar(char *, char *, int, int, int, int); +STATIC char *evalvar(char *, int); +STATIC int varisset(char *, int); +STATIC void varvalue(char *, int, int); +STATIC void recordregion(int, int, int); +STATIC void removerecordregions(int); +STATIC void ifsbreakup(char *, struct arglist *); +STATIC void expandmeta(struct strlist *, int); +STATIC void expmeta(char *, char *); +STATIC void addfname(char *); +STATIC struct strlist *expsort(struct strlist *); +STATIC struct strlist *msort(struct strlist *, int); +STATIC int pmatch(char *, char *, int); +STATIC char *cvtnum(int, char *); +STATIC int collate_range_cmp(int, int); + +STATIC int +collate_range_cmp (int c1, int c2) { static char s1[2], s2[2]; int ret; @@ -133,13 +133,13 @@ STATIC int collate_range_cmp (c1, c2) /* * Expand shell variables and backquotes inside a here document. + * union node *arg the document + * int fd; where to write the expanded version */ void -expandhere(arg, fd) - union node *arg; /* the document */ - int fd; /* where to write the expanded version */ - { +expandhere(union node *arg, int fd) +{ herefd = fd; expandarg(arg, (struct arglist *)NULL, 0); xwrite(fd, stackblock(), expdest - stackblock()); @@ -154,10 +154,7 @@ expandhere(arg, fd) */ void -expandarg(arg, arglist, flag) - union node *arg; - struct arglist *arglist; - int flag; +expandarg(union node *arg, struct arglist *arglist, int flag) { struct strlist *sp; char *p; @@ -213,9 +210,7 @@ expandarg(arg, arglist, flag) */ STATIC void -argstr(p, flag) - char *p; - int flag; +argstr(char *p, int flag) { char c; int quotes = flag & (EXP_FULL | EXP_CASE); /* do CTLESC */ @@ -277,9 +272,7 @@ breakloop:; } STATIC char * -exptilde(p, flag) - char *p; - int flag; +exptilde(char *p, int flag) { char c, *startp = p; struct passwd *pw; @@ -327,8 +320,7 @@ lose: STATIC void -removerecordregions(endoff) - int endoff; +removerecordregions(int endoff) { if (ifslastp == NULL) return; @@ -371,8 +363,7 @@ removerecordregions(endoff) * evaluate, place result in (backed up) result, adjust string position. */ void -expari(flag) - int flag; +expari(int flag) { char *p, *start; int result; @@ -431,10 +422,7 @@ expari(flag) */ STATIC void -expbackq(cmd, quoted, flag) - union node *cmd; - int quoted; - int flag; +expbackq(union node *cmd, int quoted, int flag) { struct backcmd in; int i; @@ -507,13 +495,8 @@ expbackq(cmd, quoted, flag) STATIC int -subevalvar(p, str, strloc, subtype, startloc, varflags) - char *p; - char *str; - int strloc; - int subtype; - int startloc; - int varflags; +subevalvar(char *p, char *str, int strloc, int subtype, int startloc, + int varflags) { char *startp; char *loc = NULL; @@ -638,9 +621,7 @@ recordleft: */ STATIC char * -evalvar(p, flag) - char *p; - int flag; +evalvar(char *p, int flag) { int subtype; int varflags; @@ -804,9 +785,7 @@ record: */ STATIC int -varisset(name, nulok) - char *name; - int nulok; +varisset(char *name, int nulok) { if (*name == '!') @@ -848,10 +827,7 @@ varisset(name, nulok) */ STATIC void -varvalue(name, quoted, allow_split) - char *name; - int quoted; - int allow_split; +varvalue(char *name, int quoted, int allow_split) { int num; char *p; @@ -942,10 +918,7 @@ numvar: */ STATIC void -recordregion(start, end, nulonly) - int start; - int end; - int nulonly; +recordregion(int start, int end, int nulonly) { struct ifsregion *ifsp; @@ -970,10 +943,8 @@ recordregion(start, end, nulonly) * searched for IFS characters have been stored by recordregion. */ STATIC void -ifsbreakup(string, arglist) - char *string; - struct arglist *arglist; - { +ifsbreakup(char *string, struct arglist *arglist) +{ struct ifsregion *ifsp; struct strlist *sp; char *start; @@ -1068,9 +1039,7 @@ char *expdir; STATIC void -expandmeta(str, flag) - struct strlist *str; - int flag __unused; +expandmeta(struct strlist *str, int flag __unused) { char *p; struct strlist **savelastp; @@ -1124,10 +1093,8 @@ nometa: */ STATIC void -expmeta(enddir, name) - char *enddir; - char *name; - { +expmeta(char *enddir, char *name) +{ char *p; char *q; char *start; @@ -1255,9 +1222,8 @@ expmeta(enddir, name) */ STATIC void -addfname(name) - char *name; - { +addfname(char *name) +{ char *p; struct strlist *sp; @@ -1277,9 +1243,8 @@ addfname(name) */ STATIC struct strlist * -expsort(str) - struct strlist *str; - { +expsort(struct strlist *str) +{ int len; struct strlist *sp; @@ -1291,9 +1256,7 @@ expsort(str) STATIC struct strlist * -msort(list, len) - struct strlist *list; - int len; +msort(struct strlist *list, int len) { struct strlist *p, *q = NULL; struct strlist **lpp; @@ -1339,11 +1302,8 @@ msort(list, len) */ int -patmatch(pattern, string, squoted) - char *pattern; - char *string; - int squoted; /* string might have quote chars */ - { +patmatch(char *pattern, char *string, int squoted) +{ #ifdef notdef if (pattern[0] == '!' && pattern[1] == '!') return 1 - pmatch(pattern + 2, string); @@ -1354,11 +1314,8 @@ patmatch(pattern, string, squoted) STATIC int -pmatch(pattern, string, squoted) - char *pattern; - char *string; - int squoted; - { +pmatch(char *pattern, char *string, int squoted) +{ char *p, *q; char c; @@ -1482,8 +1439,7 @@ breakloop: */ void -rmescapes(str) - char *str; +rmescapes(char *str) { char *p, *q; @@ -1512,10 +1468,8 @@ rmescapes(str) */ int -casematch(pattern, val) - union node *pattern; - char *val; - { +casematch(union node *pattern, char *val) +{ struct stackmark smark; int result; char *p; @@ -1537,10 +1491,8 @@ casematch(pattern, val) */ STATIC char * -cvtnum(num, buf) - int num; - char *buf; - { +cvtnum(int num, char *buf) +{ char temp[32]; int neg = num < 0; char *p = temp + 31; diff --git a/bin/sh/expand.h b/bin/sh/expand.h index 955b8bf..0fbd52a 100644 --- a/bin/sh/expand.h +++ b/bin/sh/expand.h @@ -59,9 +59,9 @@ struct arglist { union node; -void expandhere __P((union node *, int)); -void expandarg __P((union node *, struct arglist *, int)); -void expari __P((int)); -int patmatch __P((char *, char *, int)); -void rmescapes __P((char *)); -int casematch __P((union node *, char *)); +void expandhere(union node *, int); +void expandarg(union node *, struct arglist *, int); +void expari(int); +int patmatch(char *, char *, int); +void rmescapes(char *); +int casematch(union node *, char *); diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index 55cf73b..453c9a6 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -72,14 +72,14 @@ EditLine *el; /* editline cookie */ int displayhist; static FILE *el_in, *el_out, *el_err; -STATIC char *fc_replace __P((const char *, char *, char *)); +STATIC char *fc_replace(const char *, char *, char *); /* * Set history and editing status. Called whenever the status may * have changed (figures out what to do). */ void -histedit() +histedit(void) { #define editing (Eflag || Vflag) @@ -168,9 +168,7 @@ sethistsize(hs) * the Korn shell fc command. Oh well... */ int -histcmd(argc, argv) - int argc; - char **argv; +histcmd(int argc, char **argv) { int ch; char *editor = NULL; @@ -395,9 +393,7 @@ histcmd(argc, argv) } STATIC char * -fc_replace(s, p, r) - const char *s; - char *p, *r; +fc_replace(const char *s, char *p, char *r) { char *dest; int plen = strlen(p); @@ -419,8 +415,7 @@ fc_replace(s, p, r) } int -not_fcnumber(s) - char *s; +not_fcnumber(char *s) { if (s == NULL) return (0); @@ -430,9 +425,7 @@ not_fcnumber(s) } int -str_to_event(str, last) - char *str; - int last; +str_to_event(char *str, int last) { HistEvent he; char *s = str; @@ -482,9 +475,7 @@ str_to_event(str, last) #include "error.h" int -histcmd(argc, argv) - int argc; - char **argv; +histcmd(int argc, char **argv) { error("not compiled with history support"); diff --git a/bin/sh/init.h b/bin/sh/init.h index 366b8a3..57359dd 100644 --- a/bin/sh/init.h +++ b/bin/sh/init.h @@ -37,6 +37,6 @@ * $FreeBSD$ */ -void init __P((void)); -void reset __P((void)); -void initshellproc __P((void)); +void init(void); +void reset(void); +void initshellproc(void); diff --git a/bin/sh/input.c b/bin/sh/input.c index 4532b26..b1b9e79 100644 --- a/bin/sh/input.c +++ b/bin/sh/input.c @@ -107,8 +107,8 @@ int whichprompt; /* 1 == PS1, 2 == PS2 */ EditLine *el; /* cookie for editline package */ -STATIC void pushfile __P((void)); -static int preadfd __P((void)); +STATIC void pushfile(void); +static int preadfd(void); #ifdef mkinit INCLUDE "input.h" @@ -137,9 +137,7 @@ SHELLPROC { */ char * -pfgets(line, len) - char *line; - int len; +pfgets(char *line, int len) { char *p = line; int nleft = len; @@ -168,14 +166,14 @@ pfgets(line, len) */ int -pgetc() +pgetc(void) { return pgetc_macro(); } static int -preadfd() +preadfd(void) { int nr; parsenextc = parsefile->buf; @@ -227,7 +225,7 @@ retry: */ int -preadbuffer() +preadbuffer(void) { char *p, *q; int more; @@ -316,7 +314,8 @@ check: */ void -pungetc() { +pungetc(void) +{ parsenleft++; parsenextc--; } @@ -326,11 +325,8 @@ pungetc() { * We handle aliases this way. */ void -pushstring(s, len, ap) - char *s; - int len; - void *ap; - { +pushstring(char *s, int len, void *ap) +{ struct strpush *sp; INTOFF; @@ -353,7 +349,7 @@ pushstring(s, len, ap) } void -popstring() +popstring(void) { struct strpush *sp = parsefile->strpush; @@ -376,9 +372,7 @@ popstring() */ void -setinputfile(fname, push) - char *fname; - int push; +setinputfile(char *fname, int push) { int fd; int fd2; @@ -404,8 +398,7 @@ setinputfile(fname, push) */ void -setinputfd(fd, push) - int fd, push; +setinputfd(int fd, int push) { (void)fcntl(fd, F_SETFD, FD_CLOEXEC); if (push) { @@ -427,10 +420,8 @@ setinputfd(fd, push) */ void -setinputstring(string, push) - char *string; - int push; - { +setinputstring(char *string, int push) +{ INTOFF; if (push) pushfile(); @@ -449,7 +440,8 @@ setinputstring(string, push) */ STATIC void -pushfile() { +pushfile(void) +{ struct parsefile *pf; parsefile->nleft = parsenleft; @@ -466,7 +458,8 @@ pushfile() { void -popfile() { +popfile(void) +{ struct parsefile *pf = parsefile; INTOFF; @@ -491,7 +484,8 @@ popfile() { */ void -popallfiles() { +popallfiles(void) +{ while (parsefile != &basepf) popfile(); } @@ -504,7 +498,8 @@ popallfiles() { */ void -closescript() { +closescript(void) +{ popallfiles(); if (parsefile->fd > 0) { close(parsefile->fd); diff --git a/bin/sh/input.h b/bin/sh/input.h index 16d7244..bab05c4 100644 --- a/bin/sh/input.h +++ b/bin/sh/input.h @@ -49,17 +49,17 @@ extern int parsenleft; /* number of characters left in input buffer */ extern char *parsenextc; /* next character in input buffer */ extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */ -char *pfgets __P((char *, int)); -int pgetc __P((void)); -int preadbuffer __P((void)); -void pungetc __P((void)); -void pushstring __P((char *, int, void *)); -void popstring __P((void)); -void setinputfile __P((char *, int)); -void setinputfd __P((int, int)); -void setinputstring __P((char *, int)); -void popfile __P((void)); -void popallfiles __P((void)); -void closescript __P((void)); +char *pfgets(char *, int); +int pgetc(void); +int preadbuffer(void); +void pungetc(void); +void pushstring(char *, int, void *); +void popstring(void); +void setinputfile(char *, int); +void setinputfd(int, int); +void setinputstring(char *, int); +void popfile(void); +void popallfiles(void); +void closescript(void); #define pgetc_macro() (--parsenleft >= 0? *parsenextc++ : preadbuffer()) diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 96cc963..14f1909 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -93,17 +93,17 @@ int in_dowait = 0; /* are we in dowait()? */ volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */ #if JOBS -STATIC void restartjob __P((struct job *)); +STATIC void restartjob(struct job *); #endif -STATIC void freejob __P((struct job *)); -STATIC struct job *getjob __P((char *)); -STATIC int dowait __P((int, struct job *)); +STATIC void freejob(struct job *); +STATIC struct job *getjob(char *); +STATIC int dowait(int, struct job *); #if SYSV -STATIC int onsigchild __P((void)); +STATIC int onsigchild(void); #endif -STATIC int waitproc __P((int, int *)); -STATIC void cmdtxt __P((union node *)); -STATIC void cmdputs __P((char *)); +STATIC int waitproc(int, int *); +STATIC void cmdtxt(union node *); +STATIC void cmdputs(char *); /* @@ -118,8 +118,7 @@ MKINIT int jobctl; #if JOBS void -setjobctl(on) - int on; +setjobctl(int on) { #ifdef OLD_TTY_DRIVER int ldisc; @@ -195,9 +194,7 @@ SHELLPROC { #if JOBS int -fgcmd(argc, argv) - int argc __unused; - char **argv; +fgcmd(int argc __unused, char **argv) { struct job *jp; int pgrp; @@ -221,9 +218,7 @@ fgcmd(argc, argv) int -bgcmd(argc, argv) - int argc; - char **argv; +bgcmd(int argc, char **argv) { struct job *jp; @@ -238,8 +233,7 @@ bgcmd(argc, argv) STATIC void -restartjob(jp) - struct job *jp; +restartjob(struct job *jp) { struct procstat *ps; int i; @@ -260,9 +254,7 @@ restartjob(jp) int -jobscmd(argc, argv) - int argc __unused; - char **argv __unused; +jobscmd(int argc __unused, char **argv __unused) { showjobs(0); return 0; @@ -279,8 +271,7 @@ jobscmd(argc, argv) */ void -showjobs(change) - int change; +showjobs(int change) { int jobno; int procno; @@ -352,9 +343,8 @@ showjobs(change) */ STATIC void -freejob(jp) - struct job *jp; - { +freejob(struct job *jp) +{ struct procstat *ps; int i; @@ -376,9 +366,7 @@ freejob(jp) int -waitcmd(argc, argv) - int argc; - char **argv; +waitcmd(int argc, char **argv) { struct job *job; int status, retval; @@ -432,9 +420,7 @@ waitcmd(argc, argv) int -jobidcmd(argc, argv) - int argc __unused; - char **argv; +jobidcmd(int argc __unused, char **argv) { struct job *jp; int i; @@ -454,9 +440,8 @@ jobidcmd(argc, argv) */ STATIC struct job * -getjob(name) - char *name; - { +getjob(char *name) +{ int jobno; struct job *jp; int pid; @@ -514,9 +499,7 @@ currentjob: */ struct job * -makejob(node, nprocs) - union node *node __unused; - int nprocs; +makejob(union node *node __unused, int nprocs) { int i; struct job *jp; @@ -580,10 +563,7 @@ makejob(node, nprocs) */ int -forkshell(jp, n, mode) - union node *n; - struct job *jp; - int mode; +forkshell(struct job *jp, union node *n, int mode) { int pid; int pgrp; @@ -705,9 +685,7 @@ forkshell(jp, n, mode) */ int -waitforjob(jp, origstatus) - struct job *jp; - int *origstatus; +waitforjob(struct job *jp, int *origstatus) { #if JOBS int mypgrp = getpgrp(); @@ -764,9 +742,7 @@ waitforjob(jp, origstatus) */ STATIC int -dowait(block, job) - int block; - struct job *job; +dowait(int block, struct job *job) { int pid; int status; @@ -906,9 +882,7 @@ STATIC int onsigchild() { STATIC int -waitproc(block, status) - int block; - int *status; +waitproc(int block, int *status) { #ifdef BSD int flags; @@ -946,7 +920,7 @@ waitproc(block, status) */ int job_warning = 0; int -stoppedjobs() +stoppedjobs(void) { int jobno; struct job *jp; @@ -976,9 +950,8 @@ STATIC int cmdnleft; #define MAXCMDTEXT 200 char * -commandtext(n) - union node *n; - { +commandtext(union node *n) +{ char *name; cmdnextc = name = ckmalloc(MAXCMDTEXT); @@ -990,9 +963,8 @@ commandtext(n) STATIC void -cmdtxt(n) - union node *n; - { +cmdtxt(union node *n) +{ union node *np; struct nodelist *lp; char *p; @@ -1119,9 +1091,8 @@ redir: STATIC void -cmdputs(s) - char *s; - { +cmdputs(char *s) +{ char *p, *q; char c; int subtype = 0; diff --git a/bin/sh/jobs.h b/bin/sh/jobs.h index e8274b0..e73c930 100644 --- a/bin/sh/jobs.h +++ b/bin/sh/jobs.h @@ -82,18 +82,18 @@ extern int in_waitcmd; /* are we in waitcmd()? */ extern int in_dowait; /* are we in dowait()? */ extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */ -void setjobctl __P((int)); -int fgcmd __P((int, char **)); -int bgcmd __P((int, char **)); -int jobscmd __P((int, char **)); -void showjobs __P((int)); -int waitcmd __P((int, char **)); -int jobidcmd __P((int, char **)); -struct job *makejob __P((union node *, int)); -int forkshell __P((struct job *, union node *, int)); -int waitforjob __P((struct job *, int *)); -int stoppedjobs __P((void)); -char *commandtext __P((union node *)); +void setjobctl(int); +int fgcmd(int, char **); +int bgcmd(int, char **); +int jobscmd(int, char **); +void showjobs(int); +int waitcmd(int, char **); +int jobidcmd(int, char **); +struct job *makejob(union node *, int); +int forkshell(struct job *, union node *, int); +int waitforjob(struct job *, int *); +int stoppedjobs(void); +char *commandtext(union node *); #if ! JOBS #define setjobctl(on) /* do nothing */ diff --git a/bin/sh/mail.c b/bin/sh/mail.c index 5403515..1b3594f 100644 --- a/bin/sh/mail.c +++ b/bin/sh/mail.c @@ -72,8 +72,7 @@ STATIC time_t mailtime[MAXMBOXES]; /* times of mailboxes */ */ void -chkmail(silent) - int silent; +chkmail(int silent) { int i; char *mpath; diff --git a/bin/sh/mail.h b/bin/sh/mail.h index 319796b..a77029c 100644 --- a/bin/sh/mail.h +++ b/bin/sh/mail.h @@ -37,4 +37,4 @@ * $FreeBSD$ */ -void chkmail __P((int)); +void chkmail(int); diff --git a/bin/sh/main.c b/bin/sh/main.c index 7d00586..595c212 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -86,8 +86,8 @@ short profile_buf[16384]; extern int etext(); #endif -STATIC void read_profile __P((char *)); -STATIC char *find_dot_file __P((char *)); +STATIC void read_profile(char *); +STATIC char *find_dot_file(char *); /* * Main routine. We initialize things, parse the arguments, execute @@ -98,9 +98,7 @@ STATIC char *find_dot_file __P((char *)); */ int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { struct jmploc jmploc; struct stackmark smark; @@ -216,8 +214,7 @@ state4: /* XXX ??? - why isn't this before the "if" statement */ */ void -cmdloop(top) - int top; +cmdloop(int top) { union node *n; struct stackmark smark; @@ -269,9 +266,8 @@ cmdloop(top) */ STATIC void -read_profile(name) - char *name; - { +read_profile(char *name) +{ int fd; INTOFF; @@ -291,8 +287,7 @@ read_profile(name) */ void -readcmdfile(name) - char *name; +readcmdfile(char *name) { int fd; @@ -315,8 +310,7 @@ readcmdfile(name) STATIC char * -find_dot_file(basename) - char *basename; +find_dot_file(char *basename) { static char localname[FILENAME_MAX+1]; char *fullname; @@ -337,9 +331,7 @@ find_dot_file(basename) } int -dotcmd(argc, argv) - int argc; - char **argv; +dotcmd(int argc, char **argv) { struct strlist *sp; exitstatus = 0; @@ -360,9 +352,7 @@ dotcmd(argc, argv) int -exitcmd(argc, argv) - int argc; - char **argv; +exitcmd(int argc, char **argv) { extern int oexitstatus; @@ -376,15 +366,3 @@ exitcmd(argc, argv) /*NOTREACHED*/ return 0; } - - -#ifdef notdef -/* - * Should never be called. - */ - -void -exit(exitstatus) { - _exit(exitstatus); -} -#endif diff --git a/bin/sh/main.h b/bin/sh/main.h index 3dc3dd7..b1d06ef 100644 --- a/bin/sh/main.h +++ b/bin/sh/main.h @@ -40,7 +40,7 @@ extern int rootpid; /* pid of main shell */ extern int rootshell; /* true if we aren't a child of the main shell */ -void readcmdfile __P((char *)); -void cmdloop __P((int)); -int dotcmd __P((int, char **)); -int exitcmd __P((int, char **)); +void readcmdfile(char *); +void cmdloop(int); +int dotcmd(int, char **); +int exitcmd(int, char **); diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index 26b4b2d..651501c 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -57,8 +57,7 @@ static const char rcsid[] = */ pointer -ckmalloc(nbytes) - int nbytes; +ckmalloc(int nbytes) { pointer p; @@ -73,9 +72,7 @@ ckmalloc(nbytes) */ pointer -ckrealloc(p, nbytes) - pointer p; - int nbytes; +ckrealloc(pointer p, int nbytes) { if ((p = realloc(p, nbytes)) == NULL) error("Out of space"); @@ -88,8 +85,7 @@ ckrealloc(p, nbytes) */ char * -savestr(s) - char *s; +savestr(char *s) { char *p; @@ -127,8 +123,7 @@ int herefd = -1; pointer -stalloc(nbytes) - int nbytes; +stalloc(int nbytes) { char *p; @@ -157,8 +152,7 @@ stalloc(nbytes) void -stunalloc(p) - pointer p; +stunalloc(pointer p) { if (p == NULL) { /*DEBUG */ write(STDERR_FILENO, "stunalloc\n", 10); @@ -171,8 +165,7 @@ stunalloc(p) void -setstackmark(mark) - struct stackmark *mark; +setstackmark(struct stackmark *mark) { mark->stackp = stackp; mark->stacknxt = stacknxt; @@ -183,8 +176,7 @@ setstackmark(mark) void -popstackmark(mark) - struct stackmark *mark; +popstackmark(struct stackmark *mark) { struct stack_block *sp; @@ -212,7 +204,7 @@ popstackmark(mark) */ void -growstackblock() +growstackblock(void) { char *p; int newlen; @@ -261,8 +253,7 @@ growstackblock() void -grabstackblock(len) - int len; +grabstackblock(int len) { len = ALIGN(len); stacknxt += len; @@ -291,7 +282,7 @@ grabstackblock(len) char * -growstackstr() +growstackstr(void) { int len; @@ -312,7 +303,7 @@ growstackstr() */ char * -makestrspace() +makestrspace(void) { int len; @@ -325,9 +316,7 @@ makestrspace() void -ungrabstackstr(s, p) - char *s; - char *p; +ungrabstackstr(char *s, char *p) { stacknleft += stacknxt - s; stacknxt = s; diff --git a/bin/sh/memalloc.h b/bin/sh/memalloc.h index e3ca8be..c43d8fd 100644 --- a/bin/sh/memalloc.h +++ b/bin/sh/memalloc.h @@ -50,18 +50,18 @@ extern int stacknleft; extern int sstrnleft; extern int herefd; -pointer ckmalloc __P((int)); -pointer ckrealloc __P((pointer, int)); -char *savestr __P((char *)); -pointer stalloc __P((int)); -void stunalloc __P((pointer)); -void setstackmark __P((struct stackmark *)); -void popstackmark __P((struct stackmark *)); -void growstackblock __P((void)); -void grabstackblock __P((int)); -char *growstackstr __P((void)); -char *makestrspace __P((void)); -void ungrabstackstr __P((char *, char *)); +pointer ckmalloc(int); +pointer ckrealloc(pointer, int); +char *savestr(char *); +pointer stalloc(int); +void stunalloc(pointer); +void setstackmark(struct stackmark *); +void popstackmark(struct stackmark *); +void growstackblock(void); +void grabstackblock(int); +char *growstackstr(void); +char *makestrspace(void); +void ungrabstackstr(char *, char *); diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c index 5c5d154..ca038d7 100644 --- a/bin/sh/miscbltin.c +++ b/bin/sh/miscbltin.c @@ -75,9 +75,7 @@ static const char rcsid[] = */ int -readcmd(argc, argv) - int argc __unused; - char **argv __unused; +readcmd(int argc __unused, char **argv __unused) { char **ap; int backslash; @@ -219,9 +217,7 @@ readcmd(argc, argv) int -umaskcmd(argc, argv) - int argc __unused; - char **argv; +umaskcmd(int argc __unused, char **argv) { char *ap; int mask; @@ -353,9 +349,7 @@ static const struct limits limits[] = { }; int -ulimitcmd(argc, argv) - int argc __unused; - char **argv __unused; +ulimitcmd(int argc __unused, char **argv __unused) { int c; quad_t val = 0; diff --git a/bin/sh/mkinit.c b/bin/sh/mkinit.c index b8f8ffb..4aa29fc 100644 --- a/bin/sh/mkinit.c +++ b/bin/sh/mkinit.c @@ -152,27 +152,25 @@ struct text decls; /* declarations */ int amiddecls; /* for formatting */ -void readfile __P((char *)); -int match __P((char *, char *)); -int gooddefine __P((char *)); -void doevent __P((struct event *, FILE *, char *)); -void doinclude __P((char *)); -void dodecl __P((char *, FILE *)); -void output __P((void)); -void addstr __P((char *, struct text *)); -void addchar __P((int, struct text *)); -void writetext __P((struct text *, FILE *)); -FILE *ckfopen __P((char *, char *)); -void *ckmalloc __P((int)); -char *savestr __P((char *)); -void error __P((char *)); +void readfile(char *); +int match(char *, char *); +int gooddefine(char *); +void doevent(struct event *, FILE *, char *); +void doinclude(char *); +void dodecl(char *, FILE *); +void output(void); +void addstr(char *, struct text *); +void addchar(int, struct text *); +void writetext(struct text *, FILE *); +FILE *ckfopen(char *, char *); +void *ckmalloc(int); +char *savestr(char *); +void error(char *); #define equal(s1, s2) (strcmp(s1, s2) == 0) int -main(argc, argv) - int argc __unused; - char **argv; +main(int argc __unused, char *argv[]) { char **ap; @@ -191,9 +189,8 @@ main(argc, argv) */ void -readfile(fname) - char *fname; - { +readfile(char *fname) +{ FILE *fp; char line[1024]; struct event *ep; @@ -236,9 +233,7 @@ readfile(fname) int -match(name, line) - char *name; - char *line; +match(char *name, char *line) { char *p, *q; @@ -254,8 +249,7 @@ match(name, line) int -gooddefine(line) - char *line; +gooddefine(char *line) { char *p; @@ -278,11 +272,8 @@ gooddefine(line) void -doevent(ep, fp, fname) - struct event *ep; - FILE *fp; - char *fname; - { +doevent(struct event *ep, FILE *fp, char *fname) +{ char line[1024]; int indent; char *p; @@ -318,9 +309,8 @@ doevent(ep, fp, fname) void -doinclude(line) - char *line; - { +doinclude(char *line) +{ char *p; char *name; char **pp; @@ -343,10 +333,8 @@ doinclude(line) void -dodecl(line1, fp) - char *line1; - FILE *fp; - { +dodecl(char *line1, FILE *fp) +{ char line[1024]; char *p, *q; @@ -390,7 +378,8 @@ dodecl(line1, fp) */ void -output() { +output(void) +{ FILE *fp; char **pp; struct event *ep; @@ -421,10 +410,8 @@ output() { */ void -addstr(s, text) - char *s; - struct text *text; - { +addstr(char *s, struct text *text) +{ while (*s) { if (--text->nleft < 0) addchar(*s++, text); @@ -435,9 +422,7 @@ addstr(s, text) void -addchar(c, text) - int c; - struct text *text; +addchar(int c, struct text *text) { struct block *bp; @@ -458,10 +443,8 @@ addchar(c, text) * Write the contents of a text structure to a file. */ void -writetext(text, fp) - struct text *text; - FILE *fp; - { +writetext(struct text *text, FILE *fp) +{ struct block *bp; if (text->start != NULL) { @@ -472,10 +455,8 @@ writetext(text, fp) } FILE * -ckfopen(file, mode) - char *file; - char *mode; - { +ckfopen(char *file, char *mode) +{ FILE *fp; if ((fp = fopen(file, mode)) == NULL) { @@ -486,8 +467,7 @@ ckfopen(file, mode) } void * -ckmalloc(nbytes) - int nbytes; +ckmalloc(int nbytes) { char *p; @@ -497,9 +477,8 @@ ckmalloc(nbytes) } char * -savestr(s) - char *s; - { +savestr(char *s) +{ char *p; p = ckmalloc(strlen(s) + 1); @@ -508,9 +487,8 @@ savestr(s) } void -error(msg) - char *msg; - { +error(char *msg) +{ if (curfile != NULL) fprintf(stderr, "%s:%d: ", curfile, linno); fprintf(stderr, "%s\n", msg); diff --git a/bin/sh/mknodes.c b/bin/sh/mknodes.c index ecb8407..1f14eab 100644 --- a/bin/sh/mknodes.c +++ b/bin/sh/mknodes.c @@ -57,12 +57,7 @@ static const char rcsid[] = #include <stdlib.h> #include <string.h> #include <errno.h> -#ifdef __STDC__ #include <stdarg.h> -#else -#include <varargs.h> -#endif - #define MAXTYPES 50 /* max number of node types */ #define MAXFIELDS 20 /* max fields in a structure */ @@ -103,23 +98,21 @@ static char line[1024]; static int linno; static char *linep; -static void parsenode __P((void)); -static void parsefield __P((void)); -static void output __P((char *)); -static void outsizes __P((FILE *)); -static void outfunc __P((FILE *, int)); -static void indent __P((int, FILE *)); -static int nextfield __P((char *)); -static void skipbl __P((void)); -static int readline __P((void)); -static void error __P((const char *, ...)) __printf0like(1, 2); -static char *savestr __P((const char *)); +static void parsenode(void); +static void parsefield(void); +static void output(char *); +static void outsizes(FILE *); +static void outfunc(FILE *, int); +static void indent(int, FILE *); +static int nextfield(char *); +static void skipbl(void); +static int readline(void); +static void error(const char *, ...) __printf0like(1, 2); +static char *savestr(const char *); int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { if (argc != 3) error("usage: mknodes file"); @@ -139,7 +132,7 @@ main(argc, argv) static void -parsenode() +parsenode(void) { char name[BUFLEN]; char tag[BUFLEN]; @@ -169,7 +162,7 @@ parsenode() static void -parsefield() +parsefield(void) { char name[BUFLEN]; char type[BUFLEN]; @@ -222,8 +215,7 @@ char writer[] = "\ \n"; static void -output(file) - char *file; +output(char *file) { FILE *hfile; FILE *cfile; @@ -260,13 +252,8 @@ output(file) fputs("\tstruct nodelist *next;\n", hfile); fputs("\tunion node *n;\n", hfile); fputs("};\n\n\n", hfile); - fputs("#ifdef __STDC__\n", hfile); fputs("union node *copyfunc(union node *);\n", hfile); fputs("void freefunc(union node *);\n", hfile); - fputs("#else\n", hfile); - fputs("union node *copyfunc();\n", hfile); - fputs("void freefunc();\n", hfile); - fputs("#endif\n", hfile); fputs(writer, cfile); while (fgets(line, sizeof line, patfile) != NULL) { @@ -285,8 +272,7 @@ output(file) static void -outsizes(cfile) - FILE *cfile; +outsizes(FILE *cfile) { int i; @@ -299,9 +285,7 @@ outsizes(cfile) static void -outfunc(cfile, calcsize) - FILE *cfile; - int calcsize; +outfunc(FILE *cfile, int calcsize) { struct str *sp; struct field *fp; @@ -380,9 +364,7 @@ outfunc(cfile, calcsize) static void -indent(amount, fp) - int amount; - FILE *fp; +indent(int amount, FILE *fp) { while (amount >= 8) { putc('\t', fp); @@ -395,8 +377,7 @@ indent(amount, fp) static int -nextfield(buf) - char *buf; +nextfield(char *buf) { char *p, *q; @@ -413,7 +394,7 @@ nextfield(buf) static void -skipbl() +skipbl(void) { while (*linep == ' ' || *linep == '\t') linep++; @@ -421,7 +402,7 @@ skipbl() static int -readline() +readline(void) { char *p; @@ -441,21 +422,10 @@ readline() static void -#ifdef __STDC__ error(const char *msg, ...) -#else -error(va_alist) - va_dcl -#endif { va_list va; -#ifdef __STDC__ va_start(va, msg); -#else - const char *msg; - va_start(va); - msg = va_arg(va, char *); -#endif (void) fprintf(stderr, "line %d: ", linno); (void) vfprintf(stderr, msg, va); @@ -469,8 +439,7 @@ error(va_alist) static char * -savestr(s) - const char *s; +savestr(const char *s) { char *p; diff --git a/bin/sh/mksyntax.c b/bin/sh/mksyntax.c index 437c435..778ab3c 100644 --- a/bin/sh/mksyntax.c +++ b/bin/sh/mksyntax.c @@ -111,17 +111,15 @@ static int size; /* number of values which a char variable can have */ static int nbits; /* number of bits in a character */ static int digit_contig;/* true if digits are contiguous */ -static void filltable __P((char *)); -static void init __P((void)); -static void add __P((char *, char *)); -static void print __P((char *)); -static void output_type_macros __P((void)); -static void digit_convert __P((void)); +static void filltable(char *); +static void init(void); +static void add(char *, char *); +static void print(char *); +static void output_type_macros(void); +static void digit_convert(void); int -main(argc, argv) - int argc __unused; - char **argv __unused; +main(int argc __unused, char **argv __unused) { char c; char d; @@ -268,8 +266,7 @@ main(argc, argv) */ static void -filltable(dftval) - char *dftval; +filltable(char *dftval) { int i; @@ -283,7 +280,7 @@ filltable(dftval) */ static void -init() +init(void) { filltable("CWORD"); syntax[0] = "CEOF"; @@ -303,8 +300,7 @@ init() */ static void -add(p, type) - char *p, *type; +add(char *p, char *type) { while (*p) syntax[*p++ + base] = type; @@ -317,8 +313,7 @@ add(p, type) */ static void -print(name) - char *name; +print(char *name) { int i; int col; @@ -360,7 +355,7 @@ static char *macro[] = { }; static void -output_type_macros() +output_type_macros(void) { char **pp; @@ -381,7 +376,7 @@ output_type_macros() */ static void -digit_convert() +digit_convert(void) { int maxdigit; static char digit[] = "0123456789"; diff --git a/bin/sh/myhistedit.h b/bin/sh/myhistedit.h index e60bf5a..77817c7 100644 --- a/bin/sh/myhistedit.h +++ b/bin/sh/myhistedit.h @@ -40,9 +40,9 @@ extern History *hist; extern EditLine *el; extern int displayhist; -void histedit __P((void)); -void sethistsize __P((const char *)); -int histcmd __P((int, char **)); -int not_fcnumber __P((char *)); -int str_to_event __P((char *, int)); +void histedit(void); +void sethistsize(const char *); +int histcmd(int, char **); +int not_fcnumber(char *); +int str_to_event(char *, int); diff --git a/bin/sh/mystring.c b/bin/sh/mystring.c index 8013f7d..993cbd2 100644 --- a/bin/sh/mystring.c +++ b/bin/sh/mystring.c @@ -77,11 +77,8 @@ char nullstr[1]; /* zero length string */ */ void -scopyn(from, to, size) - char const *from; - char *to; - int size; - { +scopyn(const char *from, char *to, int size) +{ while (--size > 0) { if ((*to++ = *from++) == '\0') @@ -96,10 +93,8 @@ scopyn(from, to, size) */ int -prefix(pfx, string) - char const *pfx; - char const *string; - { +prefix(const char *pfx, const char *string) +{ while (*pfx) { if (*pfx++ != *string++) return 0; @@ -114,10 +109,8 @@ prefix(pfx, string) */ int -number(s) - const char *s; - { - +number(const char *s) +{ if (! is_number(s)) error("Illegal number: %s", (char *)s); return atoi(s); @@ -130,9 +123,8 @@ number(s) */ int -is_number(p) - const char *p; - { +is_number(const char *p) +{ do { if (! is_digit(*p)) return 0; diff --git a/bin/sh/mystring.h b/bin/sh/mystring.h index 4a78bd9..d29f832 100644 --- a/bin/sh/mystring.h +++ b/bin/sh/mystring.h @@ -39,10 +39,10 @@ #include <string.h> -void scopyn __P((const char *, char *, int)); -int prefix __P((const char *, const char *)); -int number __P((const char *)); -int is_number __P((const char *)); +void scopyn(const char *, char *, int); +int prefix(const char *, const char *); +int number(const char *); +int is_number(const char *); #define equal(s1, s2) (strcmp(s1, s2) == 0) #define scopy(s1, s2) ((void)strcpy(s2, s1)) diff --git a/bin/sh/nodes.c.pat b/bin/sh/nodes.c.pat index 526cd88..2fc79f0 100644 --- a/bin/sh/nodes.c.pat +++ b/bin/sh/nodes.c.pat @@ -57,11 +57,11 @@ char *funcstring; /* block to allocate strings from */ %SIZES -STATIC void calcsize __P((union node *)); -STATIC void sizenodelist __P((struct nodelist *)); -STATIC union node *copynode __P((union node *)); -STATIC struct nodelist *copynodelist __P((struct nodelist *)); -STATIC char *nodesavestr __P((char *)); +STATIC void calcsize(union node *); +STATIC void sizenodelist(struct nodelist *); +STATIC union node *copynode(union node *); +STATIC struct nodelist *copynodelist(struct nodelist *); +STATIC char *nodesavestr(char *); @@ -70,8 +70,7 @@ STATIC char *nodesavestr __P((char *)); */ union node * -copyfunc(n) - union node *n; +copyfunc(union node *n) { if (n == NULL) return NULL; @@ -86,8 +85,7 @@ copyfunc(n) STATIC void -calcsize(n) - union node *n; +calcsize(union node *n) { %CALCSIZE } @@ -95,8 +93,7 @@ calcsize(n) STATIC void -sizenodelist(lp) - struct nodelist *lp; +sizenodelist(struct nodelist *lp) { while (lp) { funcblocksize += ALIGN(sizeof(struct nodelist)); @@ -108,8 +105,7 @@ sizenodelist(lp) STATIC union node * -copynode(n) - union node *n; +copynode(union node *n) { union node *new; @@ -119,8 +115,7 @@ copynode(n) STATIC struct nodelist * -copynodelist(lp) - struct nodelist *lp; +copynodelist(struct nodelist *lp) { struct nodelist *start; struct nodelist **lpp; @@ -140,8 +135,7 @@ copynodelist(lp) STATIC char * -nodesavestr(s) - char *s; +nodesavestr(char *s) { char *p = s; char *q = funcstring; @@ -160,8 +154,7 @@ nodesavestr(s) */ void -freefunc(n) - union node *n; +freefunc(union node *n) { if (n) ckfree(n); diff --git a/bin/sh/options.c b/bin/sh/options.c index 36f9c5c..5a3ba34 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -73,10 +73,10 @@ char *optptr; /* used by nextopt */ char *minusc; /* argument to -c option */ -STATIC void options __P((int)); -STATIC void minus_o __P((char *, int)); -STATIC void setoption __P((int, int)); -STATIC int getopts __P((char *, char *, char **, char ***, char **)); +STATIC void options(int); +STATIC void minus_o(char *, int); +STATIC void setoption(int, int); +STATIC int getopts(char *, char *, char **, char ***, char **); /* @@ -84,9 +84,7 @@ STATIC int getopts __P((char *, char *, char **, char ***, char **)); */ void -procargs(argc, argv) - int argc; - char **argv; +procargs(int argc, char **argv) { int i; @@ -127,7 +125,7 @@ procargs(argc, argv) void -optschanged() +optschanged(void) { setinteractive(iflag); #ifndef NO_HISTORY @@ -142,8 +140,7 @@ optschanged() */ STATIC void -options(cmdline) - int cmdline; +options(int cmdline) { char *p; int val; @@ -201,9 +198,7 @@ options(cmdline) } STATIC void -minus_o(name, val) - char *name; - int val; +minus_o(char *name, int val) { int i; @@ -228,10 +223,8 @@ minus_o(name, val) STATIC void -setoption(flag, val) - char flag; - int val; - { +setoption(int flag, int val) +{ int i; for (i = 0; i < NOPTS; i++) @@ -270,9 +263,8 @@ SHELLPROC { */ void -setparam(argv) - char **argv; - { +setparam(char **argv) +{ char **newparam; char **ap; int nparam; @@ -296,9 +288,8 @@ setparam(argv) */ void -freeparam(param) - struct shparam *param; - { +freeparam(struct shparam *param) +{ char **ap; if (param->malloc) { @@ -315,9 +306,7 @@ freeparam(param) */ int -shiftcmd(argc, argv) - int argc; - char **argv; +shiftcmd(int argc, char **argv) { int n; char **ap1, **ap2; @@ -347,9 +336,7 @@ shiftcmd(argc, argv) */ int -setcmd(argc, argv) - int argc; - char **argv; +setcmd(int argc, char **argv) { if (argc == 1) return showvarscmd(argc, argv); @@ -365,8 +352,7 @@ setcmd(argc, argv) void -getoptsreset(value) - const char *value; +getoptsreset(const char *value) { if (number(value) == 1) { shellparam.optnext = NULL; @@ -382,9 +368,7 @@ getoptsreset(value) */ int -getoptscmd(argc, argv) - int argc; - char **argv; +getoptscmd(int argc, char **argv) { char **optbase = NULL; @@ -406,12 +390,8 @@ getoptscmd(argc, argv) } STATIC int -getopts(optstr, optvar, optfirst, optnext, optptr) - char *optstr; - char *optvar; - char **optfirst; - char ***optnext; - char **optptr; +getopts(char *optstr, char *optvar, char **optfirst, char ***optnext, + char **optptr) { char *p, *q; char c = '?'; @@ -515,9 +495,8 @@ out: */ int -nextopt(optstring) - char *optstring; - { +nextopt(char *optstring) +{ char *p, *q; char c; diff --git a/bin/sh/options.h b/bin/sh/options.h index 023027b..016a936 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -106,12 +106,12 @@ extern char **argptr; /* argument list for builtin commands */ extern char *shoptarg; /* set by nextopt */ extern char *optptr; /* used by nextopt */ -void procargs __P((int, char **)); -void optschanged __P((void)); -void setparam __P((char **)); -void freeparam __P((struct shparam *)); -int shiftcmd __P((int, char **)); -int setcmd __P((int, char **)); -int getoptscmd __P((int, char **)); -int nextopt __P((char *)); -void getoptsreset __P((const char *)); +void procargs(int, char **); +void optschanged(void); +void setparam(char **); +void freeparam(struct shparam *); +int shiftcmd(int, char **); +int setcmd(int, char **); +int getoptscmd(int, char **); +int nextopt(char *); +void getoptsreset(const char *); diff --git a/bin/sh/output.c b/bin/sh/output.c index 2989c9a..56a437c 100644 --- a/bin/sh/output.c +++ b/bin/sh/output.c @@ -58,11 +58,7 @@ static const char rcsid[] = #include <stdio.h> /* defines BUFSIZ */ #include <string.h> -#ifdef __STDC__ #include <stdarg.h> -#else -#include <varargs.h> -#endif #include <errno.h> #include <unistd.h> #include <stdlib.h> @@ -105,46 +101,23 @@ RESET { #endif -#ifdef notdef /* no longer used */ -/* - * Set up an output file to write to memory rather than a file. - */ - -void -open_mem(block, length, file) - char *block; - int length; - struct output *file; - { - file->nextc = block; - file->nleft = --length; - file->fd = BLOCK_OUT; - file->flags = 0; -} -#endif - - void -out1str(p) - const char *p; - { +out1str(const char *p) +{ outstr(p, out1); } void -out2str(p) - const char *p; - { +out2str(const char *p) +{ outstr(p, out2); } void -outstr(p, file) - const char *p; - struct output *file; - { +outstr(const char *p, struct output *file) +{ while (*p) outc(*p++, file); if (file == out2) @@ -156,9 +129,8 @@ char out_junk[16]; void -emptyoutbuf(dest) - struct output *dest; - { +emptyoutbuf(struct output *dest) +{ int offset; if (dest->fd == BLOCK_OUT) { @@ -187,16 +159,16 @@ emptyoutbuf(dest) void -flushall() { +flushall(void) +{ flushout(&output); flushout(&errout); } void -flushout(dest) - struct output *dest; - { +flushout(struct output *dest) +{ if (dest->buf == NULL || dest->nextc == dest->buf || dest->fd < 0) return; @@ -208,7 +180,8 @@ flushout(dest) void -freestdout() { +freestdout(void) +{ INTOFF; if (output.buf) { ckfree(output.buf); @@ -219,9 +192,9 @@ freestdout() { } -#ifdef __STDC__ void -outfmt(struct output *file, const char *fmt, ...) { +outfmt(struct output *file, const char *fmt, ...) +{ va_list ap; va_start(ap, fmt); @@ -231,7 +204,8 @@ outfmt(struct output *file, const char *fmt, ...) { void -out1fmt(const char *fmt, ...) { +out1fmt(const char *fmt, ...) +{ va_list ap; va_start(ap, fmt); @@ -240,7 +214,8 @@ out1fmt(const char *fmt, ...) { } void -dprintf(const char *fmt, ...) { +dprintf(const char *fmt, ...) +{ va_list ap; va_start(ap, fmt); @@ -250,7 +225,8 @@ dprintf(const char *fmt, ...) { } void -fmtstr(char *outbuf, int length, const char *fmt, ...) { +fmtstr(char *outbuf, int length, const char *fmt, ...) +{ va_list ap; struct output strout; @@ -265,77 +241,6 @@ fmtstr(char *outbuf, int length, const char *fmt, ...) { outbuf[length - 1] = '\0'; } -#else /* not __STDC__ */ - -void -outfmt(va_alist) - va_dcl - { - va_list ap; - struct output *file; - const char *fmt; - - va_start(ap); - file = va_arg(ap, struct output *); - fmt = va_arg(ap, char *); - doformat(file, fmt, ap); - va_end(ap); -} - - -void -out1fmt(va_alist) - va_dcl - { - va_list ap; - const char *fmt; - - va_start(ap); - fmt = va_arg(ap, char *); - doformat(out1, fmt, ap); - va_end(ap); -} - -void -dprintf(va_alist) - va_dcl - { - va_list ap; - const char *fmt; - - va_start(ap); - fmt = va_arg(ap, char *); - doformat(out2, fmt, ap); - va_end(ap); - flushout(out2); -} - -void -fmtstr(va_alist) - va_dcl - { - va_list ap; - struct output strout; - char *outbuf; - int length; - const char *fmt; - - va_start(ap); - outbuf = va_arg(ap, char *); - length = va_arg(ap, int); - fmt = va_arg(ap, char *); - strout.nextc = outbuf; - strout.nleft = length; - strout.fd = BLOCK_OUT; - strout.flags = 0; - doformat(&strout, fmt, ap); - outc('\0', &strout); - if (strout.flags & OUTPUT_ERR) - outbuf[length - 1] = '\0'; -} -#endif /* __STDC__ */ - - /* * Formatted output. This routine handles a subset of the printf formats: * - Formats supported: d, u, o, X, s, and c. @@ -355,11 +260,8 @@ static const char digit[] = "0123456789ABCDEF"; void -doformat(dest, f, ap) - struct output *dest; - const char *f; /* format string */ - va_list ap; - { +doformat(struct output *dest, const char *f, va_list ap) +{ char c; char temp[TEMPSIZE]; int flushleft; @@ -529,11 +431,8 @@ number: /* process a number */ */ int -xwrite(fd, buf, nbytes) - int fd; - char *buf; - int nbytes; - { +xwrite(int fd, char *buf, int nbytes) +{ int ntry; int i; int n; @@ -555,21 +454,3 @@ xwrite(fd, buf, nbytes) } } } - - -/* - * Version of ioctl that retries after a signal is caught. - * XXX unused function - */ - -int -xioctl(fd, request, arg) - int fd; - unsigned long request; - char * arg; -{ - int i; - - while ((i = ioctl(fd, request, arg)) == -1 && errno == EINTR); - return i; -} diff --git a/bin/sh/output.h b/bin/sh/output.h index 425b49f..5991115 100644 --- a/bin/sh/output.h +++ b/bin/sh/output.h @@ -60,21 +60,20 @@ extern struct output memout; extern struct output *out1; extern struct output *out2; -void open_mem __P((char *, int, struct output *)); -void out1str __P((const char *)); -void out2str __P((const char *)); -void outstr __P((const char *, struct output *)); -void emptyoutbuf __P((struct output *)); -void flushall __P((void)); -void flushout __P((struct output *)); -void freestdout __P((void)); -void outfmt __P((struct output *, const char *, ...)) __printflike(2, 3); -void out1fmt __P((const char *, ...)) __printflike(1, 2); -void dprintf __P((const char *, ...)) __printflike(1, 2); -void fmtstr __P((char *, int, const char *, ...)) __printflike(3, 4); -void doformat __P((struct output *, const char *, va_list)) __printflike(2, 0); -int xwrite __P((int, char *, int)); -int xioctl __P((int, unsigned long, char *)); +void open_mem(char *, int, struct output *); +void out1str(const char *); +void out2str(const char *); +void outstr(const char *, struct output *); +void emptyoutbuf(struct output *); +void flushall(void); +void flushout(struct output *); +void freestdout(void); +void outfmt(struct output *, const char *, ...) __printflike(2, 3); +void out1fmt(const char *, ...) __printflike(1, 2); +void dprintf(const char *, ...) __printflike(1, 2); +void fmtstr(char *, int, const char *, ...) __printflike(3, 4); +void doformat(struct output *, const char *, va_list) __printflike(2, 0); +int xwrite(int, char *, int); #define outc(c, file) (--(file)->nleft < 0? (emptyoutbuf(file), *(file)->nextc++ = (c)) : (*(file)->nextc++ = (c))) #define out1c(c) outc(c, out1); diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 1dc5d4b..08cd737 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -108,22 +108,22 @@ static const char types[] = "}-+?="; #endif -STATIC union node *list __P((int)); -STATIC union node *andor __P((void)); -STATIC union node *pipeline __P((void)); -STATIC union node *command __P((void)); -STATIC union node *simplecmd __P((union node **, union node *)); -STATIC union node *makename __P((void)); -STATIC void parsefname __P((void)); -STATIC void parseheredoc __P((void)); -STATIC int peektoken __P((void)); -STATIC int readtoken __P((void)); -STATIC int xxreadtoken __P((void)); -STATIC int readtoken1 __P((int, char const *, char *, int)); -STATIC int noexpand __P((char *)); -STATIC void synexpect __P((int)); -STATIC void synerror __P((char *)); -STATIC void setprompt __P((int)); +STATIC union node *list(int); +STATIC union node *andor(void); +STATIC union node *pipeline(void); +STATIC union node *command(void); +STATIC union node *simplecmd(union node **, union node *); +STATIC union node *makename(void); +STATIC void parsefname(void); +STATIC void parseheredoc(void); +STATIC int peektoken(void); +STATIC int readtoken(void); +STATIC int xxreadtoken(void); +STATIC int readtoken1(int, char const *, char *, int); +STATIC int noexpand(char *); +STATIC void synexpect(int); +STATIC void synerror(char *); +STATIC void setprompt(int); /* @@ -132,8 +132,7 @@ STATIC void setprompt __P((int)); */ union node * -parsecmd(interact) - int interact; +parsecmd(int interact) { int t; @@ -155,8 +154,7 @@ parsecmd(interact) STATIC union node * -list(nlflag) - int nlflag; +list(int nlflag) { union node *n1, *n2, *n3; int tok; @@ -226,7 +224,8 @@ list(nlflag) STATIC union node * -andor() { +andor(void) +{ union node *n1, *n2, *n3; int t; @@ -252,7 +251,8 @@ andor() { STATIC union node * -pipeline() { +pipeline(void) +{ union node *n1, *n2, *pipenode; struct nodelist *lp, *prev; int negate; @@ -292,7 +292,8 @@ pipeline() { STATIC union node * -command() { +command(void) +{ union node *n1, *n2; union node *ap, **app; union node *cp, **cpp; @@ -527,9 +528,8 @@ checkneg: STATIC union node * -simplecmd(rpp, redir) - union node **rpp, *redir; - { +simplecmd(union node **rpp, union node *redir) +{ union node *args, **app; union node **orig_rpp = rpp; union node *n = NULL, *n2; @@ -604,7 +604,8 @@ checkneg: } STATIC union node * -makename() { +makename(void) +{ union node *n; n = (union node *)stalloc(sizeof (struct narg)); @@ -615,11 +616,8 @@ makename() { return n; } -void fixredir(n, text, err) - union node *n; - const char *text; - int err; - { +void fixredir(union node *n, const char *text, int err) +{ TRACE(("Fix redir %s %d\n", text, err)); if (!err) n->ndup.vname = NULL; @@ -639,7 +637,8 @@ void fixredir(n, text, err) STATIC void -parsefname() { +parsefname(void) +{ union node *n = redirnode; if (readtoken() != TWORD) @@ -680,7 +679,8 @@ parsefname() { */ STATIC void -parseheredoc() { +parseheredoc(void) +{ struct heredoc *here; union node *n; @@ -703,7 +703,8 @@ parseheredoc() { } STATIC int -peektoken() { +peektoken(void) +{ int t; t = readtoken(); @@ -712,7 +713,8 @@ peektoken() { } STATIC int -readtoken() { +readtoken(void) +{ int t; int savecheckkwd = checkkwd; struct alias *ap; @@ -791,7 +793,8 @@ out: #define RETURN(token) return lasttoken = token STATIC int -xxreadtoken() { +xxreadtoken(void) +{ int c; if (tokpushback) { @@ -881,12 +884,8 @@ breakloop: #define PARSEARITH() {goto parsearith; parsearith_return:;} STATIC int -readtoken1(firstc, syntax, eofmark, striptabs) - int firstc; - char const *syntax; - char *eofmark; - int striptabs; - { +readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs) +{ int c = firstc; char *out; int len; @@ -1484,9 +1483,8 @@ RESET { */ STATIC int -noexpand(text) - char *text; - { +noexpand(char *text) +{ char *p; char c; @@ -1509,9 +1507,8 @@ noexpand(text) */ int -goodname(name) - char *name; - { +goodname(char *name) +{ char *p; p = name; @@ -1532,8 +1529,7 @@ goodname(name) */ STATIC void -synexpect(token) - int token; +synexpect(int token) { char msg[64]; @@ -1548,9 +1544,8 @@ synexpect(token) STATIC void -synerror(msg) - char *msg; - { +synerror(char *msg) +{ if (commandname) outfmt(&errout, "%s: %d: ", commandname, startlinno); outfmt(&errout, "Syntax error: %s\n", msg); @@ -1558,9 +1553,8 @@ synerror(msg) } STATIC void -setprompt(which) - int which; - { +setprompt(int which) +{ whichprompt = which; #ifndef NO_HISTORY @@ -1574,8 +1568,7 @@ setprompt(which) * should be added here. */ char * -getprompt(unused) - void *unused __unused; +getprompt(void *unused __unused) { switch (whichprompt) { case 0: diff --git a/bin/sh/parser.h b/bin/sh/parser.h index fdb2c34..c83d66a 100644 --- a/bin/sh/parser.h +++ b/bin/sh/parser.h @@ -76,7 +76,7 @@ extern int tokpushback; extern int whichprompt; /* 1 == PS1, 2 == PS2 */ -union node *parsecmd __P((int)); -void fixredir __P((union node *, const char *, int)); -int goodname __P((char *)); -char *getprompt __P((void *)); +union node *parsecmd(int); +void fixredir(union node *, const char *, int); +int goodname(char *); +char *getprompt(void *); diff --git a/bin/sh/redir.c b/bin/sh/redir.c index b51fa2b..b596463 100644 --- a/bin/sh/redir.c +++ b/bin/sh/redir.c @@ -84,8 +84,8 @@ MKINIT struct redirtab *redirlist; */ int fd0_redirected = 0; -STATIC void openredirect __P((union node *, char[10 ])); -STATIC int openhere __P((union node *)); +STATIC void openredirect(union node *, char[10 ]); +STATIC int openhere(union node *); /* @@ -97,10 +97,8 @@ STATIC int openhere __P((union node *)); */ void -redirect(redir, flags) - union node *redir; - int flags; - { +redirect(union node *redir, int flags) +{ union node *n; struct redirtab *sv = NULL; int i; @@ -161,10 +159,8 @@ again: STATIC void -openredirect(redir, memory) - union node *redir; - char memory[10]; - { +openredirect(union node *redir, char memory[10]) +{ int fd = redir->nfile.fd; char *fname; int f; @@ -260,9 +256,8 @@ movefd: */ STATIC int -openhere(redir) - union node *redir; - { +openhere(union node *redir) +{ int pip[2]; int len = 0; @@ -302,7 +297,8 @@ out: */ void -popredir() { +popredir(void) +{ struct redirtab *rp = redirlist; int i; @@ -344,7 +340,8 @@ SHELLPROC { /* Return true if fd 0 has already been redirected at least once. */ int -fd0_redirected_p () { +fd0_redirected_p(void) +{ return fd0_redirected != 0; } @@ -353,7 +350,8 @@ fd0_redirected_p () { */ void -clearredir() { +clearredir(void) +{ struct redirtab *rp; int i; @@ -376,9 +374,7 @@ clearredir() { */ int -copyfd(from, to) - int from; - int to; +copyfd(int from, int to) { int newfd; diff --git a/bin/sh/redir.h b/bin/sh/redir.h index 709ed12..e786004 100644 --- a/bin/sh/redir.h +++ b/bin/sh/redir.h @@ -42,9 +42,9 @@ #define REDIR_BACKQ 02 /* save the command output in memory */ union node; -void redirect __P((union node *, int)); -void popredir __P((void)); -int fd0_redirected_p __P((void)); -void clearredir __P((void)); -int copyfd __P((int, int)); +void redirect(union node *, int); +void popredir(void); +int fd0_redirected_p(void); +void clearredir(void); +int copyfd(int, int); diff --git a/bin/sh/show.c b/bin/sh/show.c index 0183e6b..3880d38 100644 --- a/bin/sh/show.c +++ b/bin/sh/show.c @@ -43,14 +43,7 @@ static const char rcsid[] = #endif /* not lint */ #include <stdio.h> -#ifdef __STDC__ #include <stdarg.h> -#else -#include <varargs.h> -#endif -#if DEBUG == 2 -#include <errno.h> -#endif #include <errno.h> #include "shell.h" @@ -61,16 +54,15 @@ static const char rcsid[] = #ifdef DEBUG -static void shtree __P((union node *, int, char *, FILE*)); -static void shcmd __P((union node *, FILE *)); -static void sharg __P((union node *, FILE *)); -static void indent __P((int, char *, FILE *)); -static void trstring __P((char *)); +static void shtree(union node *, int, char *, FILE*); +static void shcmd(union node *, FILE *); +static void sharg(union node *, FILE *); +static void indent(int, char *, FILE *); +static void trstring(char *); void -showtree(n) - union node *n; +showtree(union node *n) { trputs("showtree called\n"); shtree(n, 1, NULL, stdout); @@ -78,11 +70,7 @@ showtree(n) static void -shtree(n, ind, pfx, fp) - union node *n; - int ind; - char *pfx; - FILE *fp; +shtree(union node *n, int ind, char *pfx, FILE *fp) { struct nodelist *lp; char *s; @@ -133,9 +121,7 @@ binop: static void -shcmd(cmd, fp) - union node *cmd; - FILE *fp; +shcmd(union node *cmd, FILE *fp) { union node *np; int first; @@ -176,10 +162,8 @@ shcmd(cmd, fp) static void -sharg(arg, fp) - union node *arg; - FILE *fp; - { +sharg(union node *arg, FILE *fp) +{ char *p; struct nodelist *bqlist; int subtype; @@ -263,10 +247,7 @@ sharg(arg, fp) static void -indent(amount, pfx, fp) - int amount; - char *pfx; - FILE *fp; +indent(int amount, char *pfx, FILE *fp) { int i; @@ -293,8 +274,7 @@ int debug = 0; void -trputc(c) - int c; +trputc(int c) { if (tracefile == NULL) return; @@ -305,21 +285,10 @@ trputc(c) void -#ifdef __STDC__ sh_trace(const char *fmt, ...) -#else -sh_trace(va_alist) - va_dcl -#endif { va_list va; -#ifdef __STDC__ va_start(va, fmt); -#else - char *fmt; - va_start(va); - fmt = va_arg(va, char *); -#endif if (tracefile != NULL) { (void) vfprintf(tracefile, fmt, va); if (strchr(fmt, '\n')) @@ -330,8 +299,7 @@ sh_trace(va_alist) void -trputs(s) - char *s; +trputs(char *s) { if (tracefile == NULL) return; @@ -342,8 +310,7 @@ trputs(s) static void -trstring(s) - char *s; +trstring(char *s) { char *p; char c; @@ -383,8 +350,7 @@ backslash: putc('\\', tracefile); void -trargs(ap) - char **ap; +trargs(char **ap) { if (tracefile == NULL) return; @@ -400,7 +366,8 @@ trargs(ap) void -opentrace() { +opentrace(void) +{ char s[100]; char *getenv(); #ifdef O_APPEND diff --git a/bin/sh/show.h b/bin/sh/show.h index 98ec398..edd4309 100644 --- a/bin/sh/show.h +++ b/bin/sh/show.h @@ -34,11 +34,11 @@ * $FreeBSD$ */ -void showtree __P((union node *)); +void showtree(union node *); #ifdef DEBUG -void sh_trace __P((const char *, ...)) __printflike(1, 2); -void trargs __P((char **)); -void trputc __P((int)); -void trputs __P((char *)); -void opentrace __P((void)); +void sh_trace(const char *, ...) __printflike(1, 2); +void trargs(char **); +void trputc(int); +void trputs(char *); +void opentrace(void); #endif diff --git a/bin/sh/trap.c b/bin/sh/trap.c index 233746e..20bd9f9 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -82,15 +82,14 @@ static volatile sig_atomic_t gotsig[NSIG]; /* indicates specified signal received */ static int ignore_sigchld; /* Used while handling SIGCHLD traps. */ -static int getsigaction __P((int, sig_t *)); +static int getsigaction(int, sig_t *); /* * Map a string to a signal number. */ static int -sigstring_to_signum(sig) - char *sig; +sigstring_to_signum(char *sig) { if (is_number(sig)) { @@ -117,7 +116,7 @@ sigstring_to_signum(sig) * Print a list of valid signal names. */ static void -printsignals() +printsignals(void) { int n; @@ -135,9 +134,7 @@ printsignals() * The trap builtin. */ int -trapcmd(argc, argv) - int argc; - char **argv; +trapcmd(int argc, char **argv) { char *action; int signo; @@ -188,7 +185,7 @@ trapcmd(argc, argv) * Clear traps on a fork. */ void -clear_traps() +clear_traps(void) { char *volatile *tp; @@ -210,8 +207,7 @@ clear_traps() * out what it should be set to. */ void -setsignal(signo) - int signo; +setsignal(int signo) { int action; sig_t sig, sigact = SIG_DFL; @@ -296,9 +292,7 @@ setsignal(signo) * Return the current setting for sig w/o changing it. */ static int -getsigaction(signo, sigact) - int signo; - sig_t *sigact; +getsigaction(int signo, sig_t *sigact) { struct sigaction sa; @@ -313,8 +307,7 @@ getsigaction(signo, sigact) * Ignore a signal. */ void -ignoresig(signo) - int signo; +ignoresig(int signo) { if (sigmode[signo] != S_IGN && sigmode[signo] != S_HARD_IGN) { @@ -344,8 +337,7 @@ SHELLPROC { * Signal handler. */ void -onsig(signo) - int signo; +onsig(int signo) { #ifndef BSD @@ -380,7 +372,7 @@ onsig(signo) * handlers while we are executing a trap handler. */ void -dotrap() +dotrap(void) { int i; int savestatus; @@ -418,8 +410,7 @@ dotrap() * Controls whether the shell is interactive or not. */ void -setinteractive(on) - int on; +setinteractive(int on) { static int is_interactive = -1; @@ -436,8 +427,7 @@ setinteractive(on) * Called to exit the shell. */ void -exitshell(status) - int status; +exitshell(int status) { struct jmploc loc1, loc2; char *p; diff --git a/bin/sh/trap.h b/bin/sh/trap.h index 2140c14..d633d7a 100644 --- a/bin/sh/trap.h +++ b/bin/sh/trap.h @@ -40,11 +40,11 @@ extern int pendingsigs; extern int in_dotrap; -int trapcmd __P((int, char **)); -void clear_traps __P((void)); -void setsignal __P((int)); -void ignoresig __P((int)); -void onsig __P((int)); -void dotrap __P((void)); -void setinteractive __P((int)); -void exitshell __P((int)); +int trapcmd(int, char **); +void clear_traps(void); +void setsignal(int); +void ignoresig(int); +void onsig(int); +void dotrap(void); +void setinteractive(int); +void exitshell(int); diff --git a/bin/sh/var.c b/bin/sh/var.c index 056ae6f..099d4c5 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -77,7 +77,7 @@ struct varinit { struct var *var; int flags; char *text; - void (*func) __P((const char *)); + void (*func)(const char *); }; @@ -133,9 +133,9 @@ const struct varinit varinit[] = { struct var *vartab[VTABSIZE]; -STATIC struct var **hashvar __P((char *)); -STATIC int varequal __P((char *, char *)); -STATIC int localevar __P((char *)); +STATIC struct var **hashvar(char *); +STATIC int varequal(char *, char *); +STATIC int localevar(char *); /* * Initialize the varable symbol tables and import the environment @@ -163,7 +163,8 @@ INIT { */ void -initvar() { +initvar(void) +{ const struct varinit *ip; struct var *vp; struct var **vpp; @@ -195,9 +196,7 @@ initvar() { */ int -setvarsafe(name, val, flags) - char *name, *val; - int flags; +setvarsafe(char *name, char *val, int flags) { struct jmploc jmploc; struct jmploc *volatile savehandler = handler; @@ -223,9 +222,7 @@ setvarsafe(name, val, flags) */ void -setvar(name, val, flags) - char *name, *val; - int flags; +setvar(char *name, char *val, int flags) { char *p, *q; int len; @@ -267,9 +264,8 @@ setvar(name, val, flags) } STATIC int -localevar(s) - char *s; - { +localevar(char *s) +{ static char *lnames[7] = { "ALL", "COLLATE", "CTYPE", "MONETARY", "NUMERIC", "TIME", NULL @@ -296,9 +292,7 @@ localevar(s) */ void -setvareq(s, flags) - char *s; - int flags; +setvareq(char *s, int flags) { struct var *vp, **vpp; @@ -359,9 +353,8 @@ setvareq(s, flags) */ void -listsetvar(list) - struct strlist *list; - { +listsetvar(struct strlist *list) +{ struct strlist *lp; INTOFF; @@ -378,9 +371,8 @@ listsetvar(list) */ char * -lookupvar(name) - char *name; - { +lookupvar(char *name) +{ struct var *v; for (v = *hashvar(name) ; v ; v = v->next) { @@ -402,9 +394,7 @@ lookupvar(name) */ char * -bltinlookup(name, doall) - char *name; - int doall; +bltinlookup(char *name, int doall) { struct strlist *sp; struct var *v; @@ -432,7 +422,8 @@ bltinlookup(name, doall) */ char ** -environment() { +environment(void) +{ int nenv; struct var **vpp; struct var *vp; @@ -470,7 +461,8 @@ SHELLPROC { #endif void -shprocvar() { +shprocvar(void) +{ struct var **vpp; struct var *vp, **prev; @@ -503,9 +495,7 @@ shprocvar() { */ int -showvarscmd(argc, argv) - int argc __unused; - char **argv __unused; +showvarscmd(int argc __unused, char **argv __unused) { struct var **vpp; struct var *vp; @@ -526,9 +516,7 @@ showvarscmd(argc, argv) */ int -exportcmd(argc, argv) - int argc; - char **argv; +exportcmd(int argc, char **argv) { struct var **vpp; struct var *vp; @@ -545,6 +533,7 @@ exportcmd(argc, argv) vpp = hashvar(name); for (vp = *vpp ; vp ; vp = vp->next) { if (varequal(vp->text, name)) { + vp->flags |= flag; if ((vp->flags & VEXPORT) && localevar(vp->text)) { putenv(vp->text); @@ -577,9 +566,7 @@ found:; */ int -localcmd(argc, argv) - int argc __unused; - char **argv __unused; +localcmd(int argc __unused, char **argv __unused) { char *name; @@ -600,9 +587,8 @@ localcmd(argc, argv) */ void -mklocal(name) - char *name; - { +mklocal(char *name) +{ struct localvar *lvp; struct var **vpp; struct var *vp; @@ -644,7 +630,8 @@ mklocal(name) */ void -poplocalvars() { +poplocalvars(void) +{ struct localvar *lvp; struct var *vp; @@ -668,9 +655,7 @@ poplocalvars() { int -setvarcmd(argc, argv) - int argc; - char **argv; +setvarcmd(int argc, char **argv) { if (argc <= 2) return unsetcmd(argc, argv); @@ -689,9 +674,7 @@ setvarcmd(argc, argv) */ int -unsetcmd(argc, argv) - int argc __unused; - char **argv __unused; +unsetcmd(int argc __unused, char **argv __unused) { char **ap; int i; @@ -723,9 +706,8 @@ unsetcmd(argc, argv) */ int -unsetvar(s) - char *s; - { +unsetvar(char *s) +{ struct var **vpp; struct var *vp; @@ -764,9 +746,8 @@ unsetvar(s) */ STATIC struct var ** -hashvar(p) - char *p; - { +hashvar(char *p) +{ unsigned int hashval; hashval = ((unsigned char) *p) << 4; @@ -784,9 +765,8 @@ hashvar(p) */ STATIC int -varequal(p, q) - char *p, *q; - { +varequal(char *p, char *q) +{ while (*p == *q++) { if (*p++ == '=') return 1; diff --git a/bin/sh/var.h b/bin/sh/var.h index 1a215fc..0718a25 100644 --- a/bin/sh/var.h +++ b/bin/sh/var.h @@ -55,7 +55,7 @@ struct var { struct var *next; /* next entry in hash list */ int flags; /* flags are defined above */ char *text; /* name=value */ - void (*func) __P((const char *)); + void (*func)(const char *); /* function to be called when */ /* the variable gets set/unset */ }; @@ -113,21 +113,21 @@ extern struct var vhistsize; #endif #define mpathset() ((vmpath.flags & VUNSET) == 0) -void initvar __P((void)); -void setvar __P((char *, char *, int)); -void setvareq __P((char *, int)); +void initvar(void); +void setvar(char *, char *, int); +void setvareq(char *, int); struct strlist; -void listsetvar __P((struct strlist *)); -char *lookupvar __P((char *)); -char *bltinlookup __P((char *, int)); -char **environment __P((void)); -void shprocvar __P((void)); -int showvarscmd __P((int, char **)); -int exportcmd __P((int, char **)); -int localcmd __P((int, char **)); -void mklocal __P((char *)); -void poplocalvars __P((void)); -int setvarcmd __P((int, char **)); -int unsetcmd __P((int, char **)); -int unsetvar __P((char *)); -int setvarsafe __P((char *, char *, int)); +void listsetvar(struct strlist *); +char *lookupvar(char *); +char *bltinlookup(char *, int); +char **environment(void); +void shprocvar(void); +int showvarscmd(int, char **); +int exportcmd(int, char **); +int localcmd(int, char **); +void mklocal(char *); +void poplocalvars(void); +int setvarcmd(int, char **); +int unsetcmd(int, char **); +int unsetvar(char *); +int setvarsafe(char *, char *, int); diff --git a/bin/sleep/sleep.c b/bin/sleep/sleep.c index 1f8b4fb..94263e5 100644 --- a/bin/sleep/sleep.c +++ b/bin/sleep/sleep.c @@ -52,13 +52,10 @@ static const char rcsid[] = #include <time.h> #include <unistd.h> -int main __P((int, char *[])); -void usage __P((void)); +void usage(void); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { struct timespec time_to_sleep; long l; @@ -129,7 +126,7 @@ main(argc, argv) } void -usage() +usage(void) { (void)fprintf(stderr, "usage: sleep seconds\n"); diff --git a/bin/stty/cchar.c b/bin/stty/cchar.c index 8552160..297ba6b 100644 --- a/bin/stty/cchar.c +++ b/bin/stty/cchar.c @@ -50,7 +50,7 @@ static const char rcsid[] = #include "stty.h" #include "extern.h" -static int c_cchar __P((const void *, const void *)); +static int c_cchar(const void *, const void *); /* * Special control characters. @@ -90,17 +90,14 @@ struct cchar cchars2[] = { }; static int -c_cchar(a, b) - const void *a, *b; +c_cchar(const void *a, const void *b) { return (strcmp(((const struct cchar *)a)->name, ((const struct cchar *)b)->name)); } int -csearch(argvp, ip) - char ***argvp; - struct info *ip; +csearch(char ***argvp, struct info *ip) { struct cchar *cp, tmp; long val; diff --git a/bin/stty/extern.h b/bin/stty/extern.h index 27869f8..35d5f9afe 100644 --- a/bin/stty/extern.h +++ b/bin/stty/extern.h @@ -34,16 +34,16 @@ * $FreeBSD$ */ -int c_cchars __P((const void *, const void *)); -int c_modes __P((const void *, const void *)); -int csearch __P((char ***, struct info *)); -void checkredirect __P((void)); -void gprint __P((struct termios *, struct winsize *, int)); -void gread __P((struct termios *, char *)); -int ksearch __P((char ***, struct info *)); -int msearch __P((char ***, struct info *)); -void optlist __P((void)); -void print __P((struct termios *, struct winsize *, int, enum FMT)); -void usage __P((void)); +int c_cchars(const void *, const void *); +int c_modes(const void *, const void *); +int csearch(char ***, struct info *); +void checkredirect(void); +void gprint(struct termios *, struct winsize *, int); +void gread(struct termios *, char *); +int ksearch(char ***, struct info *); +int msearch(char ***, struct info *); +void optlist(void); +void print(struct termios *, struct winsize *, int, enum FMT); +void usage(void); extern struct cchar cchars1[], cchars2[]; diff --git a/bin/stty/gfmt.c b/bin/stty/gfmt.c index 8a9a03a..be0218a 100644 --- a/bin/stty/gfmt.c +++ b/bin/stty/gfmt.c @@ -48,11 +48,10 @@ static const char rcsid[] = #include "stty.h" #include "extern.h" -static void gerr __P((const char *s)); +static void gerr(const char *s); static void -gerr(s) - const char *s; +gerr(const char *s) { if (s) errx(1, "illegal gfmt1 option -- %s", s); @@ -61,10 +60,7 @@ gerr(s) } void -gprint(tp, wp, ldisc) - struct termios *tp; - struct winsize *wp __unused; - int ldisc __unused; +gprint(struct termios *tp, struct winsize *wp __unused, int ldisc __unused) { struct cchar *cp; @@ -78,9 +74,7 @@ gprint(tp, wp, ldisc) } void -gread(tp, s) - struct termios *tp; - char *s; +gread(struct termios *tp, char *s) { struct cchar *cp; char *ep, *p; diff --git a/bin/stty/key.c b/bin/stty/key.c index 9a48f41..1b9ce2b 100644 --- a/bin/stty/key.c +++ b/bin/stty/key.c @@ -52,28 +52,28 @@ static const char rcsid[] = #include "extern.h" __BEGIN_DECLS -static int c_key __P((const void *, const void *)); -void f_all __P((struct info *)); -void f_cbreak __P((struct info *)); -void f_columns __P((struct info *)); -void f_dec __P((struct info *)); -void f_ek __P((struct info *)); -void f_everything __P((struct info *)); -void f_extproc __P((struct info *)); -void f_ispeed __P((struct info *)); -void f_nl __P((struct info *)); -void f_ospeed __P((struct info *)); -void f_raw __P((struct info *)); -void f_rows __P((struct info *)); -void f_sane __P((struct info *)); -void f_size __P((struct info *)); -void f_speed __P((struct info *)); -void f_tty __P((struct info *)); +static int c_key(const void *, const void *); +void f_all(struct info *); +void f_cbreak(struct info *); +void f_columns(struct info *); +void f_dec(struct info *); +void f_ek(struct info *); +void f_everything(struct info *); +void f_extproc(struct info *); +void f_ispeed(struct info *); +void f_nl(struct info *); +void f_ospeed(struct info *); +void f_raw(struct info *); +void f_rows(struct info *); +void f_sane(struct info *); +void f_size(struct info *); +void f_speed(struct info *); +void f_tty(struct info *); __END_DECLS static struct key { const char *name; /* name */ - void (*f) __P((struct info *)); /* function */ + void (*f)(struct info *); /* function */ #define F_NEEDARG 0x01 /* needs an argument */ #define F_OFFOK 0x02 /* can turn off */ int flags; @@ -101,17 +101,14 @@ static struct key { }; static int -c_key(a, b) - const void *a, *b; +c_key(const void *a, const void *b) { return (strcmp(((const struct key *)a)->name, ((const struct key *)b)->name)); } int -ksearch(argvp, ip) - char ***argvp; - struct info *ip; +ksearch(char ***argvp, struct info *ip) { char *name; struct key *kp, tmp; @@ -140,15 +137,13 @@ ksearch(argvp, ip) } void -f_all(ip) - struct info *ip; +f_all(struct info *ip) { print(&ip->t, &ip->win, ip->ldisc, BSD); } void -f_cbreak(ip) - struct info *ip; +f_cbreak(struct info *ip) { if (ip->off) @@ -163,8 +158,7 @@ f_cbreak(ip) } void -f_columns(ip) - struct info *ip; +f_columns(struct info *ip) { ip->win.ws_col = atoi(ip->arg); @@ -172,8 +166,7 @@ f_columns(ip) } void -f_dec(ip) - struct info *ip; +f_dec(struct info *ip) { ip->t.c_cc[VERASE] = (u_char)0177; @@ -186,8 +179,7 @@ f_dec(ip) } void -f_ek(ip) - struct info *ip; +f_ek(struct info *ip) { ip->t.c_cc[VERASE] = CERASE; @@ -196,16 +188,14 @@ f_ek(ip) } void -f_everything(ip) - struct info *ip; +f_everything(struct info *ip) { print(&ip->t, &ip->win, ip->ldisc, BSD); } void -f_extproc(ip) - struct info *ip; +f_extproc(struct info *ip) { if (ip->off) { @@ -218,8 +208,7 @@ f_extproc(ip) } void -f_ispeed(ip) - struct info *ip; +f_ispeed(struct info *ip) { cfsetispeed(&ip->t, (speed_t)atoi(ip->arg)); @@ -227,8 +216,7 @@ f_ispeed(ip) } void -f_nl(ip) - struct info *ip; +f_nl(struct info *ip) { if (ip->off) { @@ -242,8 +230,7 @@ f_nl(ip) } void -f_ospeed(ip) - struct info *ip; +f_ospeed(struct info *ip) { cfsetospeed(&ip->t, (speed_t)atoi(ip->arg)); @@ -251,8 +238,7 @@ f_ospeed(ip) } void -f_raw(ip) - struct info *ip; +f_raw(struct info *ip) { if (ip->off) @@ -266,8 +252,7 @@ f_raw(ip) } void -f_rows(ip) - struct info *ip; +f_rows(struct info *ip) { ip->win.ws_row = atoi(ip->arg); @@ -275,8 +260,7 @@ f_rows(ip) } void -f_sane(ip) - struct info *ip; +f_sane(struct info *ip) { ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & CLOCAL); @@ -290,24 +274,21 @@ f_sane(ip) } void -f_size(ip) - struct info *ip; +f_size(struct info *ip) { (void)printf("%d %d\n", ip->win.ws_row, ip->win.ws_col); } void -f_speed(ip) - struct info *ip; +f_speed(struct info *ip) { (void)printf("%lu\n", (u_long)cfgetospeed(&ip->t)); } void -f_tty(ip) - struct info *ip; +f_tty(struct info *ip) { int tmp; diff --git a/bin/stty/modes.c b/bin/stty/modes.c index 926dc7d..9cfcfea 100644 --- a/bin/stty/modes.c +++ b/bin/stty/modes.c @@ -44,7 +44,7 @@ static const char rcsid[] = #include <string.h> #include "stty.h" -int msearch __P((char ***, struct info *)); +int msearch(char ***, struct info *); struct modes { const char *name; @@ -209,9 +209,7 @@ struct modes omodes[] = { #define CHK(s) (*name == s[0] && !strcmp(name, s)) int -msearch(argvp, ip) - char ***argvp; - struct info *ip; +msearch(char ***argvp, struct info *ip) { struct modes *mp; char *name; diff --git a/bin/stty/print.c b/bin/stty/print.c index 6aff06a..63fe8d6 100644 --- a/bin/stty/print.c +++ b/bin/stty/print.c @@ -50,16 +50,12 @@ static const char rcsid[] = #include <sys/ioctl_compat.h> /* XXX NTTYDISC is too well hidden */ -static void binit __P((const char *)); -static void bput __P((const char *)); -static const char *ccval __P((struct cchar *, int)); +static void binit(const char *); +static void bput(const char *); +static const char *ccval(struct cchar *, int); void -print(tp, wp, ldisc, fmt) - struct termios *tp; - struct winsize *wp; - int ldisc; - enum FMT fmt; +print(struct termios *tp, struct winsize *wp, int ldisc, enum FMT fmt) { struct cchar *p; long tmp; @@ -228,8 +224,7 @@ static int col; static const char *label; static void -binit(lb) - const char *lb; +binit(const char *lb) { if (col) { @@ -240,8 +235,7 @@ binit(lb) } static void -bput(s) - const char *s; +bput(const char *s) { if (col == 0) { @@ -257,9 +251,7 @@ bput(s) } static const char * -ccval(p, c) - struct cchar *p; - int c; +ccval(struct cchar *p, int c) { static char buf[5]; char *bp; diff --git a/bin/stty/stty.c b/bin/stty/stty.c index d794544..049667a 100644 --- a/bin/stty/stty.c +++ b/bin/stty/stty.c @@ -59,12 +59,8 @@ static const char rcsid[] = #include "stty.h" #include "extern.h" -int main __P((int, char *[])); - int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { struct info i; enum FMT fmt; @@ -160,7 +156,7 @@ args: argc -= optind; } void -usage() +usage(void) { (void)fprintf(stderr, "usage: stty [-a|-e|-g] [-f file] [options]\n"); diff --git a/bin/stty/util.c b/bin/stty/util.c index b99e83f..a5b6790 100644 --- a/bin/stty/util.c +++ b/bin/stty/util.c @@ -57,7 +57,7 @@ static const char rcsid[] = * redirected. */ void -checkredirect() +checkredirect(void) { struct stat sb1, sb2; diff --git a/bin/sync/sync.c b/bin/sync/sync.c index 019b8fd..54ea61e 100644 --- a/bin/sync/sync.c +++ b/bin/sync/sync.c @@ -48,10 +48,8 @@ static const char rcsid[] = #include <stdlib.h> #include <unistd.h> -int main __P((void)); - int -main() +main(int argc __unused, char *argv[] __unused) { sync(); exit(0); diff --git a/bin/test/test.c b/bin/test/test.c index bcb85d1..a6713a6 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -37,22 +37,10 @@ static const char rcsid[] = static void error(const char *, ...) __attribute__((__noreturn__)); static void -#ifdef __STDC__ error(const char *msg, ...) -#else -error(va_alist) - va_dcl -#endif { va_list ap; -#ifndef __STDC__ - const char *msg; - - va_start(ap); - msg = va_arg(ap, const char *); -#else va_start(ap, msg); -#endif verrx(2, msg, ap); /*NOTREACHED*/ va_end(ap); @@ -176,27 +164,25 @@ struct t_op { struct t_op const *t_wp_op; char **t_wp; -static int aexpr __P((enum token)); -static int binop __P((void)); -static int equalf __P((const char *, const char *)); -static int filstat __P((char *, enum token)); -static int getn __P((const char *)); -static long long getq __P((const char *)); -static int intcmp __P((const char *, const char *)); -static int isoperand __P((void)); -int main __P((int, char **)); -static int newerf __P((const char *, const char *)); -static int nexpr __P((enum token)); -static int oexpr __P((enum token)); -static int olderf __P((const char *, const char *)); -static int primary __P((enum token)); -static void syntax __P((const char *, const char *)); -static enum token t_lex __P((char *)); +static int aexpr(enum token); +static int binop(void); +static int equalf(const char *, const char *); +static int filstat(char *, enum token); +static int getn(const char *); +static long long getq(const char *); +static int intcmp(const char *, const char *); +static int isoperand(void); +int main(int, char **); +static int newerf(const char *, const char *); +static int nexpr(enum token); +static int oexpr(enum token); +static int olderf(const char *, const char *); +static int primary(enum token); +static void syntax(const char *, const char *); +static enum token t_lex(char *); int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { int res; char *p; @@ -232,9 +218,7 @@ main(argc, argv) } static void -syntax(op, msg) - const char *op; - const char *msg; +syntax(const char *op, const char *msg) { if (op && *op) @@ -244,8 +228,7 @@ syntax(op, msg) } static int -oexpr(n) - enum token n; +oexpr(enum token n) { int res; @@ -257,8 +240,7 @@ oexpr(n) } static int -aexpr(n) - enum token n; +aexpr(enum token n) { int res; @@ -270,8 +252,7 @@ aexpr(n) } static int -nexpr(n) - enum token n; /* token */ +nexpr(enum token n) { if (n == UNOT) return !nexpr(t_lex(*++t_wp)); @@ -279,8 +260,7 @@ nexpr(n) } static int -primary(n) - enum token n; +primary(enum token n) { enum token nn; int res; @@ -319,7 +299,7 @@ primary(n) } static int -binop() +binop(void) { const char *opnd1, *opnd2; struct t_op const *op; @@ -365,9 +345,7 @@ binop() } static int -filstat(nm, mode) - char *nm; - enum token mode; +filstat(char *nm, enum token mode) { struct stat s; @@ -420,8 +398,7 @@ filstat(nm, mode) } static enum token -t_lex(s) - char *s; +t_lex(char *s) { struct t_op const *op = ops; @@ -444,7 +421,7 @@ t_lex(s) } static int -isoperand() +isoperand(void) { struct t_op const *op = ops; char *s; @@ -465,8 +442,7 @@ isoperand() /* atoi with error detection */ static int -getn(s) - const char *s; +getn(const char *s) { char *p; long r; @@ -492,8 +468,7 @@ getn(s) /* atoi with error detection and 64 bit range */ static long long -getq(s) - const char *s; +getq(const char *s) { char *p; long long r; @@ -518,8 +493,7 @@ getq(s) } static int -intcmp (s1, s2) - const char *s1, *s2; +intcmp (const char *s1, const char *s2) { long long q1, q2; @@ -537,8 +511,7 @@ intcmp (s1, s2) } static int -newerf (f1, f2) - const char *f1, *f2; +newerf (const char *f1, const char *f2) { struct stat b1, b2; @@ -548,8 +521,7 @@ newerf (f1, f2) } static int -olderf (f1, f2) - const char *f1, *f2; +olderf (const char *f1, const char *f2) { struct stat b1, b2; @@ -559,8 +531,7 @@ olderf (f1, f2) } static int -equalf (f1, f2) - const char *f1, *f2; +equalf (const char *f1, const char *f2) { struct stat b1, b2; |