summaryrefslogtreecommitdiff
path: root/miscutils/bc.c
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-03 19:12:29 +0100
committerDenys Vlasenko2018-12-05 15:43:35 +0100
commitbc5ce66617b6aa32b0ff7b51435cfc2c00c8ea89 (patch)
treeda0c698853a3f91b992531ae607896f79b17d7fd /miscutils/bc.c
parentc1c2470f843c0b8218dd3611330a941b00d0cc34 (diff)
downloadbusybox-bc5ce66617b6aa32b0ff7b51435cfc2c00c8ea89.zip
busybox-bc5ce66617b6aa32b0ff7b51435cfc2c00c8ea89.tar.gz
bc: simplify bc_lex_comment()
function old new delta bc_lex_token 1369 1344 -25 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r--miscutils/bc.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index dd01f54..ecd19cb 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -3090,24 +3090,27 @@ static BcStatus bc_lex_comment(BcLex *l)
{
size_t i, nls = 0;
const char *buf = l->buf;
- bool end = false;
- char c;
l->t.t = BC_LEX_WHITESPACE;
-
- for (i = ++l->i; !end; i += !end) {
-
- for (c = buf[i]; c != '*' && c != 0; c = buf[++i]) nls += (c == '\n');
-
- if (c == 0 || buf[i + 1] == '\0') {
+ i = ++l->i;
+ for (;;) {
+ char c = buf[i];
+ check_star:
+ if (c == '*') {
+ c = buf[++i];
+ if (c == '/')
+ break;
+ goto check_star;
+ }
+ if (c == '\0') {
l->i = i;
return BC_STATUS_LEX_NO_COMMENT_END;
}
-
- end = buf[i + 1] == '/';
+ nls += (c == '\n');
+ i++;
}
- l->i = i + 2;
+ l->i = i + 1;
l->line += nls;
return BC_STATUS_SUCCESS;