aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-06 12:54:26 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-06 12:54:26 +0100
commitb6f60863cb9e0b3af3c694c282489e458822002f (patch)
tree7becf4de87c21957b7cff3eb62548c4027743192
parente55a5726001ce23161c4bd0010b842578e7b722c (diff)
downloadbusybox-w32-b6f60863cb9e0b3af3c694c282489e458822002f.tar.gz
busybox-w32-b6f60863cb9e0b3af3c694c282489e458822002f.tar.bz2
busybox-w32-b6f60863cb9e0b3af3c694c282489e458822002f.zip
bc: move a function to reduce forward declarations
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 40430d411..6cc9fe2f7 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -716,9 +716,6 @@ typedef struct BcProgram {
716 716
717typedef unsigned long (*BcProgramBuiltIn)(BcNum *); 717typedef unsigned long (*BcProgramBuiltIn)(BcNum *);
718 718
719static void bc_program_addFunc(char *name, size_t *idx);
720static void bc_program_reset(void);
721
722#define BC_FLAG_X (1 << 0) 719#define BC_FLAG_X (1 << 0)
723#define BC_FLAG_W (1 << 1) 720#define BC_FLAG_W (1 << 1)
724#define BC_FLAG_V (1 << 2) 721#define BC_FLAG_V (1 << 2)
@@ -3523,6 +3520,8 @@ static BcStatus dc_lex_token(BcLex *l)
3523} 3520}
3524#endif // ENABLE_DC 3521#endif // ENABLE_DC
3525 3522
3523static void bc_program_addFunc(char *name, size_t *idx);
3524
3526static void bc_parse_addFunc(BcParse *p, char *name, size_t *idx) 3525static void bc_parse_addFunc(BcParse *p, char *name, size_t *idx)
3527{ 3526{
3528 bc_program_addFunc(name, idx); 3527 bc_program_addFunc(name, idx);
@@ -3583,6 +3582,21 @@ static BcStatus bc_parse_text(BcParse *p, const char *text)
3583 return bc_lex_text(&p->l, text); 3582 return bc_lex_text(&p->l, text);
3584} 3583}
3585 3584
3585// Called when parsing or execution detects a failure,
3586// resets execution structures.
3587static void bc_program_reset(void)
3588{
3589 BcFunc *f;
3590 BcInstPtr *ip;
3591
3592 bc_vec_npop(&G.prog.stack, G.prog.stack.len - 1);
3593 bc_vec_pop_all(&G.prog.results);
3594
3595 f = bc_vec_item(&G.prog.fns, 0);
3596 ip = bc_vec_top(&G.prog.stack);
3597 ip->idx = f->code.len;
3598}
3599
3586#define bc_parse_updateFunc(p, f) \ 3600#define bc_parse_updateFunc(p, f) \
3587 ((p)->func = bc_vec_item(&G.prog.fns, ((p)->fidx = (f)))) 3601 ((p)->func = bc_vec_item(&G.prog.fns, ((p)->fidx = (f))))
3588 3602
@@ -6548,24 +6562,6 @@ static void bc_program_addFunc(char *name, size_t *idx)
6548 } 6562 }
6549} 6563}
6550 6564
6551// Called when parsing or execution detects a failure,
6552// resets execution structures.
6553static void bc_program_reset(void)
6554{
6555 BcFunc *f;
6556 BcInstPtr *ip;
6557
6558 bc_vec_npop(&G.prog.stack, G.prog.stack.len - 1);
6559 bc_vec_pop_all(&G.prog.results);
6560
6561 f = bc_vec_item(&G.prog.fns, 0);
6562 ip = bc_vec_top(&G.prog.stack);
6563 ip->idx = f->code.len;
6564
6565 // If !tty, no need to check for ^C: we don't have ^C handler,
6566 // we would be killed by a signal and won't reach this place
6567}
6568
6569static BcStatus bc_program_exec(void) 6565static BcStatus bc_program_exec(void)
6570{ 6566{
6571 BcStatus s = BC_STATUS_SUCCESS; 6567 BcStatus s = BC_STATUS_SUCCESS;