[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4276-g492c24d
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4276-g492c24d |
Date: |
Thu, 5 Aug 2021 13:19:11 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, gawk-5.1-stable has been updated
via 492c24d65f760edea1f9228260930728eb747cf7 (commit)
via f2e5270b21042a09bf33b86f31fbe79bd8fbea06 (commit)
from 41658f8679967bd276973c3fe02f6d4db94975e3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=492c24d65f760edea1f9228260930728eb747cf7
commit 492c24d65f760edea1f9228260930728eb747cf7
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Thu Aug 5 20:18:50 2021 +0300
MPFR division by zero is now a fatal error.
diff --git a/ChangeLog b/ChangeLog
index 7389624..c598dac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/NEWS b/NEWS
index 7b9c4d2..9b420f9 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/mpfr.c b/mpfr.c
index cf18288..4010d0c 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -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);
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=f2e5270b21042a09bf33b86f31fbe79bd8fbea06
commit f2e5270b21042a09bf33b86f31fbe79bd8fbea06
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Thu Aug 5 20:11:07 2021 +0300
Add warnings for negative arguments for -M mode.
diff --git a/ChangeLog b/ChangeLog
index a03edc8..7389624 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-08-05 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * mpfr.c (do_mpfr_func): New argument, warn_negative. If true,
+ print a warning message about a negative argument. Bring -M
+ code into line with regular code. Bug report from Neil Ormos
+ 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.
diff --git a/mpfr.c b/mpfr.c
index cabc391..cf18288 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -749,7 +749,7 @@ do_mpfr_atan2(int nargs)
static inline NODE *
do_mpfr_func(const char *name,
int (*mpfr_func)(mpfr_ptr, mpfr_srcptr, mpfr_rnd_t),
- int nargs)
+ int nargs, bool warn_negative)
{
NODE *t1, *res;
mpfr_ptr p1;
@@ -762,6 +762,10 @@ do_mpfr_func(const char *name,
force_number(t1);
p1 = MP_FLOAT(t1);
+ if (warn_negative && mpfr_sgn(p1) < 0) {
+ force_string(t1);
+ warning(_("%s: received negative argument %.*s"), name, (int)
t1->stlen, t1->stptr);
+ }
res = mpg_float();
if ((argprec = mpfr_get_prec(p1)) > default_prec)
mpfr_set_prec(res->mpg_numbr, argprec); /* needed at least for
sqrt() */
@@ -771,9 +775,9 @@ do_mpfr_func(const char *name,
return res;
}
-#define SPEC_MATH(X) \
+#define SPEC_MATH(X, WN) \
NODE *result; \
-result = do_mpfr_func(#X, mpfr_##X, nargs); \
+result = do_mpfr_func(#X, mpfr_##X, nargs, WN); \
return result
/* do_mpfr_sin --- do the sin function */
@@ -781,7 +785,7 @@ return result
NODE *
do_mpfr_sin(int nargs)
{
- SPEC_MATH(sin);
+ SPEC_MATH(sin, false);
}
/* do_mpfr_cos --- do the cos function */
@@ -789,7 +793,7 @@ do_mpfr_sin(int nargs)
NODE *
do_mpfr_cos(int nargs)
{
- SPEC_MATH(cos);
+ SPEC_MATH(cos, false);
}
/* do_mpfr_exp --- exponential function */
@@ -797,7 +801,7 @@ do_mpfr_cos(int nargs)
NODE *
do_mpfr_exp(int nargs)
{
- SPEC_MATH(exp);
+ SPEC_MATH(exp, false);
}
/* do_mpfr_log --- the log function */
@@ -805,7 +809,7 @@ do_mpfr_exp(int nargs)
NODE *
do_mpfr_log(int nargs)
{
- SPEC_MATH(log);
+ SPEC_MATH(log, true);
}
/* do_mpfr_sqrt --- do the sqrt function */
@@ -813,7 +817,7 @@ do_mpfr_log(int nargs)
NODE *
do_mpfr_sqrt(int nargs)
{
- SPEC_MATH(sqrt);
+ SPEC_MATH(sqrt, true);
}
/* do_mpfr_int --- convert double to int for awk */
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 14 ++++++++++++++
NEWS | 5 ++++-
mpfr.c | 26 ++++++++++++++++++--------
3 files changed, 36 insertions(+), 9 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4276-g492c24d,
Arnold Robbins <=