From 454a02b3728543503f2f30771a867148a27f71b3 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Mon, 13 Jun 2011 21:03:27 +0000 Subject: [PATCH] sh: Fix duplicate prototypes for builtins. Have mkbuiltins write the prototypes for the *cmd functions to builtins.h instead of builtins.c and include builtins.h in more .c files instead of duplicating prototypes for *cmd functions in other headers. --- bin/sh/alias.c | 1 + bin/sh/alias.h | 2 -- bin/sh/arith.h | 1 - bin/sh/bltin/bltin.h | 4 +--- bin/sh/cd.c | 1 + bin/sh/cd.h | 2 -- bin/sh/eval.h | 9 --------- bin/sh/exec.h | 2 -- bin/sh/expand.c | 1 + bin/sh/expand.h | 1 - bin/sh/histedit.c | 1 + bin/sh/jobs.c | 1 + bin/sh/jobs.h | 5 ----- bin/sh/main.c | 1 + bin/sh/main.h | 2 -- bin/sh/mkbuiltins | 8 ++++---- bin/sh/myhistedit.h | 2 -- bin/sh/options.c | 1 + bin/sh/options.h | 3 --- bin/sh/trap.c | 1 + bin/sh/trap.h | 1 - bin/sh/var.c | 1 + bin/sh/var.h | 4 ---- 23 files changed, 14 insertions(+), 41 deletions(-) diff --git a/bin/sh/alias.c b/bin/sh/alias.c index 929c68e8798a..fb0e92294431 100644 --- a/bin/sh/alias.c +++ b/bin/sh/alias.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include "mystring.h" #include "alias.h" #include "options.h" /* XXX for argptr (should remove?) */ +#include "builtins.h" #define ATABSIZE 39 diff --git a/bin/sh/alias.h b/bin/sh/alias.h index 79836639acd5..546e91a1f3f2 100644 --- a/bin/sh/alias.h +++ b/bin/sh/alias.h @@ -43,5 +43,3 @@ struct alias { }; struct alias *lookupalias(const char *, int); -int aliascmd(int, char **); -int unaliascmd(int, char **); diff --git a/bin/sh/arith.h b/bin/sh/arith.h index 3a7db9e059fb..5b18bd677ccc 100644 --- a/bin/sh/arith.h +++ b/bin/sh/arith.h @@ -36,4 +36,3 @@ arith_t arith(const char *); void arith_lex_reset(void); -int expcmd(int, char **); diff --git a/bin/sh/bltin/bltin.h b/bin/sh/bltin/bltin.h index e449673d1d0d..0143b6e27aca 100644 --- a/bin/sh/bltin/bltin.h +++ b/bin/sh/bltin/bltin.h @@ -43,6 +43,7 @@ #include "../mystring.h" #ifdef SHELL #include "../output.h" +#include "builtins.h" #define FILE struct output #undef stdout #define stdout out1 @@ -75,7 +76,4 @@ pointer stalloc(int); void error(const char *, ...) __printf0like(1, 2); pid_t getjobpgrp(char *); -int echocmd(int, char **); -int testcmd(int, char **); - extern char *commandname; diff --git a/bin/sh/cd.c b/bin/sh/cd.c index b1b0fc015e9e..6fb10390a239 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include "mystring.h" #include "show.h" #include "cd.h" +#include "builtins.h" static int cdlogical(char *); static int cdphysical(char *); diff --git a/bin/sh/cd.h b/bin/sh/cd.h index f88ce26ad4c6..91fbc2b692aa 100644 --- a/bin/sh/cd.h +++ b/bin/sh/cd.h @@ -30,5 +30,3 @@ */ void pwd_init(int); -int cdcmd (int, char **); -int pwdcmd(int, char **); diff --git a/bin/sh/eval.h b/bin/sh/eval.h index bf987828d0cb..fba6f9a2a9c9 100644 --- a/bin/sh/eval.h +++ b/bin/sh/eval.h @@ -51,19 +51,10 @@ struct backcmd { /* result of evalbackcmd */ #define EV_TESTED 02 /* exit status is checked; ignore -e flag */ #define EV_BACKCMD 04 /* command executing within back quotes */ -int evalcmd(int, char **); void evalstring(char *, int); union node; /* BLETCH for ansi C */ 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 **); -int timescmd(int, char **); -int commandcmd(int, char **); /* in_function returns nonzero if we are currently evaluating a function */ #define in_function() funcnest diff --git a/bin/sh/exec.h b/bin/sh/exec.h index 392cc335f660..31f11c09c287 100644 --- a/bin/sh/exec.h +++ b/bin/sh/exec.h @@ -66,7 +66,6 @@ extern int exerrno; /* last exec error */ void shellexec(char **, char **, const char *, int) __dead2; char *padvance(const char **, const char *); -int hashcmd(int, char **); void find_command(const char *, struct cmdentry *, int, const char *); int find_builtin(const char *, int *); void hashcd(void); @@ -75,5 +74,4 @@ void addcmdentry(const char *, struct cmdentry *); void defun(const char *, union node *); int unsetfunc(const char *); int typecmd_impl(int, char **, int, const char *); -int typecmd(int, char **); void clearcmdentry(void); diff --git a/bin/sh/expand.c b/bin/sh/expand.c index c6c54ab6f3c1..95a0d6ad15d0 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include "mystring.h" #include "arith.h" #include "show.h" +#include "builtins.h" /* * Structure specifying which parts of the string should be searched diff --git a/bin/sh/expand.h b/bin/sh/expand.h index a4bb198010af..5029552fe284 100644 --- a/bin/sh/expand.h +++ b/bin/sh/expand.h @@ -63,4 +63,3 @@ void expari(int); int patmatch(const char *, const char *, int); void rmescapes(char *); int casematch(union node *, const char *); -int wordexpcmd(int, char **); diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index 7ebe5d87502a..4619baf7856e 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include "error.h" #include "eval.h" #include "memalloc.h" +#include "builtins.h" #define MAXHISTLOOPS 4 /* max recursions through fc */ #define DEFEDITOR "ed" /* default editor *should* be $EDITOR */ diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index cbc29f175644..75b503ecaa79 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$"); #include "error.h" #include "mystring.h" #include "var.h" +#include "builtins.h" static struct job *jobtab; /* array of jobs */ diff --git a/bin/sh/jobs.h b/bin/sh/jobs.h index 8bc10821a02b..5e9d70db0434 100644 --- a/bin/sh/jobs.h +++ b/bin/sh/jobs.h @@ -88,12 +88,7 @@ extern int in_dowait; /* are we in dowait()? */ extern volatile sig_atomic_t breakwaitcmd; /* break wait to process traps? */ void setjobctl(int); -int fgcmd(int, char **); -int bgcmd(int, char **); -int jobscmd(int, char **); void showjobs(int, int); -int waitcmd(int, char **); -int jobidcmd(int, char **); struct job *makejob(union node *, int); pid_t forkshell(struct job *, union node *, int); int waitforjob(struct job *, int *); diff --git a/bin/sh/main.c b/bin/sh/main.c index 2da5a15a9276..e6c8a209de5b 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$"); #include "mystring.h" #include "exec.h" #include "cd.h" +#include "builtins.h" int rootpid; int rootshell; diff --git a/bin/sh/main.h b/bin/sh/main.h index c5e8bfd38405..6d4cc4a9b992 100644 --- a/bin/sh/main.h +++ b/bin/sh/main.h @@ -39,5 +39,3 @@ extern struct jmploc main_handler; /* top level exception handler */ void readcmdfile(const char *); void cmdloop(int); -int dotcmd(int, char **); -int exitcmd(int, char **); diff --git a/bin/sh/mkbuiltins b/bin/sh/mkbuiltins index b78729ac9ea1..49af058461c1 100755 --- a/bin/sh/mkbuiltins +++ b/bin/sh/mkbuiltins @@ -58,9 +58,7 @@ cat <<\! ! awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \ print $0}' builtins.def | sed 's/-[hj]//' > $temp -awk '{ printf "int %s(int, char **);\n", $1}' $temp -echo ' -int (*const builtinfunc[])(int, char **) = {' +echo 'int (*const builtinfunc[])(int, char **) = {' awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp echo '}; @@ -94,5 +92,7 @@ struct builtincmd { }; extern int (*const builtinfunc[])(int, char **); -extern const struct builtincmd builtincmd[];' +extern const struct builtincmd builtincmd[]; +' +awk '{ printf "int %s(int, char **);\n", $1}' $temp rm -f $temp diff --git a/bin/sh/myhistedit.h b/bin/sh/myhistedit.h index bc9fd4eddda1..9a649ecccddf 100644 --- a/bin/sh/myhistedit.h +++ b/bin/sh/myhistedit.h @@ -39,8 +39,6 @@ extern int displayhist; void histedit(void); void sethistsize(const char *); void setterm(const char *); -int histcmd(int, char **); int not_fcnumber(const char *); int str_to_event(const char *, int); -int bindcmd(int, char **); diff --git a/bin/sh/options.c b/bin/sh/options.c index 60c885284f75..9104e93270fc 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$"); #include "memalloc.h" #include "error.h" #include "mystring.h" +#include "builtins.h" #ifndef NO_HISTORY #include "myhistedit.h" #endif diff --git a/bin/sh/options.h b/bin/sh/options.h index 5004549a2926..f3d3d3db4569 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -108,8 +108,5 @@ 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(const char *); void getoptsreset(const char *); diff --git a/bin/sh/trap.c b/bin/sh/trap.c index aaa4753c7e55..2b6d8a585e4a 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$"); #include "error.h" #include "trap.h" #include "mystring.h" +#include "builtins.h" #include "myhistedit.h" diff --git a/bin/sh/trap.h b/bin/sh/trap.h index d8686ceaadde..bf1250a85b87 100644 --- a/bin/sh/trap.h +++ b/bin/sh/trap.h @@ -37,7 +37,6 @@ extern int pendingsigs; extern int in_dotrap; extern volatile sig_atomic_t gotwinch; -int trapcmd(int, char **); void clear_traps(void); int have_traps(void); void setsignal(int); diff --git a/bin/sh/var.c b/bin/sh/var.c index e405b666ba77..d5b252230cb0 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #include "error.h" #include "mystring.h" #include "parser.h" +#include "builtins.h" #ifndef NO_HISTORY #include "myhistedit.h" #endif diff --git a/bin/sh/var.h b/bin/sh/var.h index f10bfcc7ad57..347c3777c36d 100644 --- a/bin/sh/var.h +++ b/bin/sh/var.h @@ -123,11 +123,7 @@ void updatecharset(void); void initcharset(void); char **environment(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(const char *); int setvarsafe(const char *, const char *, int);