diff options
author | obrien <obrien@FreeBSD.org> | 2010-10-13 04:01:01 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2010-10-13 04:01:01 +0000 |
commit | f31ad1c86b4755ef67582377762ce84fa733658b (patch) | |
tree | 9c3469b15542c1ab6cc58c5974f1da71c59da708 /bin | |
parent | 8c097aa69ed7151df0358afc55a9bec6e7ae8b1a (diff) | |
download | FreeBSD-src-f31ad1c86b4755ef67582377762ce84fa733658b.zip FreeBSD-src-f31ad1c86b4755ef67582377762ce84fa733658b.tar.gz |
Consistently use "STATIC" for all functions in order to be able to set
breakpoints with in a debugger. And use naked "static" for variables.
Noticed by: bde
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/alias.c | 10 | ||||
-rw-r--r-- | bin/sh/cd.c | 6 | ||||
-rw-r--r-- | bin/sh/error.c | 4 | ||||
-rw-r--r-- | bin/sh/eval.c | 4 | ||||
-rw-r--r-- | bin/sh/exec.c | 6 | ||||
-rw-r--r-- | bin/sh/expand.c | 12 | ||||
-rw-r--r-- | bin/sh/input.c | 6 | ||||
-rw-r--r-- | bin/sh/jobs.c | 12 | ||||
-rw-r--r-- | bin/sh/mail.c | 4 | ||||
-rw-r--r-- | bin/sh/memalloc.c | 6 | ||||
-rw-r--r-- | bin/sh/output.c | 6 | ||||
-rw-r--r-- | bin/sh/parser.c | 27 | ||||
-rw-r--r-- | bin/sh/redir.c | 2 | ||||
-rw-r--r-- | bin/sh/shell.h | 3 | ||||
-rw-r--r-- | bin/sh/show.c | 20 | ||||
-rw-r--r-- | bin/sh/trap.c | 8 | ||||
-rw-r--r-- | bin/sh/var.c | 14 |
17 files changed, 77 insertions, 73 deletions
diff --git a/bin/sh/alias.c b/bin/sh/alias.c index 00b7fa7..5605b70 100644 --- a/bin/sh/alias.c +++ b/bin/sh/alias.c @@ -49,8 +49,8 @@ __FBSDID("$FreeBSD$"); #define ATABSIZE 39 -STATIC struct alias *atab[ATABSIZE]; -STATIC int aliases; +static struct alias *atab[ATABSIZE]; +static int aliases; STATIC void setalias(const char *, const char *); STATIC int unalias(const char *); @@ -191,7 +191,7 @@ lookupalias(const char *name, int check) return (NULL); } -static int +STATIC int comparealiases(const void *p1, const void *p2) { const struct alias *const *a1 = p1; @@ -200,7 +200,7 @@ comparealiases(const void *p1, const void *p2) return strcmp((*a1)->name, (*a2)->name); } -static void +STATIC void printalias(const struct alias *a) { char *p; @@ -214,7 +214,7 @@ printalias(const struct alias *a) out1c('\n'); } -static void +STATIC void printaliases(void) { int i, j; diff --git a/bin/sh/cd.c b/bin/sh/cd.c index aee06e8..b63928c 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -73,9 +73,9 @@ STATIC void updatepwd(char *); STATIC char *getpwd(void); STATIC char *getpwd2(void); -STATIC char *curdir = NULL; /* current working directory */ -STATIC char *prevdir; /* previous working directory */ -STATIC char *cdcomppath; +static char *curdir = NULL; /* current working directory */ +static char *prevdir; /* previous working directory */ +static char *cdcomppath; int cdcmd(int argc, char **argv) diff --git a/bin/sh/error.c b/bin/sh/error.c index beb75fa..a722ee1 100644 --- a/bin/sh/error.c +++ b/bin/sh/error.c @@ -67,7 +67,7 @@ volatile sig_atomic_t intpending; char *commandname; -static void exverror(int, const char *, va_list) __printf0like(2, 0) __dead2; +STATIC void exverror(int, const char *, va_list) __printf0like(2, 0) __dead2; /* * Called to raise an exception. Since C doesn't include exceptions, we @@ -139,7 +139,7 @@ onint(void) * is not NULL then error prints an error message using printf style * formatting. It then raises the error exception. */ -static void +STATIC void exverror(int cond, const char *msg, va_list ap) { /* diff --git a/bin/sh/eval.c b/bin/sh/eval.c index 29923c7..6d73a0f 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -75,10 +75,10 @@ __FBSDID("$FreeBSD$"); int evalskip; /* set if we are skipping commands */ -STATIC int skipcount; /* number of levels to skip */ +static int skipcount; /* number of levels to skip */ MKINIT int loopnest; /* current loop nesting level */ int funcnest; /* depth of function calls */ -STATIC int builtin_flags; /* evalcommand flags for builtins */ +static int builtin_flags; /* evalcommand flags for builtins */ char *commandname; diff --git a/bin/sh/exec.c b/bin/sh/exec.c index 7c15f79..fe83c7f 100644 --- a/bin/sh/exec.c +++ b/bin/sh/exec.c @@ -91,8 +91,8 @@ struct tblentry { }; -STATIC struct tblentry *cmdtable[CMDTABLESIZE]; -STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */ +static struct tblentry *cmdtable[CMDTABLESIZE]; +static int builtinloc = -1; /* index in path of %builtin, or -1 */ int exerrno = 0; /* Last exec error */ @@ -615,7 +615,7 @@ deletefuncs(void) * entry. */ -STATIC struct tblentry **lastcmdentry; +static struct tblentry **lastcmdentry; STATIC struct tblentry * diff --git a/bin/sh/expand.c b/bin/sh/expand.c index b2da92b..65f50f5 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -88,11 +88,11 @@ struct ifsregion { }; -STATIC char *expdest; /* output of current string */ -STATIC struct nodelist *argbackq; /* list of back quote expressions */ -STATIC struct ifsregion ifsfirst; /* first struct in list of ifs regions */ -STATIC struct ifsregion *ifslastp; /* last struct in list */ -STATIC struct arglist exparg; /* holds expanded arg list */ +static char *expdest; /* output of current string */ +static struct nodelist *argbackq; /* list of back quote expressions */ +static struct ifsregion ifsfirst; /* first struct in list of ifs regions */ +static struct ifsregion *ifslastp; /* last struct in list */ +static struct arglist exparg; /* holds expanded arg list */ STATIC void argstr(char *, int); STATIC char *exptilde(char *, int); @@ -1092,7 +1092,7 @@ ifsbreakup(char *string, struct arglist *arglist) } -STATIC char expdir[PATH_MAX]; +static char expdir[PATH_MAX]; #define expdir_end (expdir + sizeof(expdir)) /* diff --git a/bin/sh/input.c b/bin/sh/input.c index c801e62..bd68339 100644 --- a/bin/sh/input.c +++ b/bin/sh/input.c @@ -98,14 +98,14 @@ MKINIT int parselleft; /* copy of parsefile->lleft */ char *parsenextc; /* copy of parsefile->nextc */ MKINIT struct parsefile basepf; /* top level input file */ char basebuf[BUFSIZ]; /* buffer for top level input file */ -STATIC struct parsefile *parsefile = &basepf; /* current input file */ +static struct parsefile *parsefile = &basepf; /* current input file */ int init_editline = 0; /* editline library initialized? */ int whichprompt; /* 1 == PS1, 2 == PS2 */ EditLine *el; /* cookie for editline package */ STATIC void pushfile(void); -static int preadfd(void); +STATIC int preadfd(void); #ifdef mkinit INCLUDE "input.h" @@ -169,7 +169,7 @@ pgetc(void) } -static int +STATIC int preadfd(void) { int nr; diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index f55b637..7740302 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -72,13 +72,13 @@ __FBSDID("$FreeBSD$"); #include "mystring.h" -STATIC struct job *jobtab; /* array of jobs */ -STATIC int njobs; /* size of array */ +static struct job *jobtab; /* array of jobs */ +static int njobs; /* size of array */ MKINIT pid_t backgndpid = -1; /* pid of last background process */ MKINIT struct job *bgjob = NULL; /* last background process */ #if JOBS -STATIC struct job *jobmru; /* most recently used job list */ -STATIC pid_t initialpgrp; /* pgrp of shell on invocation */ +static struct job *jobmru; /* most recently used job list */ +static pid_t initialpgrp; /* pgrp of shell on invocation */ #endif int in_waitcmd = 0; /* are we in waitcmd()? */ int in_dowait = 0; /* are we in dowait()? */ @@ -1130,8 +1130,8 @@ backgndpidval(void) * jobs command. */ -STATIC char *cmdnextc; -STATIC int cmdnleft; +static char *cmdnextc; +static int cmdnleft; #define MAXCMDTEXT 200 char * diff --git a/bin/sh/mail.c b/bin/sh/mail.c index 0ba7be5..597e733 100644 --- a/bin/sh/mail.c +++ b/bin/sh/mail.c @@ -57,8 +57,8 @@ __FBSDID("$FreeBSD$"); #define MAXMBOXES 10 -STATIC int nmboxes; /* number of mailboxes */ -STATIC time_t mailtime[MAXMBOXES]; /* times of mailboxes */ +static int nmboxes; /* number of mailboxes */ +static time_t mailtime[MAXMBOXES]; /* times of mailboxes */ diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index 9d5332f..90d2595 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -123,15 +123,15 @@ struct stack_block { }; #define SPACE(sp) ((char*)(sp) + ALIGN(sizeof(struct stack_block))) -STATIC struct stack_block *stackp; -STATIC struct stackmark *markp; +static struct stack_block *stackp; +static struct stackmark *markp; char *stacknxt; int stacknleft; int sstrnleft; int herefd = -1; -static void +STATIC void stnewblock(int nbytes) { struct stack_block *sp; diff --git a/bin/sh/output.c b/bin/sh/output.c index fd03e23..87f1245 100644 --- a/bin/sh/output.c +++ b/bin/sh/output.c @@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$"); #define MEM_OUT -3 /* output to dynamically allocated memory */ #define OUTPUT_ERR 01 /* error occurred on output */ -static int doformat_wr(void *, const char *, int); +STATIC int doformat_wr(void *, const char *, int); struct output output = {NULL, 0, NULL, OUTBUFSIZ, 1, 0}; struct output errout = {NULL, 0, NULL, 256, 2, 0}; @@ -165,7 +165,7 @@ outqstr(const char *p, struct output *file) outc('\'', file); } -STATIC char out_junk[16]; +static char out_junk[16]; void emptyoutbuf(struct output *dest) @@ -281,7 +281,7 @@ fmtstr(char *outbuf, int length, const char *fmt, ...) outbuf[length - 1] = '\0'; } -static int +STATIC int doformat_wr(void *cookie, const char *buf, int len) { struct output *o; diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 02012ef..5bcd37a 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -86,20 +86,20 @@ struct parser_temp { }; -STATIC struct heredoc *heredoclist; /* list of here documents to read */ -STATIC int doprompt; /* if set, prompt the user */ -STATIC int needprompt; /* true if interactive and at start of line */ -STATIC int lasttoken; /* last token read */ +static struct heredoc *heredoclist; /* list of here documents to read */ +static int doprompt; /* if set, prompt the user */ +static int needprompt; /* true if interactive and at start of line */ +static int lasttoken; /* last token read */ MKINIT int tokpushback; /* last token pushed back */ -STATIC char *wordtext; /* text of last word returned by readtoken */ +static char *wordtext; /* text of last word returned by readtoken */ MKINIT int checkkwd; /* 1 == check for kwds, 2 == also eat newlines */ -STATIC struct nodelist *backquotelist; -STATIC union node *redirnode; -STATIC struct heredoc *heredoc; -STATIC int quoteflag; /* set if (part of) last token was quoted */ -STATIC int startlinno; /* line # where last token started */ -STATIC int funclinno; /* line # where the current function started */ -STATIC struct parser_temp *parser_temp; +static struct nodelist *backquotelist; +static union node *redirnode; +static struct heredoc *heredoc; +static int quoteflag; /* set if (part of) last token was quoted */ +static int startlinno; /* line # where last token started */ +static int funclinno; /* line # where the current function started */ +static struct parser_temp *parser_temp; /* XXX When 'noaliases' is set to one, no alias expansion takes place. */ static int noaliases = 0; @@ -683,7 +683,8 @@ makename(void) return n; } -void fixredir(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) diff --git a/bin/sh/redir.c b/bin/sh/redir.c index 2239b9f..e83fcaf 100644 --- a/bin/sh/redir.c +++ b/bin/sh/redir.c @@ -81,7 +81,7 @@ MKINIT struct redirtab *redirlist; * background commands, where we want to redirect fd0 to /dev/null only * if it hasn't already been redirected. */ -STATIC int fd0_redirected = 0; +static int fd0_redirected = 0; STATIC void openredirect(union node *, char[10 ]); STATIC int openhere(union node *); diff --git a/bin/sh/shell.h b/bin/sh/shell.h index cb1be84..7f59be2 100644 --- a/bin/sh/shell.h +++ b/bin/sh/shell.h @@ -62,11 +62,14 @@ typedef intmax_t arith_t; #define strtoarith_t(nptr, endptr, base) strtoimax(nptr, endptr, base) typedef void *pointer; + +/* STATIC is only for use with functions, not variables. */ #if DEBUG >= 3 #define STATIC #else #define STATIC static #endif + #define MKINIT /* empty */ #include <sys/cdefs.h> diff --git a/bin/sh/show.c b/bin/sh/show.c index 7cb3547..aca2620 100644 --- a/bin/sh/show.c +++ b/bin/sh/show.c @@ -52,11 +52,11 @@ __FBSDID("$FreeBSD$"); #ifdef DEBUG -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 *); +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 @@ -67,7 +67,7 @@ showtree(union node *n) } -static void +STATIC void shtree(union node *n, int ind, char *pfx, FILE *fp) { struct nodelist *lp; @@ -118,7 +118,7 @@ binop: -static void +STATIC void shcmd(union node *cmd, FILE *fp) { union node *np; @@ -169,7 +169,7 @@ shcmd(union node *cmd, FILE *fp) -static void +STATIC void sharg(union node *arg, FILE *fp) { char *p; @@ -254,7 +254,7 @@ sharg(union node *arg, FILE *fp) } -static void +STATIC void indent(int amount, char *pfx, FILE *fp) { int i; @@ -317,7 +317,7 @@ trputs(const char *s) } -static void +STATIC void trstring(char *s) { char *p; diff --git a/bin/sh/trap.c b/bin/sh/trap.c index 3a6803b..979ad73 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -80,7 +80,7 @@ static volatile sig_atomic_t gotsig[NSIG]; static int ignore_sigchld; /* Used while handling SIGCHLD traps. */ volatile sig_atomic_t gotwinch; -static int getsigaction(int, sig_t *); +STATIC int getsigaction(int, sig_t *); /* @@ -88,7 +88,7 @@ static int getsigaction(int, sig_t *); * * Note: the signal number may exceed NSIG. */ -static int +STATIC int sigstring_to_signum(char *sig) { @@ -116,7 +116,7 @@ sigstring_to_signum(char *sig) /* * Print a list of valid signal names. */ -static void +STATIC void printsignals(void) { int n, outlen; @@ -334,7 +334,7 @@ setsignal(int signo) /* * Return the current setting for sig w/o changing it. */ -static int +STATIC int getsigaction(int signo, sig_t *sigact) { struct sigaction sa; diff --git a/bin/sh/var.c b/bin/sh/var.c index 8ff6426..0b47fb0 100644 --- a/bin/sh/var.c +++ b/bin/sh/var.c @@ -91,9 +91,9 @@ struct var vps1; struct var vps2; struct var vps4; struct var vvers; -STATIC struct var voptind; +static struct var voptind; -STATIC const struct varinit varinit[] = { +static const struct varinit varinit[] = { #ifndef NO_HISTORY { &vhistsize, VUNSET, "HISTSIZE=", sethistsize }, @@ -125,13 +125,13 @@ STATIC const struct varinit varinit[] = { NULL } }; -STATIC struct var *vartab[VTABSIZE]; +static struct var *vartab[VTABSIZE]; -STATIC const char *const locale_names[7] = { +static const char *const locale_names[7] = { "LC_COLLATE", "LC_CTYPE", "LC_MONETARY", "LC_NUMERIC", "LC_TIME", "LC_MESSAGES", NULL }; -STATIC const int locale_categories[7] = { +static const int locale_categories[7] = { LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, LC_MESSAGES, 0 }; @@ -292,7 +292,7 @@ localevar(const char *s) * Sets/unsets an environment variable from a pointer that may actually be a * pointer into environ where the string should not be manipulated. */ -static void +STATIC void change_env(const char *s, int set) { char *eqp; @@ -579,7 +579,7 @@ shprocvar(void) } -static int +STATIC int var_compare(const void *a, const void *b) { const char *const *sa, *const *sb; |