aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-05-23 17:43:00 +0000
committerMatt Kraai <kraai@debian.org>2001-05-23 17:43:00 +0000
commitbdd4eced8475919c9768c5aa1396e674397c63fd (patch)
treefe0252ec243bc3128f09144cedc531e5155e6069
parent774d135b66f4ba914ee8649ce6e8c3f7d3e36c35 (diff)
downloadbusybox-w32-bdd4eced8475919c9768c5aa1396e674397c63fd.tar.gz
busybox-w32-bdd4eced8475919c9768c5aa1396e674397c63fd.tar.bz2
busybox-w32-bdd4eced8475919c9768c5aa1396e674397c63fd.zip
Commit a patch by Larry Doolittle which fixes recursive calls to file_peek,
and improves some debugging messages.
-rw-r--r--hush.c15
-rw-r--r--shell/hush.c15
2 files changed, 16 insertions, 14 deletions
diff --git a/hush.c b/hush.c
index 40787a464..0dc2d62f8 100644
--- a/hush.c
+++ b/hush.c
@@ -278,6 +278,7 @@ typedef struct {
278 * available? Where is it documented? */ 278 * available? Where is it documented? */
279struct in_str { 279struct in_str {
280 const char *p; 280 const char *p;
281 char peek_buf[2];
281 int __promptme; 282 int __promptme;
282 int promptmode; 283 int promptmode;
283 FILE *file; 284 FILE *file;
@@ -932,12 +933,11 @@ static int file_peek(struct in_str *i)
932 if (i->p && *i->p) { 933 if (i->p && *i->p) {
933 return *i->p; 934 return *i->p;
934 } else { 935 } else {
935 static char buffer[2]; 936 i->peek_buf[0] = fgetc(i->file);
936 buffer[0] = fgetc(i->file); 937 i->peek_buf[1] = '\0';
937 buffer[1] = '\0'; 938 i->p = i->peek_buf;
938 i->p = buffer;
939 debug_printf("b_peek: got a %d\n", *i->p); 939 debug_printf("b_peek: got a %d\n", *i->p);
940 return *i->p; 940 return *i->p;
941 } 941 }
942} 942}
943 943
@@ -1513,8 +1513,8 @@ static int run_list_real(struct pipe *pi)
1513 perror_msg("tcsetpgrp-4"); 1513 perror_msg("tcsetpgrp-4");
1514 } else { 1514 } else {
1515 rcode = pipe_wait(pi); 1515 rcode = pipe_wait(pi);
1516 debug_printf("pipe_wait returned %d\n",rcode);
1517 } 1516 }
1517 debug_printf("pipe_wait returned %d\n",rcode);
1518 } 1518 }
1519 last_return_code=rcode; 1519 last_return_code=rcode;
1520 if ( rmode == RES_IF || rmode == RES_ELIF ) 1520 if ( rmode == RES_IF || rmode == RES_ELIF )
@@ -2347,7 +2347,7 @@ int parse_stream(o_string *dest, struct p_context *ctx,
2347 done_pipe(ctx,PIPE_SEQ); 2347 done_pipe(ctx,PIPE_SEQ);
2348 } 2348 }
2349 if (ch == end_trigger && !dest->quote && ctx->w==RES_NONE) { 2349 if (ch == end_trigger && !dest->quote && ctx->w==RES_NONE) {
2350 debug_printf("leaving parse_stream\n"); 2350 debug_printf("leaving parse_stream (triggered)\n");
2351 return 0; 2351 return 0;
2352 } 2352 }
2353#if 0 2353#if 0
@@ -2471,6 +2471,7 @@ int parse_stream(o_string *dest, struct p_context *ctx,
2471 * that is, we were really supposed to get end_trigger, and never got 2471 * that is, we were really supposed to get end_trigger, and never got
2472 * one before the EOF. Can't use the standard "syntax error" return code, 2472 * one before the EOF. Can't use the standard "syntax error" return code,
2473 * so that parse_stream_outer can distinguish the EOF and exit smoothly. */ 2473 * so that parse_stream_outer can distinguish the EOF and exit smoothly. */
2474 debug_printf("leaving parse_stream (EOF)\n");
2474 if (end_trigger != '\0') return -1; 2475 if (end_trigger != '\0') return -1;
2475 return 0; 2476 return 0;
2476} 2477}
diff --git a/shell/hush.c b/shell/hush.c
index 40787a464..0dc2d62f8 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -278,6 +278,7 @@ typedef struct {
278 * available? Where is it documented? */ 278 * available? Where is it documented? */
279struct in_str { 279struct in_str {
280 const char *p; 280 const char *p;
281 char peek_buf[2];
281 int __promptme; 282 int __promptme;
282 int promptmode; 283 int promptmode;
283 FILE *file; 284 FILE *file;
@@ -932,12 +933,11 @@ static int file_peek(struct in_str *i)
932 if (i->p && *i->p) { 933 if (i->p && *i->p) {
933 return *i->p; 934 return *i->p;
934 } else { 935 } else {
935 static char buffer[2]; 936 i->peek_buf[0] = fgetc(i->file);
936 buffer[0] = fgetc(i->file); 937 i->peek_buf[1] = '\0';
937 buffer[1] = '\0'; 938 i->p = i->peek_buf;
938 i->p = buffer;
939 debug_printf("b_peek: got a %d\n", *i->p); 939 debug_printf("b_peek: got a %d\n", *i->p);
940 return *i->p; 940 return *i->p;
941 } 941 }
942} 942}
943 943
@@ -1513,8 +1513,8 @@ static int run_list_real(struct pipe *pi)
1513 perror_msg("tcsetpgrp-4"); 1513 perror_msg("tcsetpgrp-4");
1514 } else { 1514 } else {
1515 rcode = pipe_wait(pi); 1515 rcode = pipe_wait(pi);
1516 debug_printf("pipe_wait returned %d\n",rcode);
1517 } 1516 }
1517 debug_printf("pipe_wait returned %d\n",rcode);
1518 } 1518 }
1519 last_return_code=rcode; 1519 last_return_code=rcode;
1520 if ( rmode == RES_IF || rmode == RES_ELIF ) 1520 if ( rmode == RES_IF || rmode == RES_ELIF )
@@ -2347,7 +2347,7 @@ int parse_stream(o_string *dest, struct p_context *ctx,
2347 done_pipe(ctx,PIPE_SEQ); 2347 done_pipe(ctx,PIPE_SEQ);
2348 } 2348 }
2349 if (ch == end_trigger && !dest->quote && ctx->w==RES_NONE) { 2349 if (ch == end_trigger && !dest->quote && ctx->w==RES_NONE) {
2350 debug_printf("leaving parse_stream\n"); 2350 debug_printf("leaving parse_stream (triggered)\n");
2351 return 0; 2351 return 0;
2352 } 2352 }
2353#if 0 2353#if 0
@@ -2471,6 +2471,7 @@ int parse_stream(o_string *dest, struct p_context *ctx,
2471 * that is, we were really supposed to get end_trigger, and never got 2471 * that is, we were really supposed to get end_trigger, and never got
2472 * one before the EOF. Can't use the standard "syntax error" return code, 2472 * one before the EOF. Can't use the standard "syntax error" return code,
2473 * so that parse_stream_outer can distinguish the EOF and exit smoothly. */ 2473 * so that parse_stream_outer can distinguish the EOF and exit smoothly. */
2474 debug_printf("leaving parse_stream (EOF)\n");
2474 if (end_trigger != '\0') return -1; 2475 if (end_trigger != '\0') return -1;
2475 return 0; 2476 return 0;
2476} 2477}