aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-08 23:48:53 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-08 23:48:53 +0100
commit0f37b3286a9a999286606e0ec32cdf2902354099 (patch)
tree3bf5380243ce5c1659e03db5d7295c20fed4f498 /miscutils
parentebc41c9d9439feda167e12b27e83f7941246d76c (diff)
downloadbusybox-0f37b3286a9a999286606e0ec32cdf2902354099.tar.gz
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')
-rw-r--r--miscutils/bc.c22
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:
return s;
}
-static BcStatus bc_num_printBase(BcNum *n, BcNum *base, size_t base_t)
+static BcStatus bc_num_printBase(BcNum *n)
{
BcStatus s;
size_t width, i;
BcNumDigitOp print;
bool neg = n->neg;
- if (neg) bb_putchar('-');
- G.prog.nchars += neg;
+ if (neg) {
+ bb_putchar('-');
+ G.prog.nchars++;
+ }
n->neg = false;
- if (base_t <= BC_NUM_MAX_IBASE) {
+ if (G.prog.ob_t <= BC_NUM_MAX_IBASE) {
width = 1;
print = bc_num_printHex;
}
else {
- for (i = base_t - 1, width = 0; i != 0; i /= 10, ++width);
+ for (i = G.prog.ob_t - 1, width = 0; i != 0; i /= 10, ++width)
+ continue;
print = bc_num_printDigits;
}
- s = bc_num_printNum(n, base, width, print);
+ s = bc_num_printNum(n, &G.prog.ob, width, print);
n->neg = neg;
return s;
@@ -2486,9 +2489,6 @@ static BcStatus bc_num_parse(BcNum *n, const char *val, BcNum *base,
static BcStatus bc_num_print(BcNum *n, bool newline)
{
- BcNum *base = &G.prog.ob;
- size_t base_t = G.prog.ob_t;
-
BcStatus s = BC_STATUS_SUCCESS;
bc_num_printNewline();
@@ -2497,10 +2497,10 @@ static BcStatus bc_num_print(BcNum *n, bool newline)
bb_putchar('0');
++G.prog.nchars;
}
- else if (base_t == 10)
+ else if (G.prog.ob_t == 10)
bc_num_printDecimal(n);
else
- s = bc_num_printBase(n, base, base_t);
+ s = bc_num_printBase(n);
if (newline) {
bb_putchar('\n');