aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 21:40:54 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 21:41:17 +0100
commit15850832be164b941aeef7c62aaed91fb5774f8a (patch)
treeb26ee28de54f25023c9e7f5846b4df7737c29626
parent6b5b46f81744c72de8f63e45aa788303ab8df28b (diff)
downloadbusybox-w32-15850832be164b941aeef7c62aaed91fb5774f8a.tar.gz
busybox-w32-15850832be164b941aeef7c62aaed91fb5774f8a.tar.bz2
busybox-w32-15850832be164b941aeef7c62aaed91fb5774f8a.zip
bc: shrink zbc_parse_if() a bit more
function old new delta zbc_parse_stmt_possibly_auto 2180 2106 -74 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-74) Total: -74 bytes text data bss dec hex filename 982152 485 7296 989933 f1aed busybox_old 982078 485 7296 989859 f1aa3 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 178cd7a24..2a9f3e2d3 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4109,7 +4109,7 @@ static BC_STATUS zbc_parse_return(BcParse *p)
4109static BC_STATUS zbc_parse_if(BcParse *p) 4109static BC_STATUS zbc_parse_if(BcParse *p)
4110{ 4110{
4111 BcStatus s; 4111 BcStatus s;
4112 BcInstPtr ip; 4112 size_t ip_idx;
4113 size_t *label; 4113 size_t *label;
4114 4114
4115 dbg_lex_enter("%s:%d entered", __func__, __LINE__); 4115 dbg_lex_enter("%s:%d entered", __func__, __LINE__);
@@ -4128,41 +4128,39 @@ static BC_STATUS zbc_parse_if(BcParse *p)
4128 if (s) RETURN_STATUS(s); 4128 if (s) RETURN_STATUS(s);
4129 4129
4130 bc_parse_push(p, BC_INST_JUMP_ZERO); 4130 bc_parse_push(p, BC_INST_JUMP_ZERO);
4131 ip.idx = p->func->labels.len; 4131 ip_idx = p->func->labels.len;
4132 ip.func = ip.len = 0; 4132 bc_parse_pushIndex(p, ip_idx);
4133 bc_parse_pushIndex(p, ip.idx); 4133 bc_vec_push(&p->func->labels, &ip_idx);
4134 bc_vec_push(&p->func->labels, &ip.idx);
4135 4134
4136 s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "if"); 4135 s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "if");
4137 if (s) RETURN_STATUS(s); 4136 if (s) RETURN_STATUS(s);
4138 4137
4139 dbg_lex("%s:%d in if after stmt: p->l.t.t:%d", __func__, __LINE__, p->l.t.t); 4138 dbg_lex("%s:%d in if after stmt: p->l.t.t:%d", __func__, __LINE__, p->l.t.t);
4140 if (p->l.t.t == BC_LEX_KEY_ELSE) { 4139 if (p->l.t.t == BC_LEX_KEY_ELSE) {
4141 BcInstPtr ip2; 4140 size_t ip2_idx;
4142 4141
4143 s = zbc_lex_next_and_skip_NLINE(&p->l); 4142 s = zbc_lex_next_and_skip_NLINE(&p->l);
4144 if (s) RETURN_STATUS(s); 4143 if (s) RETURN_STATUS(s);
4145 4144
4146 ip2.idx = p->func->labels.len; 4145 ip2_idx = p->func->labels.len;
4147 ip2.func = ip2.len = 0;
4148 4146
4149 dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip.idx); 4147 dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip2_idx);
4150 bc_parse_push(p, BC_INST_JUMP); 4148 bc_parse_push(p, BC_INST_JUMP);
4151 bc_parse_pushIndex(p, ip2.idx); 4149 bc_parse_pushIndex(p, ip2_idx);
4152 4150
4153 label = bc_vec_item(&p->func->labels, ip.idx); 4151 label = bc_vec_item(&p->func->labels, ip_idx);
4154 dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len); 4152 dbg_lex("%s:%d rewriting 'if_zero' label to jump to 'else': %d -> %d", __func__, __LINE__, *label, p->func->code.len);
4155 *label = p->func->code.len; 4153 *label = p->func->code.len;
4156 4154
4157 bc_vec_push(&p->func->labels, &ip2.idx); 4155 bc_vec_push(&p->func->labels, &ip2_idx);
4158 ip.idx = ip2.idx; 4156 ip_idx = ip2_idx;
4159 4157
4160 s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "else"); 4158 s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "else");
4161 if (s) RETURN_STATUS(s); 4159 if (s) RETURN_STATUS(s);
4162 } 4160 }
4163 4161
4164 label = bc_vec_item(&p->func->labels, ip.idx); 4162 label = bc_vec_item(&p->func->labels, ip_idx);
4165 dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len); 4163 dbg_lex("%s:%d rewriting label to jump after 'if' body: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
4166 *label = p->func->code.len; 4164 *label = p->func->code.len;
4167 4165
4168 dbg_lex_done("%s:%d done", __func__, __LINE__); 4166 dbg_lex_done("%s:%d done", __func__, __LINE__);