aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 21:29:08 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 21:29:08 +0100
commit6b5b46f81744c72de8f63e45aa788303ab8df28b (patch)
treebd1310dbf42e76da958e325191d8d526911ca480
parent741563312805fa99fc9588c3673eff4a219d5e9f (diff)
downloadbusybox-w32-6b5b46f81744c72de8f63e45aa788303ab8df28b.tar.gz
busybox-w32-6b5b46f81744c72de8f63e45aa788303ab8df28b.tar.bz2
busybox-w32-6b5b46f81744c72de8f63e45aa788303ab8df28b.zip
bc: stop using p->exits when parsing if()
function old new delta zbc_parse_stmt_possibly_auto 2180 2138 -42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index ad716fac3..178cd7a24 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4110,7 +4110,6 @@ static BC_STATUS zbc_parse_if(BcParse *p)
4110{ 4110{
4111 BcStatus s; 4111 BcStatus s;
4112 BcInstPtr ip; 4112 BcInstPtr ip;
4113 BcInstPtr *ipp;
4114 size_t *label; 4113 size_t *label;
4115 4114
4116 dbg_lex_enter("%s:%d entered", __func__, __LINE__); 4115 dbg_lex_enter("%s:%d entered", __func__, __LINE__);
@@ -4132,8 +4131,6 @@ static BC_STATUS zbc_parse_if(BcParse *p)
4132 ip.idx = p->func->labels.len; 4131 ip.idx = p->func->labels.len;
4133 ip.func = ip.len = 0; 4132 ip.func = ip.len = 0;
4134 bc_parse_pushIndex(p, ip.idx); 4133 bc_parse_pushIndex(p, ip.idx);
4135//TODO: can get rid of p->exits stack?
4136 bc_vec_push(&p->exits, &ip);
4137 bc_vec_push(&p->func->labels, &ip.idx); 4134 bc_vec_push(&p->func->labels, &ip.idx);
4138 4135
4139 s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "if"); 4136 s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "if");
@@ -4147,32 +4144,27 @@ static BC_STATUS zbc_parse_if(BcParse *p)
4147 if (s) RETURN_STATUS(s); 4144 if (s) RETURN_STATUS(s);
4148 4145
4149 ip2.idx = p->func->labels.len; 4146 ip2.idx = p->func->labels.len;
4150 ip2.func = ip.len = 0; 4147 ip2.func = ip2.len = 0;
4151 4148
4152 dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip.idx); 4149 dbg_lex("%s:%d after if() body: BC_INST_JUMP to %d", __func__, __LINE__, ip.idx);
4153 bc_parse_push(p, BC_INST_JUMP); 4150 bc_parse_push(p, BC_INST_JUMP);
4154 bc_parse_pushIndex(p, ip2.idx); 4151 bc_parse_pushIndex(p, ip2.idx);
4155 4152
4156 ipp = bc_vec_top(&p->exits); 4153 label = bc_vec_item(&p->func->labels, ip.idx);
4157 label = bc_vec_item(&p->func->labels, ipp->idx);
4158 dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len); 4154 dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
4159 *label = p->func->code.len; 4155 *label = p->func->code.len;
4160 bc_vec_pop(&p->exits);
4161 4156
4162 bc_vec_push(&p->exits, &ip2);
4163 bc_vec_push(&p->func->labels, &ip2.idx); 4157 bc_vec_push(&p->func->labels, &ip2.idx);
4158 ip.idx = ip2.idx;
4164 4159
4165 s = zbc_parse_stmt(p); 4160 s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "else");
4166 if (s) RETURN_STATUS(s); 4161 if (s) RETURN_STATUS(s);
4167 } 4162 }
4168 4163
4169 ipp = bc_vec_top(&p->exits); 4164 label = bc_vec_item(&p->func->labels, ip.idx);
4170 label = bc_vec_item(&p->func->labels, ipp->idx);
4171 dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len); 4165 dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
4172 *label = p->func->code.len; 4166 *label = p->func->code.len;
4173 4167
4174 bc_vec_pop(&p->exits);
4175
4176 dbg_lex_done("%s:%d done", __func__, __LINE__); 4168 dbg_lex_done("%s:%d done", __func__, __LINE__);
4177 RETURN_STATUS(s); 4169 RETURN_STATUS(s);
4178} 4170}