diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-08-05 20:18:50 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-08-05 20:18:50 +0300 |
commit | 492c24d65f760edea1f9228260930728eb747cf7 (patch) | |
tree | b5b37e26bb36a4041f7f431de3d5a7a2436b0410 | |
parent | f2e5270b21042a09bf33b86f31fbe79bd8fbea06 (diff) | |
download | egawk-492c24d65f760edea1f9228260930728eb747cf7.tar.gz egawk-492c24d65f760edea1f9228260930728eb747cf7.tar.bz2 egawk-492c24d65f760edea1f9228260930728eb747cf7.zip |
MPFR division by zero is now a fatal error.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | mpfr.c | 6 |
3 files changed, 17 insertions, 1 deletions
@@ -5,6 +5,13 @@ code into line with regular code. Bug report from Neil Ormos in the help-gawk list. + Unrelated: + + * mpfr.c (do_mpfr_int_div, mpg_div, mpg_mod): If dividing by + zero, print a fatal error messages. Brings MPFR code into line + with the regular code. Thanks to Peng Yu for noticing the bug, in + the help-gawk list. + 2021-07-23 Arnold D. Robbins <arnold@skeeve.com> * awk.h (exec_count_t): Add typedef for Vax VMS C and everyone else. @@ -53,7 +53,10 @@ Changes from 5.1.0 to 5.1.1 14. The manual has been updated with much more information about what is and is not a bug, and the changes in the gawk mailing lists. -15. There have been numerous minor code cleanups and bug fixes. See the +15. Similar to item #4 above, division by zero is now fatal in MPFR + mode, as it is in regular mode. + +16. There have been numerous minor code cleanups and bug fixes. See the ChangeLog for details. Changes from 5.0.1 to 5.1.0 @@ -1509,6 +1509,8 @@ mpg_div(NODE *t1, NODE *t2) mpfr_ptr p1, p2; p1 = MP_FLOAT(t1); p2 = MP_FLOAT(t2); + if (mpfr_zero_p(p2)) + fatal(_("division by zero attempted")); r = mpg_float(); tval = mpfr_div(r->mpg_numbr, p1, p2, ROUND_MODE); IEEE_FMT(r->mpg_numbr, tval); @@ -1542,6 +1544,8 @@ mpg_mod(NODE *t1, NODE *t2) */ NODE *dummy_quotient; + if (mpz_sgn(t2->mpg_i) == 0) + fatal(_("division by zero attempted")); r = mpg_integer(); dummy_quotient = mpg_integer(); mpz_tdiv_qr(dummy_quotient->mpg_i, r->mpg_i, t1->mpg_i, t2->mpg_i); @@ -1550,6 +1554,8 @@ mpg_mod(NODE *t1, NODE *t2) mpfr_ptr p1, p2; p1 = MP_FLOAT(t1); p2 = MP_FLOAT(t2); + if (mpfr_zero_p(p2)) + fatal(_("division by zero attempted in `%%'")); r = mpg_float(); tval = mpfr_fmod(r->mpg_numbr, p1, p2, ROUND_MODE); IEEE_FMT(r->mpg_numbr, tval); |