Date: Wed, 13 Oct 2010 04:01:01 +0000 (UTC) From: "David E. O'Brien" <obrien@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r213760 - head/bin/sh Message-ID: <201010130401.o9D4117F071699@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: obrien Date: Wed Oct 13 04:01:01 2010 New Revision: 213760 URL: http://svn.freebsd.org/changeset/base/213760 Log: 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 Modified: head/bin/sh/alias.c head/bin/sh/cd.c head/bin/sh/error.c head/bin/sh/eval.c head/bin/sh/exec.c head/bin/sh/expand.c head/bin/sh/input.c head/bin/sh/jobs.c head/bin/sh/mail.c head/bin/sh/memalloc.c head/bin/sh/output.c head/bin/sh/parser.c head/bin/sh/redir.c head/bin/sh/shell.h head/bin/sh/show.c head/bin/sh/trap.c head/bin/sh/var.c Modified: head/bin/sh/alias.c ============================================================================== --- head/bin/sh/alias.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/alias.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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 voi 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; Modified: head/bin/sh/cd.c ============================================================================== --- head/bin/sh/cd.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/cd.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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) Modified: head/bin/sh/error.c ============================================================================== --- head/bin/sh/error.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/error.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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) { /* Modified: head/bin/sh/eval.c ============================================================================== --- head/bin/sh/eval.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/eval.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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; Modified: head/bin/sh/exec.c ============================================================================== --- head/bin/sh/exec.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/exec.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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 * Modified: head/bin/sh/expand.c ============================================================================== --- head/bin/sh/expand.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/expand.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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 } -STATIC char expdir[PATH_MAX]; +static char expdir[PATH_MAX]; #define expdir_end (expdir + sizeof(expdir)) /* Modified: head/bin/sh/input.c ============================================================================== --- head/bin/sh/input.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/input.c Wed Oct 13 04:01:01 2010 (r213760) @@ -98,14 +98,14 @@ MKINIT int parselleft; /* copy of parse 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; Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/jobs.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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 * Modified: head/bin/sh/mail.c ============================================================================== --- head/bin/sh/mail.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/mail.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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 */ Modified: head/bin/sh/memalloc.c ============================================================================== --- head/bin/sh/memalloc.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/memalloc.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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; Modified: head/bin/sh/output.c ============================================================================== --- head/bin/sh/output.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/output.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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 *fi 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 c outbuf[length - 1] = '\0'; } -static int +STATIC int doformat_wr(void *cookie, const char *buf, int len) { struct output *o; Modified: head/bin/sh/parser.c ============================================================================== --- head/bin/sh/parser.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/parser.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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) Modified: head/bin/sh/redir.c ============================================================================== --- head/bin/sh/redir.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/redir.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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 *); Modified: head/bin/sh/shell.h ============================================================================== --- head/bin/sh/shell.h Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/shell.h Wed Oct 13 04:01:01 2010 (r213760) @@ -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> Modified: head/bin/sh/show.c ============================================================================== --- head/bin/sh/show.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/show.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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; Modified: head/bin/sh/trap.c ============================================================================== --- head/bin/sh/trap.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/trap.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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; Modified: head/bin/sh/var.c ============================================================================== --- head/bin/sh/var.c Wed Oct 13 02:11:59 2010 (r213759) +++ head/bin/sh/var.c Wed Oct 13 04:01:01 2010 (r213760) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010130401.o9D4117F071699>