aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 01:21:59 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-05 15:43:35 +0100
commitf359e004b0ce4a5ac361f553c13e876123fd4ebb (patch)
treeee0c7332b6d66832970ec80481051b61b0dac017
parent68cc0a676eeceffae84a91b73895b5c4d72c2021 (diff)
downloadbusybox-f359e004b0ce4a5ac361f553c13e876123fd4ebb.tar.gz
bc: make 2^1000000 interruptible faster
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 866fa3027..b392b05a3 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2039,6 +2039,11 @@ static BcStatus bc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
powrdx <<= 1;
s = bc_num_mul(&copy, &copy, &copy, powrdx);
if (s) goto err;
+ // It is too slow to handle ^C only after entire "2^1000000" completes
+ if (G_interrupt) {
+ s = BC_STATUS_FAILURE;
+ goto err;
+ }
}
bc_num_copy(c, &copy);
@@ -2054,6 +2059,11 @@ static BcStatus bc_num_p(BcNum *a, BcNum *b, BcNum *restrict c, size_t scale)
s = bc_num_mul(c, &copy, c, resrdx);
if (s) goto err;
}
+ // It is too slow to handle ^C only after entire "2^1000000" completes
+ if (G_interrupt) {
+ s = BC_STATUS_FAILURE;
+ goto err;
+ }
}
if (neg) {