From c3e3bc7a3882f01b4fef7ae04a7a1794e1b81988 Mon Sep 17 00:00:00 2001 From: Peter Avalos Date: Sun, 21 Aug 2011 14:21:56 -0700 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. Obtained-from: FreeBSD 223060 --- bin/sh/alias.c | 3 ++- bin/sh/alias.h | 4 +--- bin/sh/arith.h | 3 +-- bin/sh/arith_yacc.c | 1 + bin/sh/bltin/bltin.h | 7 ++----- bin/sh/cd.c | 3 ++- bin/sh/cd.h | 4 +--- bin/sh/eval.h | 11 +---------- bin/sh/exec.h | 4 +--- bin/sh/expand.c | 3 ++- bin/sh/expand.h | 3 +-- bin/sh/histedit.c | 3 ++- bin/sh/jobs.c | 3 ++- bin/sh/jobs.h | 7 +------ bin/sh/main.c | 3 ++- bin/sh/main.h | 4 +--- bin/sh/mkbuiltins | 10 +++++----- bin/sh/myhistedit.h | 4 +--- bin/sh/options.c | 3 ++- bin/sh/options.h | 5 +---- bin/sh/trap.c | 3 ++- bin/sh/trap.h | 3 +-- bin/sh/var.c | 3 ++- bin/sh/var.h | 6 +----- 24 files changed, 38 insertions(+), 65 deletions(-) diff --git a/bin/sh/alias.c b/bin/sh/alias.c index d4b222f..27d059f 100644 --- a/bin/sh/alias.c +++ b/bin/sh/alias.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)alias.c 8.3 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/alias.c,v 1.31 2011/06/04 15:05:52 jilles Exp $ + * $FreeBSD: src/bin/sh/alias.c,v 1.32 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -45,6 +45,7 @@ #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 7779ada..fe964c5 100644 --- a/bin/sh/alias.h +++ b/bin/sh/alias.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)alias.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/alias.h,v 1.10 2011/02/04 22:47:55 jilles Exp $ + * $FreeBSD: src/bin/sh/alias.h,v 1.11 2011/06/13 21:03:27 jilles Exp $ */ #define ALIASINUSE 1 @@ -47,5 +47,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 c65357a..0d6e429 100644 --- a/bin/sh/arith.h +++ b/bin/sh/arith.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)arith.h 1.1 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/arith.h,v 1.14 2011/02/08 23:18:06 jilles Exp $ + * $FreeBSD: src/bin/sh/arith.h,v 1.15 2011/06/13 21:03:27 jilles Exp $ */ #include "shell.h" @@ -40,4 +40,3 @@ arith_t arith(const char *); void arith_lex_reset(void); -int letcmd(int, char **); diff --git a/bin/sh/arith_yacc.c b/bin/sh/arith_yacc.c index cb81136..6bd1f2d 100644 --- a/bin/sh/arith_yacc.c +++ b/bin/sh/arith_yacc.c @@ -41,6 +41,7 @@ #include #include "arith.h" #include "arith_yacc.h" +#include "builtins.h" #include "expand.h" #include "shell.h" #include "error.h" diff --git a/bin/sh/bltin/bltin.h b/bin/sh/bltin/bltin.h index d0d9471..d8dd468 100644 --- a/bin/sh/bltin/bltin.h +++ b/bin/sh/bltin/bltin.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)bltin.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/bltin/bltin.h,v 1.18 2010/12/21 22:47:34 jilles Exp $ + * $FreeBSD: src/bin/sh/bltin/bltin.h,v 1.19 2011/06/13 21:03:27 jilles Exp $ */ /* @@ -47,6 +47,7 @@ #include "../mystring.h" #ifdef SHELL #include "../output.h" +#include "builtins.h" #define FILE struct output #undef stdout #define stdout out1 @@ -65,9 +66,6 @@ #define warnx warning #define warn(fmt, ...) warning(fmt ": %s", __VA_ARGS__, strerror(errno)) #define errx(exitstatus, ...) error(__VA_ARGS__) - -int main(int, char *[]); - #else #undef NULL #include @@ -79,5 +77,4 @@ int main(int, char *[]); pid_t getjobpgrp(char *); - extern char *commandname; diff --git a/bin/sh/cd.c b/bin/sh/cd.c index 8396df6..a20c7de 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)cd.c 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/cd.c,v 1.48 2011/05/27 20:01:46 jilles Exp $ + * $FreeBSD: src/bin/sh/cd.c,v 1.49 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -62,6 +62,7 @@ #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 472c5fa..be98dfb 100644 --- a/bin/sh/cd.h +++ b/bin/sh/cd.h @@ -30,9 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/bin/sh/cd.h,v 1.8 2010/04/17 14:35:46 jilles Exp $ + * $FreeBSD: src/bin/sh/cd.h,v 1.9 2011/06/13 21:03:27 jilles Exp $ */ 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 a3ec200..2bdb216 100644 --- a/bin/sh/eval.h +++ b/bin/sh/eval.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)eval.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/eval.h,v 1.14 2009/12/27 18:04:05 jilles Exp $ + * $FreeBSD: src/bin/sh/eval.h,v 1.15 2011/06/13 21:03:27 jilles Exp $ */ extern const char *commandname; /* currently executing command */ @@ -55,19 +55,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 8f37365..d8cc389 100644 --- a/bin/sh/exec.h +++ b/bin/sh/exec.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)exec.h 8.3 (Berkeley) 6/8/95 - * $FreeBSD: src/bin/sh/exec.h,v 1.22 2011/02/05 14:08:51 jilles Exp $ + * $FreeBSD: src/bin/sh/exec.h,v 1.23 2011/06/13 21:03:27 jilles Exp $ */ /* values of cmdtype */ @@ -70,7 +70,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); @@ -79,5 +78,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 4293319..44c94c4 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)expand.c 8.5 (Berkeley) 5/15/95 - * $FreeBSD: src/bin/sh/expand.c,v 1.89 2011/06/12 23:06:04 jilles Exp $ + * $FreeBSD: src/bin/sh/expand.c,v 1.90 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -75,6 +75,7 @@ #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 34c3a59..42640a8 100644 --- a/bin/sh/expand.h +++ b/bin/sh/expand.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)expand.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/expand.h,v 1.16 2011/06/12 23:06:04 jilles Exp $ + * $FreeBSD: src/bin/sh/expand.h,v 1.17 2011/06/13 21:03:27 jilles Exp $ */ struct strlist { @@ -67,4 +67,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 f51e91a..d56d57f 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)histedit.c 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/histedit.c,v 1.42 2010/12/29 19:39:51 jilles Exp $ + * $FreeBSD: src/bin/sh/histedit.c,v 1.43 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -58,6 +58,7 @@ #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 39dba19..4ee7b8a 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)jobs.c 8.5 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/jobs.c,v 1.94 2011/06/12 23:06:04 jilles Exp $ + * $FreeBSD: src/bin/sh/jobs.c,v 1.95 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -70,6 +70,7 @@ #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 9b812f8..bb6b629 100644 --- a/bin/sh/jobs.h +++ b/bin/sh/jobs.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)jobs.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/jobs.h,v 1.20 2010/06/29 22:37:45 jilles Exp $ + * $FreeBSD: src/bin/sh/jobs.h,v 1.21 2011/06/13 21:03:27 jilles Exp $ */ /* Mode argument to forkshell. Don't change FORK_FG or FORK_BG. */ @@ -92,12 +92,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 **); pid_t getjobpgrp(char *); struct job *makejob(union node *, int); pid_t forkshell(struct job *, union node *, int); diff --git a/bin/sh/main.c b/bin/sh/main.c index c95655a..fc54409 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -35,7 +35,7 @@ * * @(#) Copyright (c) 1991, 1993 The Regents of the University of California. All rights reserved. * @(#)main.c 8.6 (Berkeley) 5/28/95 - * $FreeBSD: src/bin/sh/main.c,v 1.51 2011/06/12 10:13:48 jilles Exp $ + * $FreeBSD: src/bin/sh/main.c,v 1.52 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -66,6 +66,7 @@ #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 af7e08d..32d0a56 100644 --- a/bin/sh/main.h +++ b/bin/sh/main.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)main.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/main.h,v 1.10 2009/12/25 20:21:35 jilles Exp $ + * $FreeBSD: src/bin/sh/main.h,v 1.11 2011/06/13 21:03:27 jilles Exp $ */ extern int rootpid; /* pid of main shell */ @@ -43,5 +43,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 11807d4..c907b07 100644 --- a/bin/sh/mkbuiltins +++ b/bin/sh/mkbuiltins @@ -36,7 +36,7 @@ # SUCH DAMAGE. # # @(#)mkbuiltins 8.2 (Berkeley) 5/4/95 -# $FreeBSD: src/bin/sh/mkbuiltins,v 1.17 2009/12/27 18:04:05 jilles Exp $ +# $FreeBSD: src/bin/sh/mkbuiltins,v 1.18 2011/06/13 21:03:27 jilles Exp $ temp=`/usr/bin/mktemp -t ka` havejobs=0 @@ -62,9 +62,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 '}; @@ -98,5 +96,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 999b3d4..b2f1229 100644 --- a/bin/sh/myhistedit.h +++ b/bin/sh/myhistedit.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)myhistedit.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/myhistedit.h,v 1.12 2010/06/02 19:16:58 jilles Exp $ + * $FreeBSD: src/bin/sh/myhistedit.h,v 1.13 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -43,8 +43,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 65006f5..69dbfc5 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)options.c 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/options.c,v 1.36 2011/06/04 22:19:00 jilles Exp $ + * $FreeBSD: src/bin/sh/options.c,v 1.37 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -55,6 +55,7 @@ #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 b22ad8c..a0d139e 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)options.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/options.h,v 1.15 2009/12/27 18:04:05 jilles Exp $ + * $FreeBSD: src/bin/sh/options.h,v 1.16 2011/06/13 21:03:27 jilles Exp $ */ struct shparam { @@ -114,8 +114,5 @@ void procargs(int, char **); void optschanged(void); void setparam(char **); void freeparam(volatile 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 2331100..e9f7124 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)trap.c 8.5 (Berkeley) 6/5/95 - * $FreeBSD: src/bin/sh/trap.c,v 1.45 2011/02/04 22:47:55 jilles Exp $ + * $FreeBSD: src/bin/sh/trap.c,v 1.46 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -54,6 +54,7 @@ #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 750df6e..06a0d10 100644 --- a/bin/sh/trap.h +++ b/bin/sh/trap.h @@ -34,14 +34,13 @@ * SUCH DAMAGE. * * @(#)trap.h 8.3 (Berkeley) 6/5/95 - * $FreeBSD: src/bin/sh/trap.h,v 1.15 2011/01/08 23:08:13 jilles Exp $ + * $FreeBSD: src/bin/sh/trap.h,v 1.16 2011/06/13 21:03:27 jilles Exp $ */ 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 54420b6..c100e8b 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)var.c 8.3 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/var.c,v 1.61 2011/06/12 23:06:04 jilles Exp $ + * $FreeBSD: src/bin/sh/var.c,v 1.62 2011/06/13 21:03:27 jilles Exp $ */ #include @@ -62,6 +62,7 @@ #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 7274b2b..44890e3 100644 --- a/bin/sh/var.h +++ b/bin/sh/var.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)var.h 8.2 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/var.h,v 1.23 2011/06/12 23:06:04 jilles Exp $ + * $FreeBSD: src/bin/sh/var.h,v 1.24 2011/06/13 21:03:27 jilles Exp $ */ /* @@ -127,11 +127,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); -- 1.7.7.2