diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-08 23:48:53 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-12-08 23:48:53 +0100 |
commit | 0f37b3286a9a999286606e0ec32cdf2902354099 (patch) | |
tree | 3bf5380243ce5c1659e03db5d7295c20fed4f498 /miscutils/bc.c | |
parent | ebc41c9d9439feda167e12b27e83f7941246d76c (diff) | |
download | busybox-w32-0f37b3286a9a999286606e0ec32cdf2902354099.tar.gz busybox-w32-0f37b3286a9a999286606e0ec32cdf2902354099.tar.bz2 busybox-w32-0f37b3286a9a999286606e0ec32cdf2902354099.zip |
bc: eliminate always the same params to bc_num_printBase()
function old new delta
bc_program_print 739 736 -3
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r-- | miscutils/bc.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index aeb06a97b..450c21c60 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -2436,28 +2436,31 @@ err: | |||
2436 | return s; | 2436 | return s; |
2437 | } | 2437 | } |
2438 | 2438 | ||
2439 | static BcStatus bc_num_printBase(BcNum *n, BcNum *base, size_t base_t) | 2439 | static BcStatus bc_num_printBase(BcNum *n) |
2440 | { | 2440 | { |
2441 | BcStatus s; | 2441 | BcStatus s; |
2442 | size_t width, i; | 2442 | size_t width, i; |
2443 | BcNumDigitOp print; | 2443 | BcNumDigitOp print; |
2444 | bool neg = n->neg; | 2444 | bool neg = n->neg; |
2445 | 2445 | ||
2446 | if (neg) bb_putchar('-'); | 2446 | if (neg) { |
2447 | G.prog.nchars += neg; | 2447 | bb_putchar('-'); |
2448 | G.prog.nchars++; | ||
2449 | } | ||
2448 | 2450 | ||
2449 | n->neg = false; | 2451 | n->neg = false; |
2450 | 2452 | ||
2451 | if (base_t <= BC_NUM_MAX_IBASE) { | 2453 | if (G.prog.ob_t <= BC_NUM_MAX_IBASE) { |
2452 | width = 1; | 2454 | width = 1; |
2453 | print = bc_num_printHex; | 2455 | print = bc_num_printHex; |
2454 | } | 2456 | } |
2455 | else { | 2457 | else { |
2456 | for (i = base_t - 1, width = 0; i != 0; i /= 10, ++width); | 2458 | for (i = G.prog.ob_t - 1, width = 0; i != 0; i /= 10, ++width) |
2459 | continue; | ||
2457 | print = bc_num_printDigits; | 2460 | print = bc_num_printDigits; |
2458 | } | 2461 | } |
2459 | 2462 | ||
2460 | s = bc_num_printNum(n, base, width, print); | 2463 | s = bc_num_printNum(n, &G.prog.ob, width, print); |
2461 | n->neg = neg; | 2464 | n->neg = neg; |
2462 | 2465 | ||
2463 | return s; | 2466 | return s; |
@@ -2486,9 +2489,6 @@ static BcStatus bc_num_parse(BcNum *n, const char *val, BcNum *base, | |||
2486 | 2489 | ||
2487 | static BcStatus bc_num_print(BcNum *n, bool newline) | 2490 | static BcStatus bc_num_print(BcNum *n, bool newline) |
2488 | { | 2491 | { |
2489 | BcNum *base = &G.prog.ob; | ||
2490 | size_t base_t = G.prog.ob_t; | ||
2491 | |||
2492 | BcStatus s = BC_STATUS_SUCCESS; | 2492 | BcStatus s = BC_STATUS_SUCCESS; |
2493 | 2493 | ||
2494 | bc_num_printNewline(); | 2494 | bc_num_printNewline(); |
@@ -2497,10 +2497,10 @@ static BcStatus bc_num_print(BcNum *n, bool newline) | |||
2497 | bb_putchar('0'); | 2497 | bb_putchar('0'); |
2498 | ++G.prog.nchars; | 2498 | ++G.prog.nchars; |
2499 | } | 2499 | } |
2500 | else if (base_t == 10) | 2500 | else if (G.prog.ob_t == 10) |
2501 | bc_num_printDecimal(n); | 2501 | bc_num_printDecimal(n); |
2502 | else | 2502 | else |
2503 | s = bc_num_printBase(n, base, base_t); | 2503 | s = bc_num_printBase(n); |
2504 | 2504 | ||
2505 | if (newline) { | 2505 | if (newline) { |
2506 | bb_putchar('\n'); | 2506 | bb_putchar('\n'); |