aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-29 19:41:06 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-08-29 19:41:06 +0000
commit599e554aad2738efe2fa7948c28162b0f7323a63 (patch)
treec0398d52bf44783d2dc330b4b33a908a58d2d55b /shell/hush.c
parentad8f6a3513f8b54f4e80adfcc22cab37dce40a2b (diff)
downloadbusybox-w32-599e554aad2738efe2fa7948c28162b0f7323a63.tar.gz
busybox-w32-599e554aad2738efe2fa7948c28162b0f7323a63.tar.bz2
busybox-w32-599e554aad2738efe2fa7948c28162b0f7323a63.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). git-svn-id: svn://busybox.net/trunk/busybox@16015 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c42
1 files changed, 19 insertions, 23 deletions
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);