aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-08-29 19:41:06 +0000
committerRob Landley <rob@landley.net>2006-08-29 19:41:06 +0000
commit88621d73980a3cb53c1f35e64a06d7cd64188987 (patch)
treec0398d52bf44783d2dc330b4b33a908a58d2d55b /shell
parent8c1eda528a19b8af18568649e8d2b1ba5bda772e (diff)
downloadbusybox-w32-88621d73980a3cb53c1f35e64a06d7cd64188987.tar.gz
busybox-w32-88621d73980a3cb53c1f35e64a06d7cd64188987.tar.bz2
busybox-w32-88621d73980a3cb53c1f35e64a06d7cd64188987.zip
Svn 16007 broke the build under gcc 4.0.3. This fixes up some of the damage
(the e2fsprogs directory is too twisty and evil to easily fix, but I plan to rewrite it anyway so I'll just bump that up in priority a bit).
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c89
-rw-r--r--shell/cmdedit.c4
-rw-r--r--shell/hush.c42
3 files changed, 53 insertions, 82 deletions
diff --git a/shell/ash.c b/shell/ash.c
index c1b2b0ed6..754c1d72b 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -1591,7 +1591,7 @@ static int varcmp(const char *, const char *);
1591static struct var **hashvar(const char *); 1591static struct var **hashvar(const char *);
1592 1592
1593 1593
1594static inline int varequal(const char *a, const char *b) { 1594static int varequal(const char *a, const char *b) {
1595 return !varcmp(a, b); 1595 return !varcmp(a, b);
1596} 1596}
1597 1597
@@ -1649,8 +1649,7 @@ static void out2str(const char *p)
1649 * This routine initializes the builtin variables. 1649 * This routine initializes the builtin variables.
1650 */ 1650 */
1651 1651
1652static inline void 1652static void initvar(void)
1653initvar(void)
1654{ 1653{
1655 struct var *vp; 1654 struct var *vp;
1656 struct var *end; 1655 struct var *end;
@@ -1674,8 +1673,7 @@ initvar(void)
1674 } while (++vp < end); 1673 } while (++vp < end);
1675} 1674}
1676 1675
1677static inline void 1676static void init(void)
1678init(void)
1679{ 1677{
1680 1678
1681 /* from input.c: */ 1679 /* from input.c: */
@@ -1860,7 +1858,7 @@ static char *stnputs(const char *, size_t, char *);
1860static char *stputs(const char *, char *); 1858static char *stputs(const char *, char *);
1861 1859
1862 1860
1863static inline char *_STPUTC(int c, char *p) { 1861static char *_STPUTC(int c, char *p) {
1864 if (p == sstrend) 1862 if (p == sstrend)
1865 p = growstackstr(); 1863 p = growstackstr();
1866 *p++ = c; 1864 *p++ = c;
@@ -2354,8 +2352,7 @@ out:
2354 * cd command. 2352 * cd command.
2355 */ 2353 */
2356 2354
2357static inline const char * 2355static const char * updatepwd(const char *dir)
2358updatepwd(const char *dir)
2359{ 2356{
2360 char *new; 2357 char *new;
2361 char *p; 2358 char *p;
@@ -2444,8 +2441,7 @@ out:
2444 * Find out what the current directory is. If we already know the current 2441 * Find out what the current directory is. If we already know the current
2445 * directory, this routine returns immediately. 2442 * directory, this routine returns immediately.
2446 */ 2443 */
2447static inline char * 2444static char * getpwd(void)
2448getpwd(void)
2449{ 2445{
2450 char *dir = getcwd(0, 0); 2446 char *dir = getcwd(0, 0);
2451 return dir ? dir : nullstr; 2447 return dir ? dir : nullstr;
@@ -3167,8 +3163,7 @@ out:
3167} 3163}
3168 3164
3169#ifdef CONFIG_ASH_CMDCMD 3165#ifdef CONFIG_ASH_CMDCMD
3170static inline char ** 3166static char ** parse_command_args(char **argv, const char **path)
3171parse_command_args(char **argv, const char **path)
3172{ 3167{
3173 char *cp, c; 3168 char *cp, c;
3174 3169
@@ -3199,8 +3194,7 @@ parse_command_args(char **argv, const char **path)
3199} 3194}
3200#endif 3195#endif
3201 3196
3202static inline int 3197static int isassignment(const char *p)
3203isassignment(const char *p)
3204{ 3198{
3205 const char *q = endofname(p); 3199 const char *q = endofname(p);
3206 if (p == q) 3200 if (p == q)
@@ -3520,8 +3514,7 @@ funcdone:
3520} 3514}
3521 3515
3522 3516
3523static inline int 3517static int goodname(const char *p)
3524goodname(const char *p)
3525{ 3518{
3526 return !*endofname(p); 3519 return !*endofname(p);
3527} 3520}
@@ -4245,8 +4238,7 @@ delete_cmd_entry(void)
4245 * the same name - except special builtins. 4238 * the same name - except special builtins.
4246 */ 4239 */
4247 4240
4248static inline void 4241static void addcmdentry(char *name, struct cmdentry *entry)
4249addcmdentry(char *name, struct cmdentry *entry)
4250{ 4242{
4251 struct tblentry *cmdp; 4243 struct tblentry *cmdp;
4252 4244
@@ -4263,8 +4255,7 @@ addcmdentry(char *name, struct cmdentry *entry)
4263 * Make a copy of a parse tree. 4255 * Make a copy of a parse tree.
4264 */ 4256 */
4265 4257
4266static inline struct funcnode * 4258static struct funcnode * copyfunc(union node *n)
4267copyfunc(union node *n)
4268{ 4259{
4269 struct funcnode *f; 4260 struct funcnode *f;
4270 size_t blocksize; 4261 size_t blocksize;
@@ -4529,8 +4520,7 @@ static void varunset(const char *, const char *, const char *, int)
4529 * Returns an stalloced string. 4520 * Returns an stalloced string.
4530 */ 4521 */
4531 4522
4532static inline char * 4523static char * preglob(const char *pattern, int quoted, int flag) {
4533preglob(const char *pattern, int quoted, int flag) {
4534 flag |= RMESCAPE_GLOB; 4524 flag |= RMESCAPE_GLOB;
4535 if (quoted) { 4525 if (quoted) {
4536 flag |= RMESCAPE_QUOTED; 4526 flag |= RMESCAPE_QUOTED;
@@ -4554,8 +4544,7 @@ esclen(const char *start, const char *p) {
4554 * Expand shell variables and backquotes inside a here document. 4544 * Expand shell variables and backquotes inside a here document.
4555 */ 4545 */
4556 4546
4557static inline void 4547static void expandhere(union node *arg, int fd)
4558expandhere(union node *arg, int fd)
4559{ 4548{
4560 herefd = fd; 4549 herefd = fd;
4561 expandarg(arg, (struct arglist *)NULL, 0); 4550 expandarg(arg, (struct arglist *)NULL, 0);
@@ -5783,8 +5772,7 @@ msort(struct strlist *list, int len)
5783 * Returns true if the pattern matches the string. 5772 * Returns true if the pattern matches the string.
5784 */ 5773 */
5785 5774
5786static inline int 5775static int patmatch(char *pattern, const char *string)
5787patmatch(char *pattern, const char *string)
5788{ 5776{
5789 return pmatch(preglob(pattern, 0, 0), string); 5777 return pmatch(preglob(pattern, 0, 0), string);
5790} 5778}
@@ -5967,7 +5955,7 @@ static int pgetc2(void)
5967 return c; 5955 return c;
5968} 5956}
5969#else 5957#else
5970static inline int pgetc2(void) 5958static int pgetc2(void)
5971{ 5959{
5972 return pgetc_macro(); 5960 return pgetc_macro();
5973} 5961}
@@ -5977,8 +5965,7 @@ static inline int pgetc2(void)
5977 * Read a line from the script. 5965 * Read a line from the script.
5978 */ 5966 */
5979 5967
5980static inline char * 5968static char * pfgets(char *line, int len)
5981pfgets(char *line, int len)
5982{ 5969{
5983 char *p = line; 5970 char *p = line;
5984 int nleft = len; 5971 int nleft = len;
@@ -6007,7 +5994,7 @@ static char *cmdedit_prompt;
6007#else 5994#else
6008static const char *cmdedit_prompt; 5995static const char *cmdedit_prompt;
6009#endif 5996#endif
6010static inline void putprompt(const char *s) 5997static void putprompt(const char *s)
6011{ 5998{
6012#ifdef CONFIG_ASH_EXPAND_PRMT 5999#ifdef CONFIG_ASH_EXPAND_PRMT
6013 free(cmdedit_prompt); 6000 free(cmdedit_prompt);
@@ -6017,14 +6004,13 @@ static inline void putprompt(const char *s)
6017#endif 6004#endif
6018} 6005}
6019#else 6006#else
6020static inline void putprompt(const char *s) 6007static void putprompt(const char *s)
6021{ 6008{
6022 out2str(s); 6009 out2str(s);
6023} 6010}
6024#endif 6011#endif
6025 6012
6026static inline int 6013static int preadfd(void)
6027preadfd(void)
6028{ 6014{
6029 int nr; 6015 int nr;
6030 char *buf = parsefile->buf; 6016 char *buf = parsefile->buf;
@@ -7120,8 +7106,7 @@ growjobtab(void)
7120 * Called with interrupts off. 7106 * Called with interrupts off.
7121 */ 7107 */
7122 7108
7123static inline void 7109static void forkchild(struct job *jp, union node *n, int mode)
7124forkchild(struct job *jp, union node *n, int mode)
7125{ 7110{
7126 int oldlvl; 7111 int oldlvl;
7127 7112
@@ -7168,8 +7153,7 @@ forkchild(struct job *jp, union node *n, int mode)
7168 jobless = 0; 7153 jobless = 0;
7169} 7154}
7170 7155
7171static inline void 7156static void forkparent(struct job *jp, union node *n, int mode, pid_t pid)
7172forkparent(struct job *jp, union node *n, int mode, pid_t pid)
7173{ 7157{
7174 TRACE(("In parent shell: child = %d\n", pid)); 7158 TRACE(("In parent shell: child = %d\n", pid));
7175 if (!jp) { 7159 if (!jp) {
@@ -7306,8 +7290,7 @@ waitforjob(struct job *jp)
7306 * and the jobs command may give out of date information. 7290 * and the jobs command may give out of date information.
7307 */ 7291 */
7308 7292
7309static inline int 7293static int waitproc(int block, int *status)
7310waitproc(int block, int *status)
7311{ 7294{
7312 int flags = 0; 7295 int flags = 0;
7313 7296
@@ -8071,8 +8054,7 @@ readcmdfile(char *name)
8071 * search for the file, which is necessary to find sub-commands. 8054 * search for the file, which is necessary to find sub-commands.
8072 */ 8055 */
8073 8056
8074static inline char * 8057static char * find_dot_file(char *name)
8075find_dot_file(char *name)
8076{ 8058{
8077 char *fullname; 8059 char *fullname;
8078 const char *path = pathval(); 8060 const char *path = pathval();
@@ -8347,8 +8329,7 @@ growstackblock(void)
8347 } 8329 }
8348} 8330}
8349 8331
8350static inline void 8332static void grabstackblock(size_t len)
8351grabstackblock(size_t len)
8352{ 8333{
8353 len = SHELL_ALIGN(len); 8334 len = SHELL_ALIGN(len);
8354 stacknxt += len; 8335 stacknxt += len;
@@ -8830,8 +8811,7 @@ optschanged(void)
8830 setvimode(viflag); 8811 setvimode(viflag);
8831} 8812}
8832 8813
8833static inline void 8814static void minus_o(char *name, int val)
8834minus_o(char *name, int val)
8835{ 8815{
8836 int i; 8816 int i;
8837 8817
@@ -10902,8 +10882,7 @@ static const char *const *findkwd(const char *s)
10902 * Open a file in noclobber mode. 10882 * Open a file in noclobber mode.
10903 * The code was copied from bash. 10883 * The code was copied from bash.
10904 */ 10884 */
10905static inline int 10885static int noclobberopen(const char *fname)
10906noclobberopen(const char *fname)
10907{ 10886{
10908 int r, fd; 10887 int r, fd;
10909 struct stat finfo, finfo2; 10888 struct stat finfo, finfo2;
@@ -10962,8 +10941,7 @@ noclobberopen(const char *fname)
10962 * the pipe without forking. 10941 * the pipe without forking.
10963 */ 10942 */
10964 10943
10965static inline int 10944static int openhere(union node *redir)
10966openhere(union node *redir)
10967{ 10945{
10968 int pip[2]; 10946 int pip[2];
10969 size_t len = 0; 10947 size_t len = 0;
@@ -11055,8 +11033,7 @@ eopen:
11055 sh_error("cannot open %s: %s", fname, errmsg(errno, E_OPEN)); 11033 sh_error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
11056} 11034}
11057 11035
11058static inline void 11036static void dupredirect(union node *redir, int f)
11059dupredirect(union node *redir, int f)
11060{ 11037{
11061 int fd = redir->nfile.fd; 11038 int fd = redir->nfile.fd;
11062 11039
@@ -12231,8 +12208,7 @@ exportcmd(int argc, char **argv)
12231 * "-" as a special case. 12208 * "-" as a special case.
12232 */ 12209 */
12233 12210
12234static inline void 12211static void mklocal(char *name)
12235mklocal(char *name)
12236{ 12212{
12237 struct localvar *lvp; 12213 struct localvar *lvp;
12238 struct var **vpp; 12214 struct var **vpp;
@@ -13186,7 +13162,7 @@ typedef unsigned char operator;
13186 13162
13187#define NUMPTR (*numstackptr) 13163#define NUMPTR (*numstackptr)
13188 13164
13189static inline int tok_have_assign(operator op) 13165static int tok_have_assign(operator op)
13190{ 13166{
13191 operator prec = PREC(op); 13167 operator prec = PREC(op);
13192 13168
@@ -13195,7 +13171,7 @@ static inline int tok_have_assign(operator op)
13195 prec == PREC_PRE || prec == PREC_POST); 13171 prec == PREC_PRE || prec == PREC_POST);
13196} 13172}
13197 13173
13198static inline int is_right_associativity(operator prec) 13174static int is_right_associativity(operator prec)
13199{ 13175{
13200 return (prec == PREC(TOK_ASSIGN) || prec == PREC(TOK_EXPONENT) || 13176 return (prec == PREC(TOK_ASSIGN) || prec == PREC(TOK_EXPONENT) ||
13201 prec == PREC(TOK_CONDITIONAL)); 13177 prec == PREC(TOK_CONDITIONAL));
@@ -13258,8 +13234,7 @@ static int arith_lookup_val(v_n_t *t)
13258/* "applying" a token means performing it on the top elements on the integer 13234/* "applying" a token means performing it on the top elements on the integer
13259 * stack. For a unary operator it will only change the top element, but a 13235 * stack. For a unary operator it will only change the top element, but a
13260 * binary operator will pop two arguments and push a result */ 13236 * binary operator will pop two arguments and push a result */
13261static inline int 13237static int arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
13262arith_apply(operator op, v_n_t *numstack, v_n_t **numstackptr)
13263{ 13238{
13264 v_n_t *numptr_m1; 13239 v_n_t *numptr_m1;
13265 arith_t numptr_val, rez; 13240 arith_t numptr_val, rez;
diff --git a/shell/cmdedit.c b/shell/cmdedit.c
index 03aaa3b2e..fb1946e83 100644
--- a/shell/cmdedit.c
+++ b/shell/cmdedit.c
@@ -247,13 +247,13 @@ static void goto_new_line(void)
247} 247}
248 248
249 249
250static inline void out1str(const char *s) 250static void out1str(const char *s)
251{ 251{
252 if ( s ) 252 if ( s )
253 fputs(s, stdout); 253 fputs(s, stdout);
254} 254}
255 255
256static inline void beep(void) 256static void beep(void)
257{ 257{
258 putchar('\007'); 258 putchar('\007');
259} 259}
diff --git a/shell/hush.c b/shell/hush.c
index 8df91a1e8..230b0fb69 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -285,7 +285,7 @@ struct built_in_command {
285}; 285};
286 286
287/* belongs in busybox.h */ 287/* belongs in busybox.h */
288static inline int max(int a, int b) { 288static int max(int a, int b) {
289 return (a>b)?a:b; 289 return (a>b)?a:b;
290} 290}
291 291
@@ -298,8 +298,14 @@ static void debug_printf(const char *format, ...)
298 vfprintf(stderr, format, args); 298 vfprintf(stderr, format, args);
299 va_end(args); 299 va_end(args);
300} 300}
301/* broken, of course, but OK for testing */
302static char *indenter(int i)
303{
304 static char blanks[]=" ";
305 return &blanks[sizeof(blanks)-i-1];
306}
301#else 307#else
302static inline void debug_printf(const char *format ATTRIBUTE_UNUSED, ...) { } 308#define debug_printf(...) do {;} while(0);
303#endif 309#endif
304#define final_printf debug_printf 310#define final_printf debug_printf
305 311
@@ -345,7 +351,6 @@ static void mark_open(int fd);
345static void mark_closed(int fd); 351static void mark_closed(int fd);
346static void close_all(void); 352static void close_all(void);
347/* "run" the final data structures: */ 353/* "run" the final data structures: */
348static char *indenter(int i);
349static int free_pipe_list(struct pipe *head, int indent); 354static int free_pipe_list(struct pipe *head, int indent);
350static int free_pipe(struct pipe *pi, int indent); 355static int free_pipe(struct pipe *pi, int indent);
351/* really run the final data structures: */ 356/* really run the final data structures: */
@@ -847,7 +852,7 @@ static int static_peek(struct in_str *i)
847 return *i->p; 852 return *i->p;
848} 853}
849 854
850static inline void cmdedit_set_initial_prompt(void) 855static void cmdedit_set_initial_prompt(void)
851{ 856{
852#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT 857#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
853 PS1 = NULL; 858 PS1 = NULL;
@@ -858,7 +863,7 @@ static inline void cmdedit_set_initial_prompt(void)
858#endif 863#endif
859} 864}
860 865
861static inline void setup_prompt_string(int promptmode, char **prompt_str) 866static void setup_prompt_string(int promptmode, char **prompt_str)
862{ 867{
863 debug_printf("setup_prompt_string %d ",promptmode); 868 debug_printf("setup_prompt_string %d ",promptmode);
864#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT 869#ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
@@ -1591,13 +1596,6 @@ static int run_list_real(struct pipe *pi)
1591 return rcode; 1596 return rcode;
1592} 1597}
1593 1598
1594/* broken, of course, but OK for testing */
1595static char *indenter(int i)
1596{
1597 static char blanks[]=" ";
1598 return &blanks[sizeof(blanks)-i-1];
1599}
1600
1601/* return code is the exit status of the pipe */ 1599/* return code is the exit status of the pipe */
1602static int free_pipe(struct pipe *pi, int indent) 1600static int free_pipe(struct pipe *pi, int indent)
1603{ 1601{
@@ -1605,29 +1603,28 @@ static int free_pipe(struct pipe *pi, int indent)
1605 struct child_prog *child; 1603 struct child_prog *child;
1606 struct redir_struct *r, *rnext; 1604 struct redir_struct *r, *rnext;
1607 int a, i, ret_code=0; 1605 int a, i, ret_code=0;
1608 char *ind = indenter(indent);
1609 1606
1610 if (pi->stopped_progs > 0) 1607 if (pi->stopped_progs > 0)
1611 return ret_code; 1608 return ret_code;
1612 final_printf("%s run pipe: (pid %d)\n",ind,getpid()); 1609 final_printf("%s run pipe: (pid %d)\n",indenter(indent),getpid());
1613 for (i=0; i<pi->num_progs; i++) { 1610 for (i=0; i<pi->num_progs; i++) {
1614 child = &pi->progs[i]; 1611 child = &pi->progs[i];
1615 final_printf("%s command %d:\n",ind,i); 1612 final_printf("%s command %d:\n",indenter(indent),i);
1616 if (child->argv) { 1613 if (child->argv) {
1617 for (a=0,p=child->argv; *p; a++,p++) { 1614 for (a=0,p=child->argv; *p; a++,p++) {
1618 final_printf("%s argv[%d] = %s\n",ind,a,*p); 1615 final_printf("%s argv[%d] = %s\n",indenter(indent),a,*p);
1619 } 1616 }
1620 globfree(&child->glob_result); 1617 globfree(&child->glob_result);
1621 child->argv=NULL; 1618 child->argv=NULL;
1622 } else if (child->group) { 1619 } else if (child->group) {
1623 final_printf("%s begin group (subshell:%d)\n",ind, child->subshell); 1620 final_printf("%s begin group (subshell:%d)\n",indenter(indent), child->subshell);
1624 ret_code = free_pipe_list(child->group,indent+3); 1621 ret_code = free_pipe_list(child->group,indent+3);
1625 final_printf("%s end group\n",ind); 1622 final_printf("%s end group\n",indenter(indent));
1626 } else { 1623 } else {
1627 final_printf("%s (nil)\n",ind); 1624 final_printf("%s (nil)\n",indenter(indent));
1628 } 1625 }
1629 for (r=child->redirects; r; r=rnext) { 1626 for (r=child->redirects; r; r=rnext) {
1630 final_printf("%s redirect %d%s", ind, r->fd, redir_table[r->type].descrip); 1627 final_printf("%s redirect %d%s", indenter(indent), r->fd, redir_table[r->type].descrip);
1631 if (r->dup == -1) { 1628 if (r->dup == -1) {
1632 /* guard against the case >$FOO, where foo is unset or blank */ 1629 /* guard against the case >$FOO, where foo is unset or blank */
1633 if (r->word.gl_pathv) { 1630 if (r->word.gl_pathv) {
@@ -1651,11 +1648,10 @@ static int free_pipe_list(struct pipe *head, int indent)
1651{ 1648{
1652 int rcode=0; /* if list has no members */ 1649 int rcode=0; /* if list has no members */
1653 struct pipe *pi, *next; 1650 struct pipe *pi, *next;
1654 char *ind = indenter(indent);
1655 for (pi=head; pi; pi=next) { 1651 for (pi=head; pi; pi=next) {
1656 final_printf("%s pipe reserved mode %d\n", ind, pi->r_mode); 1652 final_printf("%s pipe reserved mode %d\n", indenter(indent), pi->r_mode);
1657 rcode = free_pipe(pi, indent); 1653 rcode = free_pipe(pi, indent);
1658 final_printf("%s pipe followup code %d\n", ind, pi->followup); 1654 final_printf("%s pipe followup code %d\n", indenter(indent), pi->followup);
1659 next=pi->next; 1655 next=pi->next;
1660 pi->next=NULL; 1656 pi->next=NULL;
1661 free(pi); 1657 free(pi);