aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 18:43:51 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-16 18:43:51 +0100
commit9dc5d08baa4f409b2b6f9b98e2eefd87b8eb29be (patch)
tree0490ec2029ce66df53f9af954ce352b62e6fbc03
parent202dd1943c90dea3c5c3365dd75d4e7ac9499c5f (diff)
downloadbusybox-w32-9dc5d08baa4f409b2b6f9b98e2eefd87b8eb29be.tar.gz
busybox-w32-9dc5d08baa4f409b2b6f9b98e2eefd87b8eb29be.tar.bz2
busybox-w32-9dc5d08baa4f409b2b6f9b98e2eefd87b8eb29be.zip
bc: delete unused (write-only) BcParse::nbraces member
function old new delta zbc_lex_next 2296 2309 +13 bc_parse_expr_empty_ok 2021 2025 +4 bc_vm_init 760 757 -3 bc_num_printNewline 54 51 -3 zbc_num_divmod 156 150 -6 bc_parse_reset 113 106 -7 zbc_lex_number 200 192 -8 bc_parse_number 83 66 -17 zdc_parse_expr 707 671 -36 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/7 up/down: 17/-80) Total: -63 bytes text data bss dec hex filename 982275 485 7296 990056 f1b68 busybox_old 982212 485 7296 989993 f1b29 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index a5d7a01c0..0e61642a7 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -435,9 +435,9 @@ typedef enum BcLexType {
435 BC_LEX_COMMA, 435 BC_LEX_COMMA,
436 BC_LEX_RBRACKET, 436 BC_LEX_RBRACKET,
437 437
438 BC_LEX_LBRACE, 438 BC_LEX_LBRACE, // '{' is 0x7B, '}' is 0x7D,
439 BC_LEX_SCOLON, 439 BC_LEX_SCOLON,
440 BC_LEX_RBRACE, 440 BC_LEX_RBRACE, // should be LBRACE+2: code uses (c - '{' + BC_LEX_LBRACE)
441 441
442 BC_LEX_STR, 442 BC_LEX_STR,
443 BC_LEX_NAME, 443 BC_LEX_NAME,
@@ -589,9 +589,6 @@ typedef struct BcParse {
589 BcFunc *func; 589 BcFunc *func;
590 size_t fidx; 590 size_t fidx;
591 591
592//TODO: needed? Example?
593 size_t nbraces;
594
595 size_t in_funcdef; 592 size_t in_funcdef;
596} BcParse; 593} BcParse;
597 594
@@ -2777,7 +2774,9 @@ static void bc_lex_whitespace(BcLex *l)
2777 l->t.t = BC_LEX_WHITESPACE; 2774 l->t.t = BC_LEX_WHITESPACE;
2778 for (;;) { 2775 for (;;) {
2779 char c = l->buf[l->i]; 2776 char c = l->buf[l->i];
2780 if (c == '\n' || !isspace(c)) 2777 if (c == '\n') // this is BC_LEX_NLINE, not BC_LEX_WHITESPACE
2778 break;
2779 if (!isspace(c))
2781 break; 2780 break;
2782 l->i++; 2781 l->i++;
2783 } 2782 }
@@ -3003,6 +3002,7 @@ static BC_STATUS zbc_lex_next(BcLex *l)
3003 3002
3004 // Loop until failure or we don't have whitespace. This 3003 // Loop until failure or we don't have whitespace. This
3005 // is so the parser doesn't get inundated with whitespace. 3004 // is so the parser doesn't get inundated with whitespace.
3005 // Comments are also BC_LEX_WHITESPACE tokens and eaten here.
3006 s = BC_STATUS_SUCCESS; 3006 s = BC_STATUS_SUCCESS;
3007 do { 3007 do {
3008 dbg_lex("next string to parse:'%.*s'", 3008 dbg_lex("next string to parse:'%.*s'",
@@ -3149,9 +3149,9 @@ static BC_STATUS zbc_lex_comment(BcLex *l)
3149 const char *buf = l->buf; 3149 const char *buf = l->buf;
3150 3150
3151 l->t.t = BC_LEX_WHITESPACE; 3151 l->t.t = BC_LEX_WHITESPACE;
3152 i = ++l->i; 3152 i = l->i; /* here buf[l->i] is the '*' of opening comment delimiter */
3153 for (;;) { 3153 for (;;) {
3154 char c = buf[i]; 3154 char c = buf[++i];
3155 check_star: 3155 check_star:
3156 if (c == '*') { 3156 if (c == '*') {
3157 c = buf[++i]; 3157 c = buf[++i];
@@ -3164,7 +3164,6 @@ static BC_STATUS zbc_lex_comment(BcLex *l)
3164 RETURN_STATUS(bc_error("comment end could not be found")); 3164 RETURN_STATUS(bc_error("comment end could not be found"));
3165 } 3165 }
3166 nls += (c == '\n'); 3166 nls += (c == '\n');
3167 i++;
3168 } 3167 }
3169 3168
3170 l->i = i + 1; 3169 l->i = i + 1;
@@ -3184,10 +3183,14 @@ static BC_STATUS zbc_lex_token(BcLex *l)
3184 3183
3185 // This is the workhorse of the lexer. 3184 // This is the workhorse of the lexer.
3186 switch (c) { 3185 switch (c) {
3187 case '\0': 3186 case '\0': // probably never reached
3187 l->i--;
3188 l->t.t = BC_LEX_EOF;
3189 l->newline = true;
3190 break;
3188 case '\n': 3191 case '\n':
3192 l->t.t = BC_LEX_NLINE;
3189 l->newline = true; 3193 l->newline = true;
3190 l->t.t = !c ? BC_LEX_EOF : BC_LEX_NLINE;
3191 break; 3194 break;
3192 case '\t': 3195 case '\t':
3193 case '\v': 3196 case '\v':
@@ -3556,7 +3559,7 @@ static void bc_parse_pushIndex(BcParse *p, size_t idx)
3556 } 3559 }
3557} 3560}
3558 3561
3559static void bc_parse_number(BcParse *p, BcInst *prev, size_t *nexs) 3562static void bc_parse_number(BcParse *p)
3560{ 3563{
3561 char *num = xstrdup(p->l.t.v.v); 3564 char *num = xstrdup(p->l.t.v.v);
3562 size_t idx = G.prog.consts.len; 3565 size_t idx = G.prog.consts.len;
@@ -3565,9 +3568,6 @@ static void bc_parse_number(BcParse *p, BcInst *prev, size_t *nexs)
3565 3568
3566 bc_parse_push(p, BC_INST_NUM); 3569 bc_parse_push(p, BC_INST_NUM);
3567 bc_parse_pushIndex(p, idx); 3570 bc_parse_pushIndex(p, idx);
3568
3569 ++(*nexs);
3570 (*prev) = BC_INST_NUM;
3571} 3571}
3572 3572
3573IF_BC(static BC_STATUS zbc_parse_stmt_or_funcdef(BcParse *p);) 3573IF_BC(static BC_STATUS zbc_parse_stmt_or_funcdef(BcParse *p);)
@@ -3624,7 +3624,6 @@ static void bc_parse_reset(BcParse *p)
3624 3624
3625 p->l.i = p->l.len; 3625 p->l.i = p->l.len;
3626 p->l.t.t = BC_LEX_EOF; 3626 p->l.t.t = BC_LEX_EOF;
3627 p->nbraces = 0;
3628 3627
3629 bc_vec_pop_all(&p->exits); 3628 bc_vec_pop_all(&p->exits);
3630 bc_vec_pop_all(&p->conds); 3629 bc_vec_pop_all(&p->conds);
@@ -3650,7 +3649,6 @@ static void bc_parse_create(BcParse *p, size_t func)
3650 bc_vec_init(&p->conds, sizeof(size_t), NULL); 3649 bc_vec_init(&p->conds, sizeof(size_t), NULL);
3651 bc_vec_init(&p->ops, sizeof(BcLexType), NULL); 3650 bc_vec_init(&p->ops, sizeof(BcLexType), NULL);
3652 3651
3653 // p->nbraces = 0; - already is
3654 bc_parse_updateFunc(p, func); 3652 bc_parse_updateFunc(p, func);
3655} 3653}
3656 3654
@@ -4846,7 +4844,9 @@ static BcStatus bc_parse_expr_empty_ok(BcParse *p, uint8_t flags, BcParseNext ne
4846 { 4844 {
4847 if (BC_PARSE_LEAF(prev, rprn)) 4845 if (BC_PARSE_LEAF(prev, rprn))
4848 return bc_error_bad_expression(); 4846 return bc_error_bad_expression();
4849 bc_parse_number(p, &prev, &nexprs); 4847 bc_parse_number(p);
4848 nexprs++;
4849 prev = BC_INST_NUM;
4850 paren_expr = get_token = true; 4850 paren_expr = get_token = true;
4851 rprn = bin_last = false; 4851 rprn = bin_last = false;
4852 4852
@@ -5111,7 +5111,8 @@ static BC_STATUS zdc_parse_token(BcParse *p, BcLexType t, uint8_t flags)
5111 if (p->l.t.t != BC_LEX_NUMBER) 5111 if (p->l.t.t != BC_LEX_NUMBER)
5112 RETURN_STATUS(bc_error_bad_token()); 5112 RETURN_STATUS(bc_error_bad_token());
5113 } 5113 }
5114 bc_parse_number(p, &prev, &p->nbraces); 5114 bc_parse_number(p);
5115 prev = BC_INST_NUM;
5115 if (t == BC_LEX_NEG) bc_parse_push(p, BC_INST_NEG); 5116 if (t == BC_LEX_NEG) bc_parse_push(p, BC_INST_NEG);
5116 get_token = true; 5117 get_token = true;
5117 break; 5118 break;
@@ -5159,8 +5160,6 @@ static BC_STATUS zdc_parse_expr(BcParse *p, uint8_t flags)
5159 BcInst inst; 5160 BcInst inst;
5160 BcLexType t; 5161 BcLexType t;
5161 5162
5162 if (flags & BC_PARSE_NOCALL) p->nbraces = G.prog.results.len;
5163
5164 for (t = p->l.t.t; !s && t != BC_LEX_EOF; t = p->l.t.t) { 5163 for (t = p->l.t.t; !s && t != BC_LEX_EOF; t = p->l.t.t) {
5165 inst = dc_parse_insts[t]; 5164 inst = dc_parse_insts[t];
5166 5165