From 3f5b8e508f0fcaba4447ed98193e2ea3b8560ad9 Mon Sep 17 00:00:00 2001 From: Juan Manuel Guerrero Date: Sun, 12 Nov 2017 06:54:50 +0200 Subject: Exclude DJGPP from the sigpipe1 test. --- pc/ChangeLog | 4 ++++ pc/Makefile.tst | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pc/ChangeLog b/pc/ChangeLog index bc1e3a3e..51a71d95 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,7 @@ +2017-11-11 Juan Manuel Guerrero + + * pc/Makefile.tst (sigpipe1): Exclude DJGPP from the sigpipe1 test. + 2017-11-03 Juan Manuel Guerrero * Makefile (install1): Copy gawk.exe to awk.exe before copying diff --git a/pc/Makefile.tst b/pc/Makefile.tst index 9c3ec144..3bbfcd7e 100644 --- a/pc/Makefile.tst +++ b/pc/Makefile.tst @@ -2294,10 +2294,12 @@ sclifin: @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ sigpipe1: - @echo $@ - @echo Expect sigpipe1 to fail with DJGPP. - @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ - @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + @case `uname` in \ + *MS-DOS*) echo This test fails on DJGPP --- skipping $@ ;; \ + *) \ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ ; \ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ ; \ + esac sortempty: @echo $@ -- cgit v1.2.3 From fe60f215f0dc446e39d69d4663cbb8c5ef406535 Mon Sep 17 00:00:00 2001 From: Juan Manuel Guerrero Date: Tue, 14 Nov 2017 19:07:12 +0200 Subject: Support building with MPFR in the DJGPP port. --- README_d/ChangeLog | 4 ++++ README_d/README.mpfr | 18 ++++++++++++++++++ pc/ChangeLog | 6 ++++++ pc/Makefile | 8 ++++++++ 4 files changed, 36 insertions(+) diff --git a/README_d/ChangeLog b/README_d/ChangeLog index 2b88d423..0bc75144 100644 --- a/README_d/ChangeLog +++ b/README_d/ChangeLog @@ -1,3 +1,7 @@ +2017-11-13 Juan Manuel Guerrero + + * README.mpfr: Add info that DJGPP port compiles with MPFR support. + 2017-10-21 Arnold D. Robbins * README.os2: Updated with email from Andreas. diff --git a/README_d/README.mpfr b/README_d/README.mpfr index 892a22a1..ea787b6b 100644 --- a/README_d/README.mpfr +++ b/README_d/README.mpfr @@ -1,3 +1,21 @@ +2017-11-13 +========== +The DJGPP port of Gawk has been compiled and tested using the +following combinations of MPFR and GMP versions on FreeDOS and +other versions of the DOS operating system: +GNU MPFR 3.1.6, GNU MP 6.1.2 + +Precompiled binaries of GMP and MPFR for DJGPP are available +from DJ Delorie's ftp server and mirrors: + + http://www.delorie.com/pub/djgpp/current/v2gnu/gmp612b.zip + http://www.delorie.com/pub/djgpp/current/v2gnu/mpfr316b.zip + +No previous versions of these libraries are supported. +Newer versions should work. + +---- + Sat Mar 17 07:32:01 CDT 2012 ============================= diff --git a/pc/ChangeLog b/pc/ChangeLog index 51a71d95..155c9dc2 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-13 Juan Manuel Guerrero + + * Makefile (default): Add a line for the djgpp-mpfr target. + (djgpp-mpfr): New target, passes -DHAVE_MPFR to the + compiler and adds -lmpfr -lgmp to the linker command line. + 2017-11-11 Juan Manuel Guerrero * pc/Makefile.tst (sigpipe1): Exclude DJGPP from the sigpipe1 test. diff --git a/pc/Makefile b/pc/Makefile index bdec371c..8b53cdaa 100644 --- a/pc/Makefile +++ b/pc/Makefile @@ -21,6 +21,8 @@ default: @echo "Enter $(MAK) target " @echo " where 'target' is chosen from " @echo " djgpp ... DOS 32-bit exe [GNU C, Delorie, v2] " + @echo " djgpp-mpfr . Like djgpp, but with MPFR " + @echo " [You will need to have GNU MPFR library installed.] " @echo " emx ..... OS/2 32-bit exe [emx/gcc; uses emxlibc.dll] " @echo " emxnt ... NT exe [emx/gcc with RSXNT] " @echo " emxbnd .. OS/2 and DOS 32-bit exe [emx/gcc] " @@ -125,6 +127,12 @@ djgpp-debug: LNK=LDJG LF2=-lm \ BIND=BDJG +djgpp-mpfr: + $(MAK) all \ + CC=gcc O=.o CF='-O2 -DHAVE_MPFR' \ + LNK=LDJG LF=-s LF2="-lmpfr -lgmp -lm" \ + BIND=BDJG + #======================================================================== #========================== EMX ========================================= #======================================================================== -- cgit v1.2.3 From 064d78b562c9670751c48673c6d1d171aff51a42 Mon Sep 17 00:00:00 2001 From: "Andrew J. Schorr" Date: Tue, 14 Nov 2017 14:28:48 -0500 Subject: Fix field corruption when $0 is reassigned with open $n references. --- ChangeLog | 12 ++++++++++++ field.c | 16 +++++++++++----- interpret.h | 9 +++++++-- test/ChangeLog | 7 +++++++ test/Makefile.am | 8 +++++++- test/Makefile.in | 18 +++++++++++++++++- test/Maketests | 10 ++++++++++ test/setrec0.awk | 8 ++++++++ test/setrec0.in | 1 + test/setrec0.ok | 1 + test/setrec1.awk | 9 +++++++++ test/setrec1.ok | 1 + 12 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 test/setrec0.awk create mode 100644 test/setrec0.in create mode 100644 test/setrec0.ok create mode 100644 test/setrec1.awk create mode 100644 test/setrec1.ok diff --git a/ChangeLog b/ChangeLog index a3e53e92..27adc355 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2017-11-14 Andrew J. Schorr + + Fix corruption when $0 is reassigned while other NODEs have open + references to $n. Thanks to Eric Pruitt for + the bug report. + * field.c (purge_record): For each $n field variable, if valref > 1 + and it has not already been malloced, make a copy of the string, since + $0 is about to be reset. + * interpret.h (Op_store_field): We must call the assign function + before unref, since we must copy any non-malloced $n string values + before freeing $0. + 2017-11-09 Arnold D. Robbins * main.c (usage): Add a note to not post bugs in comp.lang.awk. diff --git a/field.c b/field.c index 5ab718d4..5263cc61 100644 --- a/field.c +++ b/field.c @@ -341,14 +341,20 @@ static void purge_record() { int i; - NODE *n; NF = -1; for (i = 1; i <= parse_high_water; i++) { - assert((fields_arr[i]->flags & MALLOC) == 0 - ? fields_arr[i]->valref == 1 - : true); - unref(fields_arr[i]); + NODE *n; + NODE *r = fields_arr[i]; + if ((r->flags & MALLOC) == 0 && r->valref > 1) { + /* This can and does happen. We must copy the string! */ + const char *save = r->stptr; + emalloc(r->stptr, char *, r->stlen + 1, "purge_record"); + memcpy(r->stptr, save, r->stlen); + r->stptr[r->stlen] = '\0'; + r->flags |= MALLOC; + } + unref(r); getnode(n); *n = *Null_field; fields_arr[i] = n; diff --git a/interpret.h b/interpret.h index 166a11e1..4b140c28 100644 --- a/interpret.h +++ b/interpret.h @@ -699,11 +699,16 @@ mod: lhs = r_get_field(t1, & assign, false); decr_sp(); DEREF(t1); + /* + * N.B. We must call assign() before unref, since + * we may need to copy $n values before freeing the + * $0 buffer. + */ + assert(assign != NULL); + assign(); unref(*lhs); r = POP_SCALAR(); UNFIELD(*lhs, r); - assert(assign != NULL); - assign(); } break; diff --git a/test/ChangeLog b/test/ChangeLog index 4586d02e..1e1cf7ea 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,10 @@ +2017-11-14 Andrew J. Schorr + + * Makefile.am (EXTRA_DIST): Add new tests setrec0 and setrec1. + (BASIC_TESTS): Add setrec0 and setrec1. + * setrec0.awk, setrec0.in, setrec0.ok: New files. + * setrec1.awk, setrec1.ok: New files. + 2017-11-10 Arnold D. Robbins * badargs.ok: Updated after code change. diff --git a/test/Makefile.am b/test/Makefile.am index cb17f9d6..1438e083 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1003,6 +1003,11 @@ EXTRA_DIST = \ sclforin.ok \ sclifin.awk \ sclifin.ok \ + setrec0.awk \ + setrec0.in \ + setrec0.ok \ + setrec1.awk \ + setrec1.ok \ shadow.awk \ shadow.ok \ shadowbuiltin.awk \ @@ -1229,7 +1234,8 @@ BASIC_TESTS = \ regexpbrack regexpbrack2 regexprange regrange reindops reparse resplit \ rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 rstest3 \ rstest4 rstest5 rswhite \ - scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr \ + scalar sclforin sclifin setrec0 setrec1 \ + sigpipe1 sortempty sortglos splitargv splitarr \ splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \ subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \ tradanch tweakfld \ diff --git a/test/Makefile.in b/test/Makefile.in index 091927c5..5a190d7a 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1261,6 +1261,11 @@ EXTRA_DIST = \ sclforin.ok \ sclifin.awk \ sclifin.ok \ + setrec0.awk \ + setrec0.in \ + setrec0.ok \ + setrec1.awk \ + setrec1.ok \ shadow.awk \ shadow.ok \ shadowbuiltin.awk \ @@ -1486,7 +1491,8 @@ BASIC_TESTS = \ regexpbrack regexpbrack2 regexprange regrange reindops reparse resplit \ rri1 rs rscompat rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 rstest3 \ rstest4 rstest5 rswhite \ - scalar sclforin sclifin sigpipe1 sortempty sortglos splitargv splitarr \ + scalar sclforin sclifin setrec0 setrec1 \ + sigpipe1 sortempty sortglos splitargv splitarr \ splitdef splitvar splitwht status-close strcat1 strnum1 strnum2 strtod \ subamp subback subi18n subsepnm subslash substr swaplns synerr1 synerr2 \ tradanch tweakfld \ @@ -3755,6 +3761,16 @@ sclifin: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +setrec0: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +setrec1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + sigpipe1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/Maketests b/test/Maketests index 8ae3f973..f64b8640 100644 --- a/test/Maketests +++ b/test/Maketests @@ -887,6 +887,16 @@ sclifin: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ +setrec0: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + +setrec1: + @echo $@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + sigpipe1: @echo $@ @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ diff --git a/test/setrec0.awk b/test/setrec0.awk new file mode 100644 index 00000000..8d978aa7 --- /dev/null +++ b/test/setrec0.awk @@ -0,0 +1,8 @@ +function reassign(x, y) { + $0 = x + print y +} + +{ + reassign("larry", $1) +} diff --git a/test/setrec0.in b/test/setrec0.in new file mode 100644 index 00000000..ce013625 --- /dev/null +++ b/test/setrec0.in @@ -0,0 +1 @@ +hello diff --git a/test/setrec0.ok b/test/setrec0.ok new file mode 100644 index 00000000..ce013625 --- /dev/null +++ b/test/setrec0.ok @@ -0,0 +1 @@ +hello diff --git a/test/setrec1.awk b/test/setrec1.awk new file mode 100644 index 00000000..3da1aa10 --- /dev/null +++ b/test/setrec1.awk @@ -0,0 +1,9 @@ +function reassign(x, y) { + $0 = x + print y +} + +BEGIN { + $0 = substr("geronimo", 5, 3) + reassign(" 52", $1) +} diff --git a/test/setrec1.ok b/test/setrec1.ok new file mode 100644 index 00000000..6bb3f869 --- /dev/null +++ b/test/setrec1.ok @@ -0,0 +1 @@ +nim -- cgit v1.2.3 From b4b1162e427f634567e09bda421f947c3c8db9ce Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Wed, 15 Nov 2017 22:01:23 +0200 Subject: Small fix in ChangeLog. Update README.mpfr. --- ChangeLog | 1 + README_d/ChangeLog | 5 +++++ README_d/README.mpfr | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27adc355..ae0630ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ Fix corruption when $0 is reassigned while other NODEs have open references to $n. Thanks to Eric Pruitt for the bug report. + * field.c (purge_record): For each $n field variable, if valref > 1 and it has not already been malloced, make a copy of the string, since $0 is about to be reset. diff --git a/README_d/ChangeLog b/README_d/ChangeLog index 0bc75144..534f409b 100644 --- a/README_d/ChangeLog +++ b/README_d/ChangeLog @@ -1,3 +1,8 @@ +2017-11-15 Arnold D. Robbins + + * README.mpfr: Make separate sections for different ports and + update some of the info. + 2017-11-13 Juan Manuel Guerrero * README.mpfr: Add info that DJGPP port compiles with MPFR support. diff --git a/README_d/README.mpfr b/README_d/README.mpfr index ea787b6b..e16828d0 100644 --- a/README_d/README.mpfr +++ b/README_d/README.mpfr @@ -1,3 +1,5 @@ +-------------------------- DJGPP ----------------------------------- + 2017-11-13 ========== The DJGPP port of Gawk has been compiled and tested using the @@ -14,7 +16,7 @@ from DJ Delorie's ftp server and mirrors: No previous versions of these libraries are supported. Newer versions should work. ----- +------------------------- Mac OS X on PPC ------------------------------- Sat Mar 17 07:32:01 CDT 2012 ============================= @@ -22,7 +24,15 @@ Sat Mar 17 07:32:01 CDT 2012 The MPFR and GMP versions known to work for Mac OS X on PPC: GNU MPFR 3.1.0, GNU MP 4.3.1 ----- +Wed Nov 15 21:57:29 IST 2017 +============================ + +As of gawk 4.2, MPFR is no longer supported on Mac OS X on PPC. +Gawk switched to C99, and the last PPC version doesn't play well +with C99. + +------------------------ Windows MinGW ---------------------------- + Precompiled binaries for GMP and MPFR in Windows may be available from here: @@ -36,8 +46,10 @@ or here: You should try to use libraries downloaded from the same site to avoid possible incompatibilities. ----- +------------------------- GNU/Linux -------------------------------- + Gawk has been compiled and tested using the following combinations of MPFR and GMP versions on GNU/Linux: GNU MPFR 2.4.2, GNU MP 4.3.2 GNU MPFR 3.1.0, GNU MP 5.0.2, 5.0.3 +GNU MPFR 3.1.4, GNU MP 6.1.0 -- cgit v1.2.3