1 From 0fafaee9bb38a3ea4b8be4009e9ce99334460ddd Mon Sep 17 00:00:00 2001
2 From: "Arnold D. Robbins" <arnold@skeeve.com>
3 Date: Mon, 2 Apr 2018 16:37:17 +0300
4 Subject: [PATCH] Copy MPZ/MPFR bits also, in r_dupnode.
7 interpret.h | 27 ++++++++++++++++++---------
8 node.c | 20 ++++++++++++++++++--
9 test/Makefile.am | 12 ++++++++++--
10 test/Makefile.in | 12 ++++++++++--
11 test/mpfrfield.awk | 14 ++++++++++++++
12 test/mpfrfield.in | 10 ++++++++++
13 test/mpfrfield.ok | 1 +
14 7 files changed, 81 insertions(+), 15 deletions(-)
15 create mode 100644 test/mpfrfield.awk
16 create mode 100644 test/mpfrfield.in
17 create mode 100644 test/mpfrfield.ok
19 diff --git a/interpret.h b/interpret.h
20 index 96e2c89..20fcb7a 100644
24 * valref 1, that effectively means that this is an assignment like "$n = $n",
25 * so a no-op, other than triggering $0 reconstitution.
27 -#define UNFIELD(l, r) \
29 - /* if was a field, turn it into a var */ \
30 - if ((r->flags & MALLOC) != 0 || r->valref == 1) { \
37 +// not a macro so we can step into it with a debugger
38 +#ifndef UNFIELD_DEFINED
39 +#define UNFIELD_DEFINED 1
41 +unfield(NODE **l, NODE **r)
43 + /* if was a field, turn it into a var */
44 + if (((*r)->flags & MALLOC) != 0 || (*r)->valref == 1) {
52 +#define UNFIELD(l, r) unfield(& (l), & (r))
56 r_interpret(INSTRUCTION *code)
58 diff --git a/node.c b/node.c
59 index add959f..fcd2bf3 100644
62 @@ -306,8 +306,24 @@ r_dupnode(NODE *n)
69 + if ((n->flags & MPZN) != 0) {
71 + mpz_set(r->mpg_i, n->mpg_i);
72 + r->flags = n->flags;
73 + } else if ((n->flags & MPFN) != 0) {
75 + int tval = mpfr_set(r->mpg_numbr, n->mpg_numbr, ROUND_MODE);
76 + IEEE_FMT(r->mpg_numbr, tval);
77 + r->flags = n->flags;
89 diff --git a/test/Makefile.am b/test/Makefile.am
90 index 40e25b2..93a6ee5 100644
91 --- a/test/Makefile.am
92 +++ b/test/Makefile.am
93 @@ -655,6 +655,9 @@ EXTRA_DIST = \
103 @@ -1302,8 +1305,8 @@ INET_TESTS = inetdayu inetdayt inetechu inetecht
105 MACHINE_TESTS = double1 double2 fmtspcl intformat
107 -MPFR_TESTS = mpfrbigint mpfrexprange mpfrieee mpfrmemok1 mpfrnegzero \
108 - mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
109 +MPFR_TESTS = mpfrbigint mpfrexprange mpfrfield mpfrieee mpfrmemok1 \
110 + mpfrnegzero mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
111 mpfrstrtonum mpgforcenum mpfruplus
113 LOCALE_CHARSET_TESTS = \
114 @@ -2148,6 +2151,11 @@ mpfrmemok1:
115 @$(AWK) -p- -M -f "$(srcdir)"/$@.awk 2>&1 | sed 1d > _$@
116 @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
120 + @$(AWK) -M -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in > _$@ 2>&1
121 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
125 @"$(srcdir)"/$@.sh "$(AWKPROG)" "$(srcdir)"/$@.awk "$(srcdir)"/$@.in "_$@"
126 diff --git a/test/Makefile.in b/test/Makefile.in
127 index 74405f8..2358988 100644
128 --- a/test/Makefile.in
129 +++ b/test/Makefile.in
130 @@ -913,6 +913,9 @@ EXTRA_DIST = \
140 @@ -1555,8 +1558,8 @@ ARRAYDEBUG_TESTS = arrdbg
141 EXTRA_TESTS = inftest regtest ignrcas3
142 INET_TESTS = inetdayu inetdayt inetechu inetecht
143 MACHINE_TESTS = double1 double2 fmtspcl intformat
144 -MPFR_TESTS = mpfrbigint mpfrexprange mpfrieee mpfrmemok1 mpfrnegzero \
145 - mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
146 +MPFR_TESTS = mpfrbigint mpfrexprange mpfrfield mpfrieee mpfrmemok1 \
147 + mpfrnegzero mpfrnr mpfrrem mpfrrnd mpfrrndeval mpfrsort mpfrsqrt \
148 mpfrstrtonum mpgforcenum mpfruplus
150 LOCALE_CHARSET_TESTS = \
151 @@ -2588,6 +2591,11 @@ mpfrmemok1:
152 @$(AWK) -p- -M -f "$(srcdir)"/$@.awk 2>&1 | sed 1d > _$@
153 @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
157 + @$(AWK) -M -f "$(srcdir)"/$@.awk "$(srcdir)"/$@.in > _$@ 2>&1
158 + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
162 @"$(srcdir)"/$@.sh "$(AWKPROG)" "$(srcdir)"/$@.awk "$(srcdir)"/$@.in "_$@"
163 diff --git a/test/mpfrfield.awk b/test/mpfrfield.awk
165 index 0000000..35a97b7
167 +++ b/test/mpfrfield.awk
183 diff --git a/test/mpfrfield.in b/test/mpfrfield.in
185 index 0000000..05d3344
187 +++ b/test/mpfrfield.in
199 diff --git a/test/mpfrfield.ok b/test/mpfrfield.ok
201 index 0000000..3736de4
203 +++ b/test/mpfrfield.ok