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-4362-g09e98ee


From: Andrew J. Schorr
Subject: [SCM] gawk branch, gawk-5.1-stable, updated. gawk-4.1.0-4362-g09e98ee
Date: Wed, 8 Dec 2021 10:06:52 -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  09e98ee95fb453adc0f1783937477cd065611581 (commit)
      from  e03c8822c48bedfe6cc7fbd5a9382d9630de6494 (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=09e98ee95fb453adc0f1783937477cd065611581

commit 09e98ee95fb453adc0f1783937477cd065611581
Author: Andrew J. Schorr <aschorr@telemetry-investments.com>
Date:   Wed Dec 8 10:05:06 2021 -0500

    In extension rwarray, write and read mpfr values as strings instead of 
using the new and experimental floating-point interchange format.

diff --git a/extension/ChangeLog b/extension/ChangeLog
index c2624e6..9578a94 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,11 @@
+2021-12-08         Andrew J. Schorr      <aschorr@telemetry-investments.com>
+
+       * rwarray.c (write_number): Since mpfr_fpif_export is experimental
+       and not available in older versions of mpfr, add an ifdef to
+       use mpfr_out_str instead.
+       (read_number): Similarly, use mpfr_inp_str instead of
+       mpfr_fpif_import.
+
 2021-11-18         Arnold D. Robbins     <arnold@skeeve.com>
 
        * rwarray.c: Add support for writing/reading GMP and MPFR values.
diff --git a/extension/rwarray.c b/extension/rwarray.c
index 9a8d15e..1356005 100644
--- a/extension/rwarray.c
+++ b/extension/rwarray.c
@@ -313,7 +313,22 @@ write_number(FILE *fp, awk_value_t *val)
                        if (fwrite(& code, 1, sizeof(code), fp) != sizeof(code))
                                return awk_false;
 
+#ifdef USE_MPFR_FPIF
+                       /* This would be preferable, but it is not available
+                        * on older platforms with mpfr 3.x. It's also marked
+                        * experimental in mpfr 4.1, so perhaps not ready for
+                        * production use yet. */
                        if (mpfr_fpif_export(fp, val->num_ptr) != 0)
+#else
+#define MPFR_STR_BASE  62         /* maximize base to minimize string len */
+#define MPFR_STR_ROUND MPFR_RNDN
+                       /* XXX does the choice of MPFR_RNDN matter, given
+                        * that the precision is 0, so we should be rendering
+                        * in full precision? */
+                       /* We need to write a terminating space, since
+                        * mpfr_inp_str reads until it hits a space or EOF */
+                       if ((mpfr_out_str(fp, MPFR_STR_BASE, 0, val->num_ptr, 
MPFR_STR_ROUND) == 0) || (putc(' ', fp) == EOF))
+#endif
                                return awk_false;
                } else {
                        code = htonl(VT_GMP);
@@ -595,7 +610,14 @@ read_number(FILE *fp, awk_value_t *value, uint32_t code)
                        mpfr_t mpfr_val;
                        mpfr_init(mpfr_val);
 
+#ifdef USE_MPFR_FPIF
+                       /* preferable if widely available and stable */
                        if (mpfr_fpif_import(mpfr_val, fp) != 0)
+#else
+                       /* N.B. need to consume the terminating space we wrote
+                        * after mpfr_out_str */
+                       if ((mpfr_inp_str(mpfr_val, fp, MPFR_STR_BASE, 
MPFR_STR_ROUND) == 0) || (getc(fp) != ' '))
+#endif
                                return awk_false;
 
                        value = make_number_mpfr(& mpfr_val, value);

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

Summary of changes:
 extension/ChangeLog |  8 ++++++++
 extension/rwarray.c | 22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)


hooks/post-receive
-- 
gawk



reply via email to

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