diff options
-rw-r--r-- | miscutils/bc.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c index 6d54f968a..48be3d8a3 100644 --- a/miscutils/bc.c +++ b/miscutils/bc.c | |||
@@ -1827,7 +1827,7 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b, | |||
1827 | #define zbc_num_k(...) (zbc_num_k(__VA_ARGS__) COMMA_SUCCESS) | 1827 | #define zbc_num_k(...) (zbc_num_k(__VA_ARGS__) COMMA_SUCCESS) |
1828 | { | 1828 | { |
1829 | BcStatus s; | 1829 | BcStatus s; |
1830 | size_t max = BC_MAX(a->len, b->len), max2 = (max + 1) / 2; | 1830 | size_t max, max2; |
1831 | BcNum l1, h1, l2, h2, m2, m1, z0, z1, z2, temp; | 1831 | BcNum l1, h1, l2, h2, m2, m1, z0, z1, z2, temp; |
1832 | bool aone; | 1832 | bool aone; |
1833 | 1833 | ||
@@ -1877,6 +1877,7 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b, | |||
1877 | RETURN_STATUS(BC_STATUS_SUCCESS); | 1877 | RETURN_STATUS(BC_STATUS_SUCCESS); |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | max = BC_MAX(a->len, b->len); | ||
1880 | bc_num_init(&l1, max); | 1881 | bc_num_init(&l1, max); |
1881 | bc_num_init(&h1, max); | 1882 | bc_num_init(&h1, max); |
1882 | bc_num_init(&l2, max); | 1883 | bc_num_init(&l2, max); |
@@ -1888,6 +1889,7 @@ static FAST_FUNC BC_STATUS zbc_num_k(BcNum *restrict a, BcNum *restrict b, | |||
1888 | bc_num_init(&z2, max); | 1889 | bc_num_init(&z2, max); |
1889 | bc_num_init(&temp, max + max); | 1890 | bc_num_init(&temp, max + max); |
1890 | 1891 | ||
1892 | max2 = (max + 1) / 2; | ||
1891 | bc_num_split(a, max2, &l1, &h1); | 1893 | bc_num_split(a, max2, &l1, &h1); |
1892 | bc_num_split(b, max2, &l2, &h2); | 1894 | bc_num_split(b, max2, &l2, &h2); |
1893 | 1895 | ||
@@ -2524,9 +2526,6 @@ static void xc_read_line(BcVec *vec, FILE *fp) | |||
2524 | 2526 | ||
2525 | #if ENABLE_FEATURE_BC_INTERACTIVE | 2527 | #if ENABLE_FEATURE_BC_INTERACTIVE |
2526 | if (G_interrupt) { // ^C was pressed | 2528 | if (G_interrupt) { // ^C was pressed |
2527 | # if ENABLE_FEATURE_EDITING | ||
2528 | intr: | ||
2529 | # endif | ||
2530 | if (fp != stdin) { | 2529 | if (fp != stdin) { |
2531 | // ^C while running a script (bc SCRIPT): die. | 2530 | // ^C while running a script (bc SCRIPT): die. |
2532 | // We do not return to interactive prompt: | 2531 | // We do not return to interactive prompt: |
@@ -2537,11 +2536,11 @@ static void xc_read_line(BcVec *vec, FILE *fp) | |||
2537 | // the shell would be unexpected. | 2536 | // the shell would be unexpected. |
2538 | xfunc_die(); | 2537 | xfunc_die(); |
2539 | } | 2538 | } |
2540 | // ^C while interactive input | 2539 | // There was ^C while running calculations |
2541 | G_interrupt = 0; | 2540 | G_interrupt = 0; |
2542 | // GNU bc says "interrupted execution." | 2541 | // GNU bc says "interrupted execution." (to stdout, not stderr) |
2543 | // GNU dc says "Interrupt!" | 2542 | // GNU dc says "Interrupt!" |
2544 | fputs("\ninterrupted execution\n", stderr); | 2543 | puts("\ninterrupted execution"); |
2545 | } | 2544 | } |
2546 | 2545 | ||
2547 | # if ENABLE_FEATURE_EDITING | 2546 | # if ENABLE_FEATURE_EDITING |
@@ -2552,9 +2551,10 @@ static void xc_read_line(BcVec *vec, FILE *fp) | |||
2552 | # define line_buf bb_common_bufsiz1 | 2551 | # define line_buf bb_common_bufsiz1 |
2553 | n = read_line_input(G.line_input_state, "", line_buf, COMMON_BUFSIZE); | 2552 | n = read_line_input(G.line_input_state, "", line_buf, COMMON_BUFSIZE); |
2554 | if (n <= 0) { // read errors or EOF, or ^D, or ^C | 2553 | if (n <= 0) { // read errors or EOF, or ^D, or ^C |
2555 | if (n == 0) // ^C | 2554 | //GNU bc prints this on ^C: |
2556 | goto intr; | 2555 | //if (n == 0) // ^C |
2557 | bc_vec_pushZeroByte(vec); // ^D or EOF (or error) | 2556 | // puts("(interrupt) Exiting bc."); |
2557 | bc_vec_pushZeroByte(vec); | ||
2558 | return; | 2558 | return; |
2559 | } | 2559 | } |
2560 | i = 0; | 2560 | i = 0; |