summaryrefslogtreecommitdiffstats
path: root/bin/sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/sh')
-rw-r--r--bin/sh/Makefile2
-rw-r--r--bin/sh/alias.c18
-rw-r--r--bin/sh/cd.c32
-rw-r--r--bin/sh/error.c4
-rw-r--r--bin/sh/eval.c36
-rw-r--r--bin/sh/exec.c16
-rw-r--r--bin/sh/expand.c70
-rw-r--r--bin/sh/histedit.c4
-rw-r--r--bin/sh/input.c8
-rw-r--r--bin/sh/jobs.c48
-rw-r--r--bin/sh/main.c8
-rw-r--r--bin/sh/memalloc.c2
-rw-r--r--bin/sh/nodes.c.pat28
-rw-r--r--bin/sh/options.c16
-rw-r--r--bin/sh/output.c4
-rw-r--r--bin/sh/parser.c88
-rw-r--r--bin/sh/redir.c8
-rw-r--r--bin/sh/shell.h9
-rw-r--r--bin/sh/show.c20
-rw-r--r--bin/sh/trap.c8
-rw-r--r--bin/sh/var.c16
21 files changed, 218 insertions, 227 deletions
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index f679935..0c06c90 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -21,7 +21,7 @@ LDADD= -ll -ledit -ltermcap
LFLAGS= -8 # 8-bit lex scanner for arithmetic
CFLAGS+=-DSHELL -I. -I${.CURDIR}
# for debug:
-# DEBUG_FLAGS+= -g -DDEBUG=3 -fno-inline
+# DEBUG_FLAGS+= -g -DDEBUG=2 -fno-inline
WARNS?= 2
WFORMAT=0
diff --git a/bin/sh/alias.c b/bin/sh/alias.c
index 5605b70..c815b92 100644
--- a/bin/sh/alias.c
+++ b/bin/sh/alias.c
@@ -52,11 +52,11 @@ __FBSDID("$FreeBSD$");
static struct alias *atab[ATABSIZE];
static int aliases;
-STATIC void setalias(const char *, const char *);
-STATIC int unalias(const char *);
-STATIC struct alias **hashalias(const char *);
+static void setalias(const char *, const char *);
+static int unalias(const char *);
+static struct alias **hashalias(const char *);
-STATIC
+static
void
setalias(const char *name, const char *val)
{
@@ -111,7 +111,7 @@ setalias(const char *name, const char *val)
INTON;
}
-STATIC int
+static int
unalias(const char *name)
{
struct alias *ap, **app;
@@ -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;
@@ -276,7 +276,7 @@ unaliascmd(int argc __unused, char **argv __unused)
return (i);
}
-STATIC struct alias **
+static struct alias **
hashalias(const char *p)
{
unsigned int hashval;
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index b63928c..cec7496 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -64,14 +64,14 @@ __FBSDID("$FreeBSD$");
#include "show.h"
#include "cd.h"
-STATIC int cdlogical(char *);
-STATIC int cdphysical(char *);
-STATIC int docd(char *, int, int);
-STATIC char *getcomponent(void);
-STATIC char *findcwd(char *);
-STATIC void updatepwd(char *);
-STATIC char *getpwd(void);
-STATIC char *getpwd2(void);
+static int cdlogical(char *);
+static int cdphysical(char *);
+static int docd(char *, int, int);
+static char *getcomponent(void);
+static char *findcwd(char *);
+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 */
@@ -145,7 +145,7 @@ cdcmd(int argc, char **argv)
* Actually change the directory. In an interactive shell, print the
* directory name if "print" is nonzero.
*/
-STATIC int
+static int
docd(char *dest, int print, int phys)
{
@@ -161,7 +161,7 @@ docd(char *dest, int print, int phys)
return 0;
}
-STATIC int
+static int
cdlogical(char *dest)
{
char *p;
@@ -213,7 +213,7 @@ cdlogical(char *dest)
return (0);
}
-STATIC int
+static int
cdphysical(char *dest)
{
char *p;
@@ -232,7 +232,7 @@ cdphysical(char *dest)
* Get the next component of the path name pointed to by cdcomppath.
* This routine overwrites the string pointed to by cdcomppath.
*/
-STATIC char *
+static char *
getcomponent(void)
{
char *p;
@@ -253,7 +253,7 @@ getcomponent(void)
}
-STATIC char *
+static char *
findcwd(char *dir)
{
char *new;
@@ -296,7 +296,7 @@ findcwd(char *dir)
* cd command. We also call hashcd to let the routines in exec.c know
* that the current directory has changed.
*/
-STATIC void
+static void
updatepwd(char *dir)
{
hashcd(); /* update command hash table */
@@ -352,7 +352,7 @@ pwdcmd(int argc, char **argv)
/*
* Get the current directory and cache the result in curdir.
*/
-STATIC char *
+static char *
getpwd(void)
{
char *p;
@@ -372,7 +372,7 @@ getpwd(void)
/*
* Return the current directory.
*/
-STATIC char *
+static char *
getpwd2(void)
{
char *pwd;
diff --git a/bin/sh/error.c b/bin/sh/error.c
index a722ee1..beb75fa 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 6d73a0f..499751d 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -87,15 +87,15 @@ int exitstatus; /* exit status of last command */
int oexitstatus; /* saved exit status */
-STATIC void evalloop(union node *, int);
-STATIC void evalfor(union node *, int);
-STATIC void evalcase(union node *, int);
-STATIC void evalsubshell(union node *, int);
-STATIC void evalredir(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 *);
+static void evalloop(union node *, int);
+static void evalfor(union node *, int);
+static void evalcase(union node *, int);
+static void evalsubshell(union node *, int);
+static void evalredir(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 *);
/*
@@ -289,7 +289,7 @@ out:
}
-STATIC void
+static void
evalloop(union node *n, int flags)
{
int status;
@@ -327,7 +327,7 @@ skipping: if (evalskip == SKIPCONT && --skipcount <= 0) {
-STATIC void
+static void
evalfor(union node *n, int flags)
{
struct arglist arglist;
@@ -367,7 +367,7 @@ out:
-STATIC void
+static void
evalcase(union node *n, int flags)
{
union node *cp;
@@ -400,7 +400,7 @@ out:
* Kick off a subshell to evaluate a tree.
*/
-STATIC void
+static void
evalsubshell(union node *n, int flags)
{
struct job *jp;
@@ -425,7 +425,7 @@ evalsubshell(union node *n, int flags)
* Evaluate a redirected compound command.
*/
-STATIC void
+static void
evalredir(union node *n, int flags)
{
struct jmploc jmploc;
@@ -466,7 +466,7 @@ evalredir(union node *n, int flags)
* Compute the names of the files in a redirection list.
*/
-STATIC void
+static void
expredir(union node *n)
{
union node *redir;
@@ -504,7 +504,7 @@ expredir(union node *n)
* of all the rest.)
*/
-STATIC void
+static void
evalpipe(union node *n)
{
struct job *jp;
@@ -617,7 +617,7 @@ out:
* Execute a simple command.
*/
-STATIC void
+static void
evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
{
struct stackmark smark;
@@ -1028,7 +1028,7 @@ out:
* check that the name will not be subject to expansion.
*/
-STATIC void
+static void
prehash(union node *n)
{
struct cmdentry entry;
diff --git a/bin/sh/exec.c b/bin/sh/exec.c
index fe83c7f..e104b63 100644
--- a/bin/sh/exec.c
+++ b/bin/sh/exec.c
@@ -96,10 +96,10 @@ static int builtinloc = -1; /* index in path of %builtin, or -1 */
int exerrno = 0; /* Last exec error */
-STATIC void tryexec(char *, char **, char **);
-STATIC void printentry(struct tblentry *, int);
-STATIC struct tblentry *cmdlookup(const char *, int);
-STATIC void delete_cmd_entry(void);
+static void tryexec(char *, char **, char **);
+static void printentry(struct tblentry *, int);
+static struct tblentry *cmdlookup(const char *, int);
+static void delete_cmd_entry(void);
@@ -147,7 +147,7 @@ shellexec(char **argv, char **envp, const char *path, int idx)
}
-STATIC void
+static void
tryexec(char *cmd, char **argv, char **envp)
{
int e;
@@ -265,7 +265,7 @@ hashcmd(int argc __unused, char **argv __unused)
}
-STATIC void
+static void
printentry(struct tblentry *cmdp, int verbose)
{
int idx;
@@ -618,7 +618,7 @@ deletefuncs(void)
static struct tblentry **lastcmdentry;
-STATIC struct tblentry *
+static struct tblentry *
cmdlookup(const char *name, int add)
{
int hashval;
@@ -655,7 +655,7 @@ cmdlookup(const char *name, int add)
* Delete the command entry returned on the last lookup.
*/
-STATIC void
+static void
delete_cmd_entry(void)
{
struct tblentry *cmdp;
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index f5a2f23..d33f0ac 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -95,25 +95,25 @@ 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);
-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, 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 char *cvtnum(int, char *);
-STATIC int collate_range_cmp(int, int);
-
-STATIC int
+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, 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 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];
@@ -210,7 +210,7 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
* characters to allow for further processing.
* If EXP_FULL is set, also preserve CTLQUOTEMARK characters.
*/
-STATIC void
+static void
argstr(char *p, int flag)
{
char c;
@@ -276,7 +276,7 @@ breakloop:;
* Perform tilde expansion, placing the result in the stack string and
* returning the next position in the input string to process.
*/
-STATIC char *
+static char *
exptilde(char *p, int flag)
{
char c, *startp = p;
@@ -329,7 +329,7 @@ lose:
}
-STATIC void
+static void
removerecordregions(int endoff)
{
if (ifslastp == NULL)
@@ -428,7 +428,7 @@ expari(int flag)
/*
* Perform command substitution.
*/
-STATIC void
+static void
expbackq(union node *cmd, int quoted, int flag)
{
struct backcmd in;
@@ -508,7 +508,7 @@ expbackq(union node *cmd, int quoted, int flag)
-STATIC int
+static int
subevalvar(char *p, char *str, int strloc, int subtype, int startloc,
int varflags)
{
@@ -636,7 +636,7 @@ recordleft:
* input string.
*/
-STATIC char *
+static char *
evalvar(char *p, int flag)
{
int subtype;
@@ -824,7 +824,7 @@ record:
* Test whether a specialized variable is set.
*/
-STATIC int
+static int
varisset(char *name, int nulok)
{
@@ -866,7 +866,7 @@ varisset(char *name, int nulok)
* Add the value of a specialized variable to the stack string.
*/
-STATIC void
+static void
varvalue(char *name, int quoted, int subtype, int flag)
{
int num;
@@ -956,7 +956,7 @@ numvar:
* string for IFS characters.
*/
-STATIC void
+static void
recordregion(int start, int end, int inquotes)
{
struct ifsregion *ifsp;
@@ -993,7 +993,7 @@ recordregion(int start, int end, int inquotes)
* This pass treats them as a regular character, making the string non-empty.
* Later, they are removed along with the other CTL* characters.
*/
-STATIC void
+static void
ifsbreakup(char *string, struct arglist *arglist)
{
struct ifsregion *ifsp;
@@ -1101,7 +1101,7 @@ static char expdir[PATH_MAX];
* At this point, the only control characters should be CTLESC and CTLQUOTEMARK.
* The results are stored in the list exparg.
*/
-STATIC void
+static void
expandmeta(struct strlist *str, int flag __unused)
{
char *p;
@@ -1148,7 +1148,7 @@ nometa:
* Do metacharacter (i.e. *, ?, [...]) expansion.
*/
-STATIC void
+static void
expmeta(char *enddir, char *name)
{
char *p;
@@ -1284,7 +1284,7 @@ expmeta(char *enddir, char *name)
* Add a file name to the list.
*/
-STATIC void
+static void
addfname(char *name)
{
char *p;
@@ -1305,7 +1305,7 @@ addfname(char *name)
* work.
*/
-STATIC struct strlist *
+static struct strlist *
expsort(struct strlist *str)
{
int len;
@@ -1318,7 +1318,7 @@ expsort(struct strlist *str)
}
-STATIC struct strlist *
+static struct strlist *
msort(struct strlist *list, int len)
{
struct strlist *p, *q = NULL;
@@ -1541,7 +1541,7 @@ casematch(union node *pattern, const char *val)
* Our own itoa().
*/
-STATIC char *
+static char *
cvtnum(int num, char *buf)
{
char temp[32];
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
index d92a7a3..7773ad8 100644
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -68,7 +68,7 @@ EditLine *el; /* editline cookie */
int displayhist;
static FILE *el_in, *el_out, *el_err;
-STATIC char *fc_replace(const char *, char *, char *);
+static char *fc_replace(const char *, char *, char *);
/*
* Set history and editing status. Called whenever the status may
@@ -402,7 +402,7 @@ histcmd(int argc, char **argv)
return 0;
}
-STATIC char *
+static char *
fc_replace(const char *s, char *p, char *r)
{
char *dest;
diff --git a/bin/sh/input.c b/bin/sh/input.c
index bd68339..21a9134 100644
--- a/bin/sh/input.c
+++ b/bin/sh/input.c
@@ -104,8 +104,8 @@ int whichprompt; /* 1 == PS1, 2 == PS2 */
EditLine *el; /* cookie for editline package */
-STATIC void pushfile(void);
-STATIC int preadfd(void);
+static void pushfile(void);
+static int preadfd(void);
#ifdef mkinit
INCLUDE "input.h"
@@ -169,7 +169,7 @@ pgetc(void)
}
-STATIC int
+static int
preadfd(void)
{
int nr;
@@ -468,7 +468,7 @@ setinputstring(char *string, int push)
* adds a new entry to the stack and popfile restores the previous level.
*/
-STATIC void
+static void
pushfile(void)
{
struct parsefile *pf;
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index 7540742..bd01e5df 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -86,21 +86,21 @@ volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */
static int ttyfd = -1;
#if JOBS
-STATIC void restartjob(struct job *);
+static void restartjob(struct job *);
#endif
-STATIC void freejob(struct job *);
-STATIC struct job *getjob(char *);
-STATIC pid_t dowait(int, struct job *);
-STATIC pid_t waitproc(int, int *);
-STATIC void checkzombies(void);
-STATIC void cmdtxt(union node *);
-STATIC void cmdputs(const char *);
+static void freejob(struct job *);
+static struct job *getjob(char *);
+static pid_t dowait(int, struct job *);
+static pid_t waitproc(int, int *);
+static void checkzombies(void);
+static void cmdtxt(union node *);
+static void cmdputs(const char *);
#if JOBS
-STATIC void setcurjob(struct job *);
-STATIC void deljob(struct job *);
-STATIC struct job *getcurjob(struct job *);
+static void setcurjob(struct job *);
+static void deljob(struct job *);
+static struct job *getcurjob(struct job *);
#endif
-STATIC void showjob(struct job *, pid_t, int);
+static void showjob(struct job *, pid_t, int);
/*
@@ -242,7 +242,7 @@ bgcmd(int argc, char **argv)
}
-STATIC void
+static void
restartjob(struct job *jp)
{
struct procstat *ps;
@@ -301,7 +301,7 @@ jobscmd(int argc, char *argv[])
return (0);
}
-STATIC void
+static void
showjob(struct job *jp, pid_t pid, int mode)
{
char s[64];
@@ -430,7 +430,7 @@ showjobs(int change, int mode)
* Mark a job structure as unused.
*/
-STATIC void
+static void
freejob(struct job *jp)
{
struct procstat *ps;
@@ -543,7 +543,7 @@ jobidcmd(int argc __unused, char **argv)
* Convert a job name to a job structure.
*/
-STATIC struct job *
+static struct job *
getjob(char *name)
{
int jobno;
@@ -686,7 +686,7 @@ makejob(union node *node __unused, int nprocs)
}
#if JOBS
-STATIC void
+static void
setcurjob(struct job *cj)
{
struct job *jp, *prev;
@@ -706,7 +706,7 @@ setcurjob(struct job *cj)
jobmru = cj;
}
-STATIC void
+static void
deljob(struct job *j)
{
struct job *jp, *prev;
@@ -726,7 +726,7 @@ deljob(struct job *j)
* Return the most recently used job that isn't `nj', and preferably one
* that is stopped.
*/
-STATIC struct job *
+static struct job *
getcurjob(struct job *nj)
{
struct job *jp;
@@ -950,7 +950,7 @@ waitforjob(struct job *jp, int *origstatus)
* Wait for a process to terminate.
*/
-STATIC pid_t
+static pid_t
dowait(int block, struct job *job)
{
pid_t pid;
@@ -1061,7 +1061,7 @@ dowait(int block, struct job *job)
* stopped processes. If block is zero, we return a value of zero
* rather than blocking.
*/
-STATIC pid_t
+static pid_t
waitproc(int block, int *status)
{
int flags;
@@ -1102,7 +1102,7 @@ stoppedjobs(void)
}
-STATIC void
+static void
checkzombies(void)
{
while (njobs > 0 && dowait(0, NULL) > 0)
@@ -1147,7 +1147,7 @@ commandtext(union node *n)
}
-STATIC void
+static void
cmdtxt(union node *n)
{
union node *np;
@@ -1280,7 +1280,7 @@ redir:
-STATIC void
+static void
cmdputs(const char *s)
{
const char *p;
diff --git a/bin/sh/main.c b/bin/sh/main.c
index b9e4424..83a62a7 100644
--- a/bin/sh/main.c
+++ b/bin/sh/main.c
@@ -77,8 +77,8 @@ int rootpid;
int rootshell;
struct jmploc main_handler;
-STATIC void read_profile(const char *);
-STATIC char *find_dot_file(char *);
+static void read_profile(const char *);
+static char *find_dot_file(char *);
/*
* Main routine. We initialize things, parse the arguments, execute
@@ -247,7 +247,7 @@ cmdloop(int top)
* Read /etc/profile or .profile. Return on error.
*/
-STATIC void
+static void
read_profile(const char *name)
{
int fd;
@@ -291,7 +291,7 @@ readcmdfile(const char *name)
*/
-STATIC char *
+static char *
find_dot_file(char *basename)
{
static char localname[FILENAME_MAX+1];
diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c
index 90d2595..01bddb2 100644
--- a/bin/sh/memalloc.c
+++ b/bin/sh/memalloc.c
@@ -131,7 +131,7 @@ int sstrnleft;
int herefd = -1;
-STATIC void
+static void
stnewblock(int nbytes)
{
struct stack_block *sp;
diff --git a/bin/sh/nodes.c.pat b/bin/sh/nodes.c.pat
index 1f5adbb..b325d76 100644
--- a/bin/sh/nodes.c.pat
+++ b/bin/sh/nodes.c.pat
@@ -46,19 +46,19 @@
#include "mystring.h"
-STATIC int funcblocksize; /* size of structures in function */
-STATIC int funcstringsize; /* size of strings in node */
-STATIC pointer funcblock; /* block to allocate function from */
-STATIC char *funcstring; /* block to allocate strings from */
+static int funcblocksize; /* size of structures in function */
+static int funcstringsize; /* size of strings in node */
+static pointer funcblock; /* block to allocate function from */
+static char *funcstring; /* block to allocate strings from */
%SIZES
-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 *);
+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 *);
struct funcdef {
@@ -96,7 +96,7 @@ getfuncnode(struct funcdef *fn)
}
-STATIC void
+static void
calcsize(union node *n)
{
%CALCSIZE
@@ -104,7 +104,7 @@ calcsize(union node *n)
-STATIC void
+static void
sizenodelist(struct nodelist *lp)
{
while (lp) {
@@ -116,7 +116,7 @@ sizenodelist(struct nodelist *lp)
-STATIC union node *
+static union node *
copynode(union node *n)
{
union node *new;
@@ -126,7 +126,7 @@ copynode(union node *n)
}
-STATIC struct nodelist *
+static struct nodelist *
copynodelist(struct nodelist *lp)
{
struct nodelist *start;
@@ -146,7 +146,7 @@ copynodelist(struct nodelist *lp)
-STATIC char *
+static char *
nodesavestr(char *s)
{
char *p = s;
diff --git a/bin/sh/options.c b/bin/sh/options.c
index 3baeccc..af80036 100644
--- a/bin/sh/options.c
+++ b/bin/sh/options.c
@@ -69,10 +69,10 @@ char *nextopt_optptr; /* used by nextopt */
char *minusc; /* argument to -c option */
-STATIC void options(int);
-STATIC void minus_o(char *, int);
-STATIC void setoption(int, int);
-STATIC int getopts(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 **);
/*
@@ -138,7 +138,7 @@ optschanged(void)
* to the argument list; we advance it past the options.
*/
-STATIC void
+static void
options(int cmdline)
{
char *kp, *p;
@@ -247,7 +247,7 @@ end_options2:
}
}
-STATIC void
+static void
minus_o(char *name, int val)
{
int i;
@@ -284,7 +284,7 @@ minus_o(char *name, int val)
}
-STATIC void
+static void
setoption(int flag, int val)
{
int i;
@@ -451,7 +451,7 @@ getoptscmd(int argc, char **argv)
&shellparam.optptr);
}
-STATIC int
+static int
getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
char **optptr)
{
diff --git a/bin/sh/output.c b/bin/sh/output.c
index 87f1245..9fd8478 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};
@@ -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 5bcd37a..018b698 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -105,25 +105,25 @@ static struct parser_temp *parser_temp;
static int noaliases = 0;
-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) __dead2;
-STATIC void synerror(const char *) __dead2;
-STATIC void setprompt(int);
-
-
-STATIC void *
+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) __dead2;
+static void synerror(const char *) __dead2;
+static void setprompt(int);
+
+
+static void *
parser_temp_alloc(size_t len)
{
struct parser_temp *t;
@@ -139,7 +139,7 @@ parser_temp_alloc(size_t len)
}
-STATIC void *
+static void *
parser_temp_realloc(void *ptr, size_t len)
{
struct parser_temp *t;
@@ -154,7 +154,7 @@ parser_temp_realloc(void *ptr, size_t len)
}
-STATIC void
+static void
parser_temp_free_upto(void *ptr)
{
struct parser_temp *t;
@@ -174,7 +174,7 @@ parser_temp_free_upto(void *ptr)
}
-STATIC void
+static void
parser_temp_free_all(void)
{
struct parser_temp *t;
@@ -223,7 +223,7 @@ parsecmd(int interact)
}
-STATIC union node *
+static union node *
list(int nlflag)
{
union node *n1, *n2, *n3;
@@ -296,7 +296,7 @@ list(int nlflag)
-STATIC union node *
+static union node *
andor(void)
{
union node *n1, *n2, *n3;
@@ -323,7 +323,7 @@ andor(void)
-STATIC union node *
+static union node *
pipeline(void)
{
union node *n1, *n2, *pipenode;
@@ -365,7 +365,7 @@ pipeline(void)
-STATIC union node *
+static union node *
command(void)
{
union node *n1, *n2;
@@ -608,7 +608,7 @@ checkneg:
}
-STATIC union node *
+static union node *
simplecmd(union node **rpp, union node *redir)
{
union node *args, **app;
@@ -670,7 +670,7 @@ simplecmd(union node **rpp, union node *redir)
return n;
}
-STATIC union node *
+static union node *
makename(void)
{
union node *n;
@@ -704,7 +704,7 @@ fixredir(union node *n, const char *text, int err)
}
-STATIC void
+static void
parsefname(void)
{
union node *n = redirnode;
@@ -746,7 +746,7 @@ parsefname(void)
* Input any here documents.
*/
-STATIC void
+static void
parseheredoc(void)
{
struct heredoc *here;
@@ -770,7 +770,7 @@ parseheredoc(void)
}
}
-STATIC int
+static int
peektoken(void)
{
int t;
@@ -780,7 +780,7 @@ peektoken(void)
return (t);
}
-STATIC int
+static int
readtoken(void)
{
int t;
@@ -860,7 +860,7 @@ out:
#define RETURN(token) return lasttoken = token
-STATIC int
+static int
xxreadtoken(void)
{
int c;
@@ -931,7 +931,7 @@ breakloop:
}
-#define MAXNEST_STATIC 8
+#define MAXNEST_static 8
struct tokenstate
{
const char *syntax; /* *SYNTAX */
@@ -950,7 +950,7 @@ struct tokenstate
* Called to parse command substitutions.
*/
-STATIC char *
+static char *
parsebackq(char *out, struct nodelist **pbqlist,
int oldstyle, int dblquote, int quoted)
{
@@ -1131,7 +1131,7 @@ done:
#define PARSESUB() {goto parsesub; parsesub_return:;}
#define PARSEARITH() {goto parsearith; parsearith_return:;}
-STATIC int
+static int
readtoken1(int firstc, char const *initialsyntax, char *eofmark, int striptabs)
{
int c = firstc;
@@ -1143,8 +1143,8 @@ readtoken1(int firstc, char const *initialsyntax, char *eofmark, int striptabs)
int newvarnest;
int level;
int synentry;
- struct tokenstate state_static[MAXNEST_STATIC];
- int maxnest = MAXNEST_STATIC;
+ struct tokenstate state_static[MAXNEST_static];
+ int maxnest = MAXNEST_static;
struct tokenstate *state = state_static;
startlinno = plinno;
@@ -1554,7 +1554,7 @@ parsesub: {
state = parser_temp_alloc(
maxnest * sizeof(*state));
memcpy(state, state_static,
- MAXNEST_STATIC * sizeof(*state));
+ MAXNEST_static * sizeof(*state));
} else
state = parser_temp_realloc(state,
maxnest * sizeof(*state));
@@ -1597,7 +1597,7 @@ parsearith: {
state = parser_temp_alloc(
maxnest * sizeof(*state));
memcpy(state, state_static,
- MAXNEST_STATIC * sizeof(*state));
+ MAXNEST_static * sizeof(*state));
} else
state = parser_temp_realloc(state,
maxnest * sizeof(*state));
@@ -1630,7 +1630,7 @@ RESET {
* or backquotes).
*/
-STATIC int
+static int
noexpand(char *text)
{
char *p;
@@ -1676,7 +1676,7 @@ goodname(const char *name)
* occur at this point.
*/
-STATIC void
+static void
synexpect(int token)
{
char msg[64];
@@ -1691,7 +1691,7 @@ synexpect(int token)
}
-STATIC void
+static void
synerror(const char *msg)
{
if (commandname)
@@ -1700,7 +1700,7 @@ synerror(const char *msg)
error((char *)NULL);
}
-STATIC void
+static void
setprompt(int which)
{
whichprompt = which;
diff --git a/bin/sh/redir.c b/bin/sh/redir.c
index e83fcaf..f3ad3af 100644
--- a/bin/sh/redir.c
+++ b/bin/sh/redir.c
@@ -83,8 +83,8 @@ MKINIT struct redirtab *redirlist;
*/
static int fd0_redirected = 0;
-STATIC void openredirect(union node *, char[10 ]);
-STATIC int openhere(union node *);
+static void openredirect(union node *, char[10 ]);
+static int openhere(union node *);
/*
@@ -148,7 +148,7 @@ redirect(union node *redir, int flags)
}
-STATIC void
+static void
openredirect(union node *redir, char memory[10])
{
struct stat sb;
@@ -240,7 +240,7 @@ movefd:
* the pipe without forking.
*/
-STATIC int
+static int
openhere(union node *redir)
{
int pip[2];
diff --git a/bin/sh/shell.h b/bin/sh/shell.h
index 7f59be2..9bf399f 100644
--- a/bin/sh/shell.h
+++ b/bin/sh/shell.h
@@ -43,7 +43,6 @@
* JOBS -> 1 if you have Berkeley job control, 0 otherwise.
* define DEBUG=1 to compile in debugging (set global "debug" to turn on)
* define DEBUG=2 to compile in and turn on debugging.
- * define DEBUG=3 to also build all functions as public
*
* When debugging is on, debugging info will be written to ./trace and
* a quit signal will generate a core dump.
@@ -62,14 +61,6 @@ 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 aca2620..7cb3547 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 979ad73..3a6803b 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 0b47fb0..27bbf50 100644
--- a/bin/sh/var.c
+++ b/bin/sh/var.c
@@ -135,9 +135,9 @@ static const int locale_categories[7] = {
LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, LC_MESSAGES, 0
};
-STATIC struct var **hashvar(const char *);
-STATIC int varequal(const char *, const char *);
-STATIC int localevar(const char *);
+static struct var **hashvar(const char *);
+static int varequal(const char *, const char *);
+static int localevar(const char *);
/*
* Initialize the variable symbol tables and import the environment.
@@ -268,7 +268,7 @@ setvar(const char *name, const char *val, int flags)
setvareq(nameeq, flags);
}
-STATIC int
+static int
localevar(const char *s)
{
const char *const *ss;
@@ -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;
@@ -909,7 +909,7 @@ unsetvar(const char *s)
* Find the appropriate entry in the hash table from the name.
*/
-STATIC struct var **
+static struct var **
hashvar(const char *p)
{
unsigned int hashval;
@@ -928,7 +928,7 @@ hashvar(const char *p)
* either '=' or '\0'.
*/
-STATIC int
+static int
varequal(const char *p, const char *q)
{
while (*p == *q++) {
OpenPOWER on IntegriCloud