diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-23 22:07:07 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-07-23 22:07:07 +0200 |
commit | 86e83ec4872ee1d3156a5c019fde301497819ca3 (patch) | |
tree | f3347ea1ac6178857f073d76414b30892a2f4612 /shell/ash.c | |
parent | 7cc5a504658f0ebf5d7d0d457c1a907898ac68af (diff) | |
download | busybox-w32-86e83ec4872ee1d3156a5c019fde301497819ca3.tar.gz busybox-w32-86e83ec4872ee1d3156a5c019fde301497819ca3.tar.bz2 busybox-w32-86e83ec4872ee1d3156a5c019fde301497819ca3.zip |
ash: fix debug machinery a bit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/shell/ash.c b/shell/ash.c index 027dc7c6f..304251662 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -640,6 +640,12 @@ union node { | |||
640 | struct nnot nnot; | 640 | struct nnot nnot; |
641 | }; | 641 | }; |
642 | 642 | ||
643 | /* | ||
644 | * NODE_EOF is returned by parsecmd when it encounters an end of file. | ||
645 | * It must be distinct from NULL. | ||
646 | */ | ||
647 | #define NODE_EOF ((union node *) -1L) | ||
648 | |||
643 | struct nodelist { | 649 | struct nodelist { |
644 | struct nodelist *next; | 650 | struct nodelist *next; |
645 | union node *n; | 651 | union node *n; |
@@ -954,6 +960,12 @@ shtree(union node *n, int ind, char *pfx, FILE *fp) | |||
954 | return; | 960 | return; |
955 | 961 | ||
956 | indent(ind, pfx, fp); | 962 | indent(ind, pfx, fp); |
963 | |||
964 | if (n == NODE_EOF) { | ||
965 | fputs("<EOF>", fp); | ||
966 | return; | ||
967 | } | ||
968 | |||
957 | switch (n->type) { | 969 | switch (n->type) { |
958 | case NSEMI: | 970 | case NSEMI: |
959 | s = "; "; | 971 | s = "; "; |
@@ -10143,12 +10155,6 @@ static char *wordtext; /* text of last word returned by readtoke | |||
10143 | static struct nodelist *backquotelist; | 10155 | static struct nodelist *backquotelist; |
10144 | static union node *redirnode; | 10156 | static union node *redirnode; |
10145 | static struct heredoc *heredoc; | 10157 | static struct heredoc *heredoc; |
10146 | /* | ||
10147 | * NEOF is returned by parsecmd when it encounters an end of file. It | ||
10148 | * must be distinct from NULL, so we use the address of a variable that | ||
10149 | * happens to be handy. | ||
10150 | */ | ||
10151 | #define NEOF ((union node *)&tokpushback) | ||
10152 | 10158 | ||
10153 | /* | 10159 | /* |
10154 | * Called when an unexpected token is read during the parse. The argument | 10160 | * Called when an unexpected token is read during the parse. The argument |
@@ -11680,8 +11686,8 @@ peektoken(void) | |||
11680 | } | 11686 | } |
11681 | 11687 | ||
11682 | /* | 11688 | /* |
11683 | * Read and parse a command. Returns NEOF on end of file. (NULL is a | 11689 | * Read and parse a command. Returns NODE_EOF on end of file. |
11684 | * valid parse tree indicating a blank line.) | 11690 | * (NULL is a valid parse tree indicating a blank line.) |
11685 | */ | 11691 | */ |
11686 | static union node * | 11692 | static union node * |
11687 | parsecmd(int interact) | 11693 | parsecmd(int interact) |
@@ -11695,7 +11701,7 @@ parsecmd(int interact) | |||
11695 | needprompt = 0; | 11701 | needprompt = 0; |
11696 | t = readtoken(); | 11702 | t = readtoken(); |
11697 | if (t == TEOF) | 11703 | if (t == TEOF) |
11698 | return NEOF; | 11704 | return NODE_EOF; |
11699 | if (t == TNL) | 11705 | if (t == TNL) |
11700 | return NULL; | 11706 | return NULL; |
11701 | tokpushback = 1; | 11707 | tokpushback = 1; |
@@ -11770,7 +11776,7 @@ evalstring(char *s, int mask) | |||
11770 | setstackmark(&smark); | 11776 | setstackmark(&smark); |
11771 | 11777 | ||
11772 | skip = 0; | 11778 | skip = 0; |
11773 | while ((n = parsecmd(0)) != NEOF) { | 11779 | while ((n = parsecmd(0)) != NODE_EOF) { |
11774 | evaltree(n, 0); | 11780 | evaltree(n, 0); |
11775 | popstackmark(&smark); | 11781 | popstackmark(&smark); |
11776 | skip = evalskip; | 11782 | skip = evalskip; |
@@ -11844,10 +11850,10 @@ cmdloop(int top) | |||
11844 | } | 11850 | } |
11845 | n = parsecmd(inter); | 11851 | n = parsecmd(inter); |
11846 | #if DEBUG > 2 | 11852 | #if DEBUG > 2 |
11847 | if (debug && (n != NEOF)) | 11853 | if (debug && (n != NODE_EOF)) |
11848 | showtree(n); | 11854 | showtree(n); |
11849 | #endif | 11855 | #endif |
11850 | if (n == NEOF) { | 11856 | if (n == NODE_EOF) { |
11851 | if (!top || numeof >= 50) | 11857 | if (!top || numeof >= 50) |
11852 | break; | 11858 | break; |
11853 | if (!stoppedjobs()) { | 11859 | if (!stoppedjobs()) { |