aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-22 03:38:52 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-22 03:38:52 +0100
commit514967df5e5ef21873dc2f8a303e892e3f200ea4 (patch)
tree51b0ff63af8bbebf1d6a24affa6311c44c45930d
parentf093e3df2df46f026d5c3f053a6095b5c72387ac (diff)
downloadbusybox-w32-514967df5e5ef21873dc2f8a303e892e3f200ea4.tar.gz
busybox-w32-514967df5e5ef21873dc2f8a303e892e3f200ea4.tar.bz2
busybox-w32-514967df5e5ef21873dc2f8a303e892e3f200ea4.zip
bc: zcommon_parse_expr() has only one user, fold it in
function old new delta zbc_program_exec 4021 4046 +25 zdc_parse_expr 589 586 -3 zcommon_parse_expr 28 - -28 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/1 up/down: 25/-31) Total: -6 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 1c47fba1d..4d252cc97 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4986,6 +4986,7 @@ static BC_STATUS zdc_parse_expr(BcParse *p)
4986 BcStatus s; 4986 BcStatus s;
4987 4987
4988 t = p->l.t.t; 4988 t = p->l.t.t;
4989 dbg_lex("%s:%d G.prs.l.t.t:%d", __func__, __LINE__, G.prs.l.t.t);
4989 if (t == BC_LEX_EOF) break; 4990 if (t == BC_LEX_EOF) break;
4990 4991
4991 inst = dc_parse_insts[t]; 4992 inst = dc_parse_insts[t];
@@ -5009,6 +5010,7 @@ static BC_STATUS zdc_parse_parse(BcParse *p)
5009{ 5010{
5010 BcStatus s; 5011 BcStatus s;
5011 5012
5013 dbg_lex_enter("%s:%d entered", __func__, __LINE__);
5012 if (p->l.t.t == BC_LEX_EOF) 5014 if (p->l.t.t == BC_LEX_EOF)
5013 s = bc_error("end of file"); 5015 s = bc_error("end of file");
5014 else 5016 else
@@ -5019,22 +5021,13 @@ static BC_STATUS zdc_parse_parse(BcParse *p)
5019 s = BC_STATUS_FAILURE; 5021 s = BC_STATUS_FAILURE;
5020 } 5022 }
5021 5023
5024 dbg_lex_done("%s:%d done", __func__, __LINE__);
5022 RETURN_STATUS(s); 5025 RETURN_STATUS(s);
5023} 5026}
5024#define zdc_parse_parse(...) (zdc_parse_parse(__VA_ARGS__) COMMA_SUCCESS) 5027#define zdc_parse_parse(...) (zdc_parse_parse(__VA_ARGS__) COMMA_SUCCESS)
5025 5028
5026#endif // ENABLE_DC 5029#endif // ENABLE_DC
5027 5030
5028static BC_STATUS zcommon_parse_expr(BcParse *p)
5029{
5030 if (IS_BC) {
5031 IF_BC(RETURN_STATUS(zbc_parse_expr(p, 0)));
5032 } else {
5033 IF_DC(RETURN_STATUS(zdc_parse_expr(p)));
5034 }
5035}
5036#define zcommon_parse_expr(...) (zcommon_parse_expr(__VA_ARGS__) COMMA_SUCCESS)
5037
5038static BcVec* bc_program_search(char *id, bool var) 5031static BcVec* bc_program_search(char *id, bool var)
5039{ 5032{
5040 BcId e, *ptr; 5033 BcId e, *ptr;
@@ -5239,7 +5232,11 @@ static BC_STATUS zbc_program_read(void)
5239 5232
5240 s = zbc_parse_text_init(&parse, buf.v); 5233 s = zbc_parse_text_init(&parse, buf.v);
5241 if (s) goto exec_err; 5234 if (s) goto exec_err;
5242 s = zcommon_parse_expr(&parse); 5235 if (IS_BC) {
5236 IF_BC(s = zbc_parse_expr(&parse, 0));
5237 } else {
5238 IF_DC(s = zdc_parse_expr(&parse));
5239 }
5243 if (s) goto exec_err; 5240 if (s) goto exec_err;
5244 5241
5245 if (parse.l.t.t != BC_LEX_NLINE && parse.l.t.t != BC_LEX_EOF) { 5242 if (parse.l.t.t != BC_LEX_NLINE && parse.l.t.t != BC_LEX_EOF) {
@@ -6367,7 +6364,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond)
6367 str = *bc_program_str(sidx); 6364 str = *bc_program_str(sidx);
6368 s = zbc_parse_text_init(&prs, str); 6365 s = zbc_parse_text_init(&prs, str);
6369 if (s) goto err; 6366 if (s) goto err;
6370 s = zcommon_parse_expr(&prs); 6367 s = zdc_parse_expr(&prs);
6371 if (s) goto err; 6368 if (s) goto err;
6372 if (prs.l.t.t != BC_LEX_EOF) { 6369 if (prs.l.t.t != BC_LEX_EOF) {
6373 s = bc_error_bad_expression(); 6370 s = bc_error_bad_expression();