gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4183-ge1be14c


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4183-ge1be14c
Date: Sun, 20 Dec 2020 13:11:09 -0500 (EST)

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  e1be14cd37e0c6c58284e18c859e334d1b5fa97f (commit)
      from  3b50111ac31a64e01a2e64a06c7c276f6b9424cf (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=e1be14cd37e0c6c58284e18c859e334d1b5fa97f

commit e1be14cd37e0c6c58284e18c859e334d1b5fa97f
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Sun Dec 20 20:10:46 2020 +0200

    Finish fixing +inform, +nancy, for MPFR.

diff --git a/ChangeLog b/ChangeLog
index 26ad3f7..87805af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2020-12-20         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Second steps fixing +inform, +nancy, for MPFR.
+
+       * builtin.c (format_nan_inf): Use mpfr_signbit instead of mpfr_sgn.
+       * mpfr.c (force_mpnum): Check for NaN and leading minus and if so
+       set the signbit with mpfr_setsign.
+       (mpg_force_number): Copy in code from f_force_number to check
+       properly for +inf, +nan.
+
 2020-12-19         Arnold D. Robbins     <arnold@skeeve.com>
 
        First steps fixing +inform, +nancy. Sigh.
diff --git a/builtin.c b/builtin.c
index afd866a..2b0f818 100644
--- a/builtin.c
+++ b/builtin.c
@@ -4293,7 +4293,7 @@ format_nan_inf(NODE *n, char format)
                return NULL;
        else if (is_mpg_float(n)) {
                if (mpfr_nan_p(n->mpg_numbr)) {
-                       strcpy(buf, mpfr_sgn(n->mpg_numbr) < 0 ? "-nan" : 
"+nan");
+                       strcpy(buf, mpfr_signbit(n->mpg_numbr) != 0 ? "-nan" : 
"+nan");
 
                        goto fmt;
                } else if (mpfr_inf_p(n->mpg_numbr)) {
diff --git a/mpfr.c b/mpfr.c
index 38f38a3..f1a460a 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -328,6 +328,8 @@ force_mpnum(NODE *n, int do_nondec, int use_locale)
 
        errno = 0;
        tval = mpfr_strtofr(n->mpg_numbr, cp, & ptr, base, ROUND_MODE);
+       if (mpfr_nan_p(n->mpg_numbr) && *cp == '-')
+               tval = mpfr_setsign(n->mpg_numbr, n->mpg_numbr, 1, ROUND_MODE);
        IEEE_FMT(n->mpg_numbr, tval);
 done:
        /* trailing space is OK for NUMBER */
@@ -345,10 +347,47 @@ done:
 static NODE *
 mpg_force_number(NODE *n)
 {
+       char *cp, *cpend;
+
        if ((n->flags & NUMCUR) != 0)
                return n;
        n->flags |= NUMCUR;
 
+       /* Trim leading white space, bailing out if there's nothing else */
+       for (cp = n->stptr, cpend = cp + n->stlen;
+            cp < cpend && isspace((unsigned char) *cp); cp++)
+               continue;
+
+       if (cp == cpend)
+               goto badnum;
+
+       /* At this point, we know the string is not entirely white space */
+       /* Trim trailing white space */
+       while (isspace((unsigned char) cpend[-1]))
+               cpend--;
+
+       /*
+        * 2/2007:
+        * POSIX, by way of severe language lawyering, seems to
+        * allow things like "inf" and "nan" to mean something.
+        * So if do_posix, the user gets what he deserves.
+        * This also allows hexadecimal floating point. Ugh.
+        */
+       if (! do_posix) {
+               if (is_alpha((unsigned char) *cp))
+                       goto badnum;
+               else if (is_ieee_magic_val(cp)) {
+                       if (cpend != cp + 4)
+                               goto badnum;
+                       /* else
+                               fall through */
+               }
+               /* else
+                       fall through */
+       }
+       /* else POSIX, so
+               fall through */
+
        if (force_mpnum(n, (do_non_decimal_data && ! do_traditional), true)) {
                if ((n->flags & USER_INPUT) != 0) {
                        /* leave USER_INPUT set to indicate a strnum */
@@ -358,6 +397,10 @@ mpg_force_number(NODE *n)
        } else
                n->flags &= ~USER_INPUT;
        return n;
+badnum:
+       mpg_zero(n);
+       n->flags &= ~USER_INPUT;
+       return n;
 }
 
 /* mpg_format_val --- format a numeric value based on format */
diff --git a/pc/ChangeLog b/pc/ChangeLog
index d8df9a3..2c0b8b3 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-20         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.tst: Rebuilt.
+
 2020-12-19         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.tst: Rebuilt.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 96902d9..0d5cef1 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -2665,9 +2665,7 @@ fieldwdth:
 forcenum:
        @echo $@ $(ZOS_FAIL)
        @AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --non-decimal-data >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
-       @-if echo "$$GAWK_TEST_ARGS" | egrep -q -e '-M|--bignum' > /dev/null ; \
-       then $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ ; \
-       else $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ; fi
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
 fpat1:
        @echo $@
diff --git a/test/ChangeLog b/test/ChangeLog
index 48f28ed..f1c0a6a 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-20         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.am (EXTRA_DIST): Remove forcenum-mpfr.ok.
+       * forcenum-mpfr.ok: File deleted, no longer needed.
+
 2020-12-19         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.am (EXTRA_DIST): inf-nan-torture, new test.
diff --git a/test/Makefile.am b/test/Makefile.am
index 278a0eb..097dc26 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -344,7 +344,6 @@ EXTRA_DIST = \
        fnparydl.ok \
        forcenum.awk \
        forcenum.ok \
-       forcenum-mpfr.ok \
        fordel.awk \
        fordel.ok \
        fork.awk \
diff --git a/test/Makefile.in b/test/Makefile.in
index e0528b9..871e5a4 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -607,7 +607,6 @@ EXTRA_DIST = \
        fnparydl.ok \
        forcenum.awk \
        forcenum.ok \
-       forcenum-mpfr.ok \
        fordel.awk \
        fordel.ok \
        fork.awk \
@@ -4325,9 +4324,7 @@ fieldwdth:
 forcenum:
        @echo $@ $(ZOS_FAIL)
        @AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --non-decimal-data >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
-       @-if echo "$$GAWK_TEST_ARGS" | egrep -q -e '-M|--bignum' > /dev/null ; \
-       then $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ ; \
-       else $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ; fi
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
 fpat1:
        @echo $@
diff --git a/test/Maketests b/test/Maketests
index d849f54..90599c4 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -1409,9 +1409,7 @@ fieldwdth:
 forcenum:
        @echo $@ $(ZOS_FAIL)
        @AWKPATH="$(srcdir)" $(AWK) -f $@.awk  --non-decimal-data >_$@ 2>&1 || 
echo EXIT CODE: $$? >>_$@
-       @-if echo "$$GAWK_TEST_ARGS" | egrep -q -e '-M|--bignum' > /dev/null ; \
-       then $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ ; \
-       else $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ; fi
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
 fpat1:
        @echo $@
diff --git a/test/forcenum-mpfr.ok b/test/forcenum-mpfr.ok
deleted file mode 100644
index 6e5853f..0000000
--- a/test/forcenum-mpfr.ok
+++ /dev/null
@@ -1,9 +0,0 @@
-[] -> 0 (type string)
-[5apple] -> 5 (type string)
-[NaN] -> nan (type strnum)
-[-NaN] -> nan (type strnum)
-[+NaN] -> nan (type strnum)
-[ 6] -> 6 (type strnum)
-[0x1az] -> 26 (type string)
-[011Q] -> 9 (type string)
-[027] -> 23 (type strnum)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog             | 10 ++++++++++
 builtin.c             |  2 +-
 mpfr.c                | 43 +++++++++++++++++++++++++++++++++++++++++++
 pc/ChangeLog          |  4 ++++
 pc/Makefile.tst       |  4 +---
 test/ChangeLog        |  5 +++++
 test/Makefile.am      |  1 -
 test/Makefile.in      |  5 +----
 test/Maketests        |  4 +---
 test/forcenum-mpfr.ok |  9 ---------
 10 files changed, 66 insertions(+), 21 deletions(-)
 delete mode 100644 test/forcenum-mpfr.ok


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]