[git commit] bc: drop zbc_parse_endBody() bool parameter, move its code to caller which uses it
Denys Vlasenko
vda.linux at googlemail.com
Fri Dec 14 22:41:33 UTC 2018
commit: https://git.busybox.net/busybox/commit/?id=f10f17f8d3ee77c469fc57634a458e8a45aeb681
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
zbc_parse_stmt 1456 1479 +23
zbc_parse_body 103 101 -2
zbc_parse_endBody 326 292 -34
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 23/-36) Total: -13 bytes
text data bss dec hex filename
979893 485 7296 987674 f121a busybox_old
979880 485 7296 987661 f120d busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
miscutils/bc.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 9a501a25e..4024a08df 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4046,23 +4046,13 @@ static BC_STATUS zbc_parse_return(BcParse *p)
# define zbc_parse_return(...) (zbc_parse_return(__VA_ARGS__), BC_STATUS_SUCCESS)
#endif
-static BC_STATUS zbc_parse_endBody(BcParse *p, bool brace)
+static BC_STATUS zbc_parse_endBody(BcParse *p)
{
BcStatus s = BC_STATUS_SUCCESS;
- if (p->flags.len <= 1 || (brace && p->nbraces == 0))
+ if (p->flags.len <= 1)
RETURN_STATUS(bc_error_bad_token());
- if (brace) {
- if (p->l.t.t != BC_LEX_RBRACE)
- RETURN_STATUS(bc_error_bad_token());
- if (!p->nbraces)
- RETURN_STATUS(bc_error_bad_token());
- --p->nbraces;
- s = zbc_lex_next(&p->l);
- if (s) RETURN_STATUS(s);
- }
-
if (BC_PARSE_IF(p)) {
uint8_t *flag_ptr;
@@ -4523,7 +4513,7 @@ static BC_STATUS zbc_parse_body(BcParse *p, bool brace)
else {
dbg_lex("%s:%d !BC_PARSE_FLAG_FUNC_INNER", __func__, __LINE__);
s = zbc_parse_stmt(p);
- if (!s && !brace) s = zbc_parse_endBody(p, false);
+ if (!s && !brace) s = zbc_parse_endBody(p);
}
dbg_lex_done("%s:%d done", __func__, __LINE__);
@@ -4598,7 +4588,12 @@ static BC_STATUS zbc_parse_stmt(BcParse *p)
while (!s && p->l.t.t == BC_LEX_SCOLON) s = zbc_lex_next(&p->l);
break;
case BC_LEX_RBRACE:
- s = zbc_parse_endBody(p, true);
+ if (p->nbraces == 0)
+ RETURN_STATUS(bc_error_bad_token());
+ --p->nbraces;
+ s = zbc_lex_next(&p->l);
+ if (!s)
+ s = zbc_parse_endBody(p);
break;
case BC_LEX_STR:
s = zbc_parse_string(p, BC_INST_PRINT_STR);
More information about the busybox-cvs
mailing list