diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-16 19:21:57 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-16 19:21:57 +0100 |
commit | a50576a415a9b5d384a28c9bd4b55a4df2974248 (patch) | |
tree | 12db52aea474921a6fb5bc935405309b25e73c88 /miscutils | |
parent | 6d29879c676a636656c7b29ab5be76518346b19c (diff) | |
download | busybox-a50576a415a9b5d384a28c9bd4b55a4df2974248.tar.gz |
bc: fold zbc_parse_else() into its only caller
While at it, allow newline between "else" and its body
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/bc.c | 59 |
1 files changed, 21 insertions, 38 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index cca64eaf5..9ce6ab667 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c @@ -4112,41 +4112,6 @@ static BC_STATUS zbc_parse_return(BcParse *p) # define zbc_parse_return(...) (zbc_parse_return(__VA_ARGS__), BC_STATUS_SUCCESS) #endif -static BC_STATUS zbc_parse_else(BcParse *p) -{ - BcStatus s; - BcInstPtr ip; - BcInstPtr *ipp; - size_t *label; - - dbg_lex_enter("%s:%d entered", __func__, __LINE__); - - ip.idx = p->func->labels.len; - ip.func = ip.len = 0; - - dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip.idx); - bc_parse_push(p, BC_INST_JUMP); - bc_parse_pushIndex(p, ip.idx); - - ipp = bc_vec_top(&p->exits); - label = bc_vec_item(&p->func->labels, ipp->idx); - dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len); - *label = p->func->code.len; - bc_vec_pop(&p->exits); - - bc_vec_push(&p->exits, &ip); - bc_vec_push(&p->func->labels, &ip.idx); - - s = zbc_parse_stmt(p); - if (s) RETURN_STATUS(s); - - dbg_lex_done("%s:%d done", __func__, __LINE__); - RETURN_STATUS(s); -} -#if ERRORS_ARE_FATAL -# define zbc_parse_else(...) (zbc_parse_else(__VA_ARGS__), BC_STATUS_SUCCESS) -#endif - static BC_STATUS zbc_parse_if(BcParse *p) { BcStatus s; @@ -4179,12 +4144,30 @@ static BC_STATUS zbc_parse_if(BcParse *p) s = zbc_parse_stmt(p); if (s) RETURN_STATUS(s); + dbg_lex("%s:%d in if after stmt: p->l.t.t:%d", __func__, __LINE__, p->l.t.t); if (p->l.t.t == BC_LEX_KEY_ELSE) { - s = zbc_lex_next(&p->l); + s = zbc_lex_next_and_skip_NLINE(&p->l); + if (s) RETURN_STATUS(s); + + ip.idx = p->func->labels.len; + ip.func = ip.len = 0; + + dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip.idx); + bc_parse_push(p, BC_INST_JUMP); + bc_parse_pushIndex(p, ip.idx); + + ipp = bc_vec_top(&p->exits); + label = bc_vec_item(&p->func->labels, ipp->idx); + dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len); + *label = p->func->code.len; + bc_vec_pop(&p->exits); + + bc_vec_push(&p->exits, &ip); + bc_vec_push(&p->func->labels, &ip.idx); + + s = zbc_parse_stmt(p); if (s) RETURN_STATUS(s); - dbg_lex("%s:%d calling zbc_parse_else(), p->l.t.t:%d", __func__, __LINE__, p->l.t.t); - s = zbc_parse_else(p); } ipp = bc_vec_top(&p->exits); |