diff options
-rw-r--r-- | miscutils/bc.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 70db2ce3d..791275c8c 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -736,6 +736,7 @@ typedef struct BcProgram { | |||
736 | struct globals { | 736 | struct globals { |
737 | IF_FEATURE_BC_SIGNALS(smallint ttyin;) | 737 | IF_FEATURE_BC_SIGNALS(smallint ttyin;) |
738 | IF_FEATURE_CLEAN_UP(smallint exiting;) | 738 | IF_FEATURE_CLEAN_UP(smallint exiting;) |
739 | smallint in_read; | ||
739 | char sbgn; | 740 | char sbgn; |
740 | char send; | 741 | char send; |
741 | 742 | ||
@@ -5390,20 +5391,18 @@ static BcStatus bc_program_read(void) | |||
5390 | BcParse parse; | 5391 | BcParse parse; |
5391 | BcVec buf; | 5392 | BcVec buf; |
5392 | BcInstPtr ip; | 5393 | BcInstPtr ip; |
5393 | size_t i; | 5394 | BcFunc *f; |
5394 | BcFunc *f = bc_program_func(BC_PROG_READ); | ||
5395 | 5395 | ||
5396 | for (i = 0; i < G.prog.stack.len; ++i) { | 5396 | if (G.in_read) |
5397 | BcInstPtr *ip_ptr = bc_vec_item(&G.prog.stack, i); | 5397 | return bc_error_nested_read_call(); |
5398 | if (ip_ptr->func == BC_PROG_READ) | ||
5399 | return bc_error_nested_read_call(); | ||
5400 | } | ||
5401 | 5398 | ||
5399 | f = bc_program_func(BC_PROG_READ); | ||
5402 | bc_vec_pop_all(&f->code); | 5400 | bc_vec_pop_all(&f->code); |
5403 | bc_char_vec_init(&buf); | 5401 | bc_char_vec_init(&buf); |
5404 | 5402 | ||
5405 | sv_file = G.prog.file; | 5403 | sv_file = G.prog.file; |
5406 | G.prog.file = NULL; | 5404 | G.prog.file = NULL; |
5405 | G.in_read = 1; | ||
5407 | 5406 | ||
5408 | s = bc_read_line(&buf); | 5407 | s = bc_read_line(&buf); |
5409 | //if (s) goto io_err; - wrong, nonzero return means EOF, not error | 5408 | //if (s) goto io_err; - wrong, nonzero return means EOF, not error |
@@ -5434,6 +5433,7 @@ static BcStatus bc_program_read(void) | |||
5434 | exec_err: | 5433 | exec_err: |
5435 | bc_parse_free(&parse); | 5434 | bc_parse_free(&parse); |
5436 | //io_err: | 5435 | //io_err: |
5436 | G.in_read = 0; | ||
5437 | G.prog.file = sv_file; | 5437 | G.prog.file = sv_file; |
5438 | bc_vec_free(&buf); | 5438 | bc_vec_free(&buf); |
5439 | return s; | 5439 | return s; |