diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | gawkapi.c | 7 | ||||
-rw-r--r-- | interpret.h | 3 | ||||
-rw-r--r-- | test/ChangeLog | 11 | ||||
-rw-r--r-- | test/Makefile.am | 14 | ||||
-rw-r--r-- | test/Makefile.in | 10 | ||||
-rw-r--r-- | test/arrdbg-mpfr.ok | 12 | ||||
-rw-r--r-- | test/arrdbg.awk | 16 | ||||
-rw-r--r-- | test/testext-mpfr.ok | 94 |
9 files changed, 140 insertions, 35 deletions
@@ -2,6 +2,14 @@ * mpfr.c (mpg_interpret): Make the instruction tracing more sane. + Fix the testext test for MPFR. + + * gawkapi.c (awk_value_to_node): Use correct code to copy + MPFR/MPN numbers and don't free the original values. + * interpret.h (r_interpret): At Op_ext_builtin, separate out calls + to the external function and awk_value_to_node, for ease in a + debugger. + 2020-07-10 Arnold D. Robbins <arnold@skeeve.com> Fix printf issues. Thanks to Michal Jaegermann for the report. @@ -177,8 +177,8 @@ awk_value_to_node(const awk_value_t *retval) if (! do_mpfr) fatal(_("awk_value_to_node: not in MPFR mode")); ext_ret_val = make_number_node(MPFN); - memcpy(&ext_ret_val->mpg_numbr, retval->num_ptr, sizeof(ext_ret_val->mpg_numbr)); - freempfr(retval->num_ptr); + int tval = mpfr_set(ext_ret_val->mpg_numbr, (mpfr_ptr) retval->num_ptr, ROUND_MODE); + IEEE_FMT(ext_ret_val->mpg_numbr, tval); #else fatal(_("awk_value_to_node: MPFR not supported")); #endif @@ -188,8 +188,7 @@ awk_value_to_node(const awk_value_t *retval) if (! do_mpfr) fatal(_("awk_value_to_node: not in MPFR mode")); ext_ret_val = make_number_node(MPZN); - memcpy(&ext_ret_val->mpg_i, retval->num_ptr, sizeof(ext_ret_val->mpg_i)); - freempz(retval->num_ptr); + mpz_set(ext_ret_val->mpg_i, (mpz_ptr) retval->num_ptr); #else fatal(_("awk_value_to_node: MPFR not supported")); #endif diff --git a/interpret.h b/interpret.h index 4de778e7..efbf9b23 100644 --- a/interpret.h +++ b/interpret.h @@ -1037,7 +1037,8 @@ arrayfor: (unsigned long) max_expect); PUSH_CODE(pc); - r = awk_value_to_node(pc->extfunc(arg_count, & result, f)); + awk_value_t *ef_ret = pc->extfunc(arg_count, & result, f); + r = awk_value_to_node(ef_ret); (void) POP_CODE(); while (arg_count-- > 0) { t1 = POP(); diff --git a/test/ChangeLog b/test/ChangeLog index 6e786e8e..735d6b9c 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,6 +1,15 @@ +2020-07-12 Arnold D. Robbins <arnold@skeeve.com> + + * Makefile.am (EXTRA_DIST): Remove arrdbug-mpfr.ok and + add testext-mpfr.ok. + (CHECK_MPFR): Cleaned up. + (arrdbg): Adjust the flow. + (testext): Ditto. + * arrdbg.awk: Update code. + 2020-07-08 Arnold D. Robbins <arnold@skeeve.com> - * Makefile.am (EXTRADIST): Add additional ok files for MPFR. + * Makefile.am (EXTRA_DIST): Add additional ok files for MPFR. (CHECK_MPFR): Add arraytype, arrdbg, forcenum and numrange (arrdbg): Update to check -mpfr.ok file also. * arraytype-mpfr.ok, arrdbg-mpfr.ok, forcenum-mpfr.ok, numrange-mpfr.ok: New files. diff --git a/test/Makefile.am b/test/Makefile.am index 6d953533..94f6775b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -81,7 +81,6 @@ EXTRA_DIST = \ arraytype.ok \ arraytype-mpfr.ok \ arrdbg.awk \ - arrdbg-mpfr.ok \ arrymem1.awk \ arrymem1.ok \ arryref2.awk \ @@ -1263,6 +1262,7 @@ EXTRA_DIST = \ tailrecurse.awk \ tailrecurse.ok \ testext.ok \ + testext-mpfr.ok \ time.awk \ time.ok \ timeout.awk \ @@ -1509,7 +1509,7 @@ FAIL_CODE1 = \ # List of files which have .ok versions for MPFR CHECK_MPFR = \ - arraytype arrdbg fnarydel fnparydl forcenum numrange rand + arraytype fnarydel fnparydl forcenum numrange rand # Lists of tests that need particular locales NEED_LOCALE_C = \ @@ -2250,7 +2250,9 @@ testext:: @echo $@ @$(AWK) ' /^(@load|BEGIN)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk @$(AWK) -f ./testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ - @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk testexttmp.txt + @-if test -z "$$AWKFLAGS" ; then $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk testexttmp.txt; else \ + $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ testext.awk testexttmp.txt ; \ + fi getfile: @echo $@ @@ -2387,9 +2389,9 @@ ignrcas3:: arrdbg: @echo $@ - @$(AWK) -v "okfile=./$@.ok" -f "$(srcdir)"/$@.awk | grep array_f >_$@ || echo EXIT CODE: $$? >> _$@ - @-if test -z "$$AWKFLAGS" ; then $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ; else \ - $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ ; \ + @$(AWK) -v "okfile=./$@.ok" -v "mpfr_okfile=./$@-mpfr.ok" -f "$(srcdir)"/$@.awk | grep array_f >_$@ || echo EXIT CODE: $$? >> _$@ + @-if test -z "$$AWKFLAGS" ; then $(CMP) ./$@.ok _$@ && rm -f _$@ ./$@.ok ./$@-mpfr.ok ; else \ + $(CMP) ./$@-mpfr.ok _$@ && rm -f _$@ ./$@.ok ./$@-mpfr.ok ; \ fi diff --git a/test/Makefile.in b/test/Makefile.in index 5a6215db..3781bb25 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -344,7 +344,6 @@ EXTRA_DIST = \ arraytype.ok \ arraytype-mpfr.ok \ arrdbg.awk \ - arrdbg-mpfr.ok \ arrymem1.awk \ arrymem1.ok \ arryref2.awk \ @@ -1526,6 +1525,7 @@ EXTRA_DIST = \ tailrecurse.awk \ tailrecurse.ok \ testext.ok \ + testext-mpfr.ok \ time.awk \ time.ok \ timeout.awk \ @@ -1773,7 +1773,7 @@ FAIL_CODE1 = \ # List of files which have .ok versions for MPFR CHECK_MPFR = \ - arraytype arrdbg fnarydel fnparydl forcenum numrange rand + arraytype fnarydel fnparydl forcenum numrange rand # Lists of tests that need particular locales @@ -2703,7 +2703,9 @@ testext:: @echo $@ @$(AWK) ' /^(@load|BEGIN)/,/^}/' "$(top_srcdir)"/extension/testext.c > testext.awk @$(AWK) -f ./testext.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ - @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk testexttmp.txt + @-if test -z "$$AWKFLAGS" ; then $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ testext.awk testexttmp.txt; else \ + $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ testext.awk testexttmp.txt ; \ + fi getfile: @echo $@ @@ -2838,7 +2840,7 @@ ignrcas3:: arrdbg: @echo $@ - @$(AWK) -v "okfile=./$@.ok" -f "$(srcdir)"/$@.awk | grep array_f >_$@ || echo EXIT CODE: $$? >> _$@ + @$(AWK) -v "okfile=./$@.ok" -v "mpfr_okfile=./$@-mpfr.ok" -f "$(srcdir)"/$@.awk | grep array_f >_$@ || echo EXIT CODE: $$? >> _$@ @-if test -z "$$AWKFLAGS" ; then $(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ; else \ $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ ; \ fi diff --git a/test/arrdbg-mpfr.ok b/test/arrdbg-mpfr.ok deleted file mode 100644 index 010801cb..00000000 --- a/test/arrdbg-mpfr.ok +++ /dev/null @@ -1,12 +0,0 @@ -array_f subscript [3] - array_func: str_array_func -array_f subscript [-3] - array_func: str_array_func -array_f subscript [3.0] - array_func: str_array_func -array_f subscript [ 3] - array_func: str_array_func -array_f subscript [0] - array_func: str_array_func -array_f subscript [-1] - array_func: str_array_func diff --git a/test/arrdbg.awk b/test/arrdbg.awk index 951acb41..1943a46f 100644 --- a/test/arrdbg.awk +++ b/test/arrdbg.awk @@ -1,17 +1,19 @@ -function check(x, exptype, f) { +function check(x, exptype, mpfr_exptype, f) { f[x] printf "array_f subscript [%s]\n", x printf "array_f subscript [%s]\n", x > okfile + printf "array_f subscript [%s]\n", x > mpfr_okfile adump(f, -1) printf " array_func: %s_array_func\n", exptype > okfile + printf " array_func: %s_array_func\n", mpfr_exptype > mpfr_okfile } BEGIN { - check(3.0, "cint") - check(-3, "int") - check("3.0", "str") + check(3.0, "cint", "str") + check(-3, "int", "str") + check("3.0", "str", "str") split(" 3", f, "|") # create a maybe_num value - check(f[1], "str") - check("0", "cint") - check("-1", "int") + check(f[1], "str", "str") + check("0", "cint", "str") + check("-1", "int", "str") } diff --git a/test/testext-mpfr.ok b/test/testext-mpfr.ok new file mode 100644 index 00000000..2c616c67 --- /dev/null +++ b/test/testext-mpfr.ok @@ -0,0 +1,94 @@ +pets has 5 elements +dump_array_and_delete: sym_lookup of pets passed +dump_array_and_delete: incoming size is 5 + pets["4"] = "raincloud" + pets["5"] = "lucky" + pets["1"] = "blacky" + pets["2"] = "rusty" + pets["3"] = "sophie" +dump_array_and_delete: marking element "3" for deletion +dump_array_and_delete(pets) returned 1 +dump_array_and_delete() did remove index "3"! + +try_modify_environ: sym_lookup of ENVIRON passed +try_modify_environ: set_array_element of ENVIRON failed +try_modify_environ: marking element "testext" for deletion +try_del_environ() could not delete element - pass +try_del_environ() could not add an element - pass +var_test: sym_lookup of PROCINFO passed - got a value! +var_test: sym_lookup of ARGC passed - got a value! +var_test: sym_update of ARGC failed - correctly +var_test: sym_update("testvar") succeeded +var_test() returned 1, test_var = 42 + +test_errno() returned 1, ERRNO = No child processes + +fubar = 9 +rumpus = -5 +uid matches 1 +api_major matches 1 +test_deferred returns 1 + +length of test_array is 10, should be 10 +test_array_size: incoming size is 10 +test_array_size() returned 1, length is now 0 + +test_array_elem: a["3"] = "three" +test_array_elem() returned 1, test_array2[3] = 42 +test_array_elem() did remove element "5" +test_array_elem() added element "7" --> seven +test_array2["subarray"]["hello"] = world +test_array2["subarray"]["answer"] = 42 + +test_array_param() returned 1 +isarray(a_new_array) = 1 +a_new_array["hello"] = world +a_new_array["answer"] = 42 +test_array_param: argument is not undefined (1) +test_array_param() returned 0 +isarray(a_scalar) = 0 + +Initial value of LINT is 0 +print_do_lint: lint = 0 +print_do_lint() returned 1 +Changed value of LINT is 1 +print_do_lint: lint = 1 +print_do_lint() returned 1 + +test_scalar(7) returned 1, the_scalar is 7 +test_scalar(9) returned 1, the_scalar is 9 +test_scalar(11) returned 1, the_scalar is 11 +test_scalar(1) returned 1, the_scalar is 1 +test_scalar(3) returned 1, the_scalar is 3 +test_scalar(5) returned 1, the_scalar is 5 +test_scalar(fox) returned 1, the_scalar is fox +test_scalar(jumps) returned 1, the_scalar is jumps +test_scalar(over) returned 1, the_scalar is over +test_scalar(the) returned 1, the_scalar is the +test_scalar(lazy) returned 1, the_scalar is lazy +test_scalar(dog) returned 1, the_scalar is dog +test_scalar(the) returned 1, the_scalar is the +test_scalar(quick) returned 1, the_scalar is quick +test_scalar(brown) returned 1, the_scalar is brown +test_scalar_reserved: sym_lookup of ARGC passed - got a value! +test_scalar_reserved: could not update new_value2 for ARGC - pass +test_indirect_var: sym_lookup of NR passed +test_indirect_var: value of NR is 3 +test_indirect_var() return 1 + +test_get_file returned 0 +File [.test.alias] nr [1]: line 1 +File [.test.alias] nr [2]: line 2 +File [.test.alias] nr [3]: line 3 + +answer_num = 42 +message_string = hello, world +new_array["hello"] = "world" +new_array["answer"] = "42" + +test::testval = in namespace test +test::test_function() called. + +at_exit2 called (should be first): data = NULL, exit_status = 0 +at_exit1 called (should be second): (data is & data_for_1), data value = 0xdeadbeef, exit_status = 0 +at_exit0 called (should be third): data = NULL, exit_status = 0 |