aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-22 23:14:48 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-22 23:14:48 +0100
commit1acac7f9c596cd447d197039216f7b55c9ee3ab3 (patch)
treeb3ae155549c55401c798f575143967b6cdd0814c /miscutils
parenta9f59db809d45847779b9c631d663a25b6115d7d (diff)
downloadbusybox-1acac7f9c596cd447d197039216f7b55c9ee3ab3.tar.gz
bc: do not yet allow 2^2.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index ae5105b01..8cd67b0f5 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2095,8 +2095,10 @@ static FAST_FUNC BC_STATUS zbc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size
size_t i, powrdx, resrdx;
bool neg;
-// GNU bc does not allow 2^2.0. We do.
-// if (b->rdx) RETURN_STATUS(bc_error("non integer number"));
+ // GNU bc does not allow 2^2.0 - we do
+ for (i = 0; i < b->rdx; i++)
+ if (b->num[i] != 0)
+ RETURN_STATUS(bc_error("not an integer"));
if (b->len == 0) {
bc_num_one(c);
@@ -2505,7 +2507,7 @@ static BC_STATUS zdc_num_modexp(BcNum *a, BcNum *b, BcNum *c, BcNum *restrict d)
if (c->len == 0)
RETURN_STATUS(bc_error("divide by zero"));
if (a->rdx || b->rdx || c->rdx)
- RETURN_STATUS(bc_error("non integer number"));
+ RETURN_STATUS(bc_error("not an integer"));
if (b->neg)
RETURN_STATUS(bc_error("negative number"));