diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-22 02:23:08 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-22 02:23:08 +0100 |
| commit | 39287e0d0225db167baa34db59a0ae63eecf5a6c (patch) | |
| tree | ffd07779524ee360189de9eb8ff204f535450f81 /miscutils | |
| parent | 8c1e72359626789b1b98aeac0225d73d1336bb59 (diff) | |
| download | busybox-w32-39287e0d0225db167baa34db59a0ae63eecf5a6c.tar.gz busybox-w32-39287e0d0225db167baa34db59a0ae63eecf5a6c.tar.bz2 busybox-w32-39287e0d0225db167baa34db59a0ae63eecf5a6c.zip | |
bc: stop using BC_PARSE_NOCALL in dc code
function old new delta
zdc_program_execStr 465 474 +9
zbc_vm_process 701 699 -2
common_parse_expr 32 29 -3
zdc_parse_expr 615 586 -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 9/-34) Total: -25 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/bc.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 1ba8427da..65f98afc2 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
| @@ -302,16 +302,14 @@ typedef enum BcInst { | |||
| 302 | BC_INST_PRINT_STR, | 302 | BC_INST_PRINT_STR, |
| 303 | 303 | ||
| 304 | #if ENABLE_BC | 304 | #if ENABLE_BC |
| 305 | BC_INST_HALT, | ||
| 305 | BC_INST_JUMP, | 306 | BC_INST_JUMP, |
| 306 | BC_INST_JUMP_ZERO, | 307 | BC_INST_JUMP_ZERO, |
| 307 | 308 | ||
| 308 | BC_INST_CALL, | 309 | BC_INST_CALL, |
| 309 | |||
| 310 | BC_INST_RET, | ||
| 311 | BC_INST_RET0, | 310 | BC_INST_RET0, |
| 312 | |||
| 313 | BC_INST_HALT, | ||
| 314 | #endif | 311 | #endif |
| 312 | BC_INST_RET, | ||
| 315 | 313 | ||
| 316 | BC_INST_POP, | 314 | BC_INST_POP, |
| 317 | #if ENABLE_DC | 315 | #if ENABLE_DC |
| @@ -659,10 +657,12 @@ typedef struct BcLex { | |||
| 659 | 657 | ||
| 660 | #define BC_PARSE_STREND (0xff) | 658 | #define BC_PARSE_STREND (0xff) |
| 661 | 659 | ||
| 662 | #define BC_PARSE_REL (1 << 0) | 660 | #if ENABLE_BC |
| 663 | #define BC_PARSE_PRINT (1 << 1) | 661 | # define BC_PARSE_REL (1 << 0) |
| 664 | #define BC_PARSE_NOCALL (1 << 2) | 662 | # define BC_PARSE_PRINT (1 << 1) |
| 665 | #define BC_PARSE_ARRAY (1 << 3) | 663 | # define BC_PARSE_ARRAY (1 << 2) |
| 664 | # define BC_PARSE_NOCALL (1 << 3) | ||
| 665 | #endif | ||
| 666 | 666 | ||
| 667 | typedef struct BcParse { | 667 | typedef struct BcParse { |
| 668 | BcLex l; | 668 | BcLex l; |
| @@ -4976,7 +4976,7 @@ static BC_STATUS zdc_parse_token(BcParse *p, BcLexType t) | |||
| 4976 | } | 4976 | } |
| 4977 | #define zdc_parse_token(...) (zdc_parse_token(__VA_ARGS__) COMMA_SUCCESS) | 4977 | #define zdc_parse_token(...) (zdc_parse_token(__VA_ARGS__) COMMA_SUCCESS) |
| 4978 | 4978 | ||
| 4979 | static BC_STATUS zdc_parse_expr(BcParse *p, uint8_t flags) | 4979 | static BC_STATUS zdc_parse_expr(BcParse *p) |
| 4980 | { | 4980 | { |
| 4981 | BcLexType t; | 4981 | BcLexType t; |
| 4982 | 4982 | ||
| @@ -5000,9 +5000,6 @@ static BC_STATUS zdc_parse_expr(BcParse *p, uint8_t flags) | |||
| 5000 | if (s) RETURN_STATUS(s); | 5000 | if (s) RETURN_STATUS(s); |
| 5001 | } | 5001 | } |
| 5002 | 5002 | ||
| 5003 | if (flags & BC_PARSE_NOCALL) | ||
| 5004 | bc_parse_push(p, BC_INST_POP_EXEC); | ||
| 5005 | |||
| 5006 | dbg_lex_done("%s:%d done", __func__, __LINE__); | 5003 | dbg_lex_done("%s:%d done", __func__, __LINE__); |
| 5007 | RETURN_STATUS(BC_STATUS_SUCCESS); | 5004 | RETURN_STATUS(BC_STATUS_SUCCESS); |
| 5008 | } | 5005 | } |
| @@ -5015,7 +5012,7 @@ static BC_STATUS zdc_parse_parse(BcParse *p) | |||
| 5015 | if (p->l.t.t == BC_LEX_EOF) | 5012 | if (p->l.t.t == BC_LEX_EOF) |
| 5016 | s = bc_error("end of file"); | 5013 | s = bc_error("end of file"); |
| 5017 | else | 5014 | else |
| 5018 | s = zdc_parse_expr(p, 0); | 5015 | s = zdc_parse_expr(p); |
| 5019 | 5016 | ||
| 5020 | if (s || G_interrupt) { | 5017 | if (s || G_interrupt) { |
| 5021 | bc_parse_reset(p); | 5018 | bc_parse_reset(p); |
| @@ -5028,8 +5025,8 @@ static BC_STATUS zdc_parse_parse(BcParse *p) | |||
| 5028 | 5025 | ||
| 5029 | #endif // ENABLE_DC | 5026 | #endif // ENABLE_DC |
| 5030 | 5027 | ||
| 5031 | #if !ENABLE_DC | 5028 | #if !ENABLE_BC |
| 5032 | #define common_parse_expr(p,flags) \ | 5029 | #define common_parse_expr(p, flags) \ |
| 5033 | common_parse_expr(p) | 5030 | common_parse_expr(p) |
| 5034 | #define flags 0 | 5031 | #define flags 0 |
| 5035 | #endif | 5032 | #endif |
| @@ -5038,8 +5035,9 @@ static BC_STATUS common_parse_expr(BcParse *p, uint8_t flags) | |||
| 5038 | if (IS_BC) { | 5035 | if (IS_BC) { |
| 5039 | IF_BC(RETURN_STATUS(zbc_parse_expr(p, flags))); | 5036 | IF_BC(RETURN_STATUS(zbc_parse_expr(p, flags))); |
| 5040 | } else { | 5037 | } else { |
| 5041 | IF_DC(RETURN_STATUS(zdc_parse_expr(p, flags))); | 5038 | IF_DC(RETURN_STATUS(zdc_parse_expr(p))); |
| 5042 | } | 5039 | } |
| 5040 | #undef flags | ||
| 5043 | } | 5041 | } |
| 5044 | #define zcommon_parse_expr(...) (common_parse_expr(__VA_ARGS__) COMMA_SUCCESS) | 5042 | #define zcommon_parse_expr(...) (common_parse_expr(__VA_ARGS__) COMMA_SUCCESS) |
| 5045 | 5043 | ||
| @@ -6375,7 +6373,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond) | |||
| 6375 | str = *bc_program_str(sidx); | 6373 | str = *bc_program_str(sidx); |
| 6376 | s = zbc_parse_text_init(&prs, str); | 6374 | s = zbc_parse_text_init(&prs, str); |
| 6377 | if (s) goto err; | 6375 | if (s) goto err; |
| 6378 | s = zcommon_parse_expr(&prs, BC_PARSE_NOCALL); | 6376 | s = zcommon_parse_expr(&prs, 0); |
| 6379 | if (s) goto err; | 6377 | if (s) goto err; |
| 6380 | if (prs.l.t.t != BC_LEX_EOF) { | 6378 | if (prs.l.t.t != BC_LEX_EOF) { |
| 6381 | s = bc_error_bad_expression(); | 6379 | s = bc_error_bad_expression(); |
| @@ -6384,6 +6382,7 @@ static BC_STATUS zdc_program_execStr(char *code, size_t *bgn, bool cond) | |||
| 6384 | bc_vec_pop_all(&f->code); | 6382 | bc_vec_pop_all(&f->code); |
| 6385 | goto exit; | 6383 | goto exit; |
| 6386 | } | 6384 | } |
| 6385 | bc_parse_push(&prs, BC_INST_POP_EXEC); | ||
| 6387 | bc_parse_free(&prs); | 6386 | bc_parse_free(&prs); |
| 6388 | } | 6387 | } |
| 6389 | 6388 | ||
| @@ -6696,9 +6695,10 @@ static BC_STATUS zbc_vm_process(const char *text) | |||
| 6696 | if (s) RETURN_STATUS(s); | 6695 | if (s) RETURN_STATUS(s); |
| 6697 | 6696 | ||
| 6698 | while (G.prs.l.t.t != BC_LEX_EOF) { | 6697 | while (G.prs.l.t.t != BC_LEX_EOF) { |
| 6699 | dbg_lex("%s:%d G.prs.l.t.t:%d", __func__, __LINE__, G.prs.l.t.t); | 6698 | dbg_lex("%s:%d G.prs.l.t.t:%d, parsing...", __func__, __LINE__, G.prs.l.t.t); |
| 6700 | s = zcommon_parse(&G.prs); | 6699 | s = zcommon_parse(&G.prs); |
| 6701 | if (s) RETURN_STATUS(s); | 6700 | if (s) RETURN_STATUS(s); |
| 6701 | dbg_lex("%s:%d executing...", __func__, __LINE__); | ||
| 6702 | s = zbc_program_exec(); | 6702 | s = zbc_program_exec(); |
| 6703 | if (s) { | 6703 | if (s) { |
| 6704 | bc_program_reset(); | 6704 | bc_program_reset(); |
