gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, master, updated. gawk-4.1.0-4864-g4be234bc


From: Arnold Robbins
Subject: [SCM] gawk branch, master, updated. gawk-4.1.0-4864-g4be234bc
Date: Sun, 14 Aug 2022 11:15:10 -0400 (EDT)

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, master has been updated
       via  4be234bc1435b927ea19b07ac888564b383291e7 (commit)
      from  877acc226db6d694ba6407a3ff797ffc92379a81 (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=4be234bc1435b927ea19b07ac888564b383291e7

commit 4be234bc1435b927ea19b07ac888564b383291e7
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Sun Aug 14 18:14:35 2022 +0300

    Improve parse-time checking for divide by zero, add test case.

diff --git a/ChangeLog b/ChangeLog
index dec5fe56..26f4fcb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-08-14         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * awkgram.y (mk_binary): Check for division by constant zero in
+       `/' and `%' when numerator is not a constant. Thanks to Ed Morton
+       <mortoneccc@comcast.net> for the report.
+
 2022-08-12         Arnold D. Robbins     <arnold@skeeve.com>
 
        * NEWS: Small update: mention pm-gawk.1 man page.
diff --git a/awkgram.c b/awkgram.c
index b948a83a..ed10b5c7 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -8041,9 +8041,21 @@ mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION 
*op)
                                op->opcode = Op_times_i;
                                break;
                        case Op_quotient:
+                               if (ip2->memory->numbr == 0.0) {
+                                       /* don't fatalize, allow parsing rest 
of the input */
+                                       error_ln(op->source_line, _("division 
by zero attempted"));
+                                       goto regular;
+                               }
+
                                op->opcode = Op_quotient_i;
                                break;
                        case Op_mod:
+                               if (ip2->memory->numbr == 0.0) {
+                                       /* don't fatalize, allow parsing rest 
of the input */
+                                       error_ln(op->source_line, _("division 
by zero attempted in `%%'"));
+                                       goto regular;
+                               }
+
                                op->opcode = Op_mod_i;
                                break;
                        case Op_plus:
diff --git a/awkgram.y b/awkgram.y
index 36cac704..e2a3d21b 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -5533,9 +5533,21 @@ mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION 
*op)
                                op->opcode = Op_times_i;
                                break;
                        case Op_quotient:
+                               if (ip2->memory->numbr == 0.0) {
+                                       /* don't fatalize, allow parsing rest 
of the input */
+                                       error_ln(op->source_line, _("division 
by zero attempted"));
+                                       goto regular;
+                               }
+
                                op->opcode = Op_quotient_i;
                                break;
                        case Op_mod:
+                               if (ip2->memory->numbr == 0.0) {
+                                       /* don't fatalize, allow parsing rest 
of the input */
+                                       error_ln(op->source_line, _("division 
by zero attempted in `%%'"));
+                                       goto regular;
+                               }
+
                                op->opcode = Op_mod_i;
                                break;
                        case Op_plus:
diff --git a/pc/ChangeLog b/pc/ChangeLog
index a135c4c9..753eb4e2 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2022-08-14         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.tst: Regenerated.
+
 2022-08-08         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.tst.prologue (SORT2): New variable.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 9c59aba4..5641486f 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -150,7 +150,7 @@ BASIC_TESTS = \
        back89 backgsub badassign1 badbuild callparam childin clobber \
        closebad close_status clsflnam compare compare2 concat1 concat2 \
        concat3 concat4 concat5 convfmt datanonl defref delargv delarpm2 \
-       delarprm delfunc dfacheck2 dfamb1 dfastress dynlj eofsplit \
+       delarprm delfunc dfacheck2 dfamb1 dfastress divzero dynlj eofsplit \
        eofsrc1 escapebrace exit2 exitval1 exitval2 exitval3 fcall_exit \
        fcall_exit2 fldchg fldchgnf fldterm fnamedat fnarray fnarray2 \
        fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \
@@ -1573,6 +1573,11 @@ dfastress:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+divzero:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 dynlj:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/ChangeLog b/test/ChangeLog
index 626da0ee..90d3dd73 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2022-08-14         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.am (EXTRA_DIST): divzero: new test.
+       * divzero.awk, divzero.ok: New files.
+
 2022-08-08         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.am (EXPECTED_FAIL_MINGW): Remove nsidentifier from the
diff --git a/test/Makefile.am b/test/Makefile.am
index acd3632a..fcc8002b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -271,6 +271,8 @@ EXTRA_DIST = \
        dfamb1.ok \
        dfastress.awk \
        dfastress.ok \
+       divzero.awk \
+       divzero.ok \
        double1.awk \
        double1.ok \
        double2.awk \
@@ -1434,7 +1436,7 @@ BASIC_TESTS = \
        back89 backgsub badassign1 badbuild callparam childin clobber \
        closebad close_status clsflnam compare compare2 concat1 concat2 \
        concat3 concat4 concat5 convfmt datanonl defref delargv delarpm2 \
-       delarprm delfunc dfacheck2 dfamb1 dfastress dynlj eofsplit \
+       delarprm delfunc dfacheck2 dfamb1 dfastress divzero dynlj eofsplit \
        eofsrc1 escapebrace exit2 exitval1 exitval2 exitval3 fcall_exit \
        fcall_exit2 fldchg fldchgnf fldterm fnamedat fnarray fnarray2 \
        fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 78eb0e7b..c8edbb43 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -538,6 +538,8 @@ EXTRA_DIST = \
        dfamb1.ok \
        dfastress.awk \
        dfastress.ok \
+       divzero.awk \
+       divzero.ok \
        double1.awk \
        double1.ok \
        double2.awk \
@@ -1701,7 +1703,7 @@ BASIC_TESTS = \
        back89 backgsub badassign1 badbuild callparam childin clobber \
        closebad close_status clsflnam compare compare2 concat1 concat2 \
        concat3 concat4 concat5 convfmt datanonl defref delargv delarpm2 \
-       delarprm delfunc dfacheck2 dfamb1 dfastress dynlj eofsplit \
+       delarprm delfunc dfacheck2 dfamb1 dfastress divzero dynlj eofsplit \
        eofsrc1 escapebrace exit2 exitval1 exitval2 exitval3 fcall_exit \
        fcall_exit2 fldchg fldchgnf fldterm fnamedat fnarray fnarray2 \
        fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fscaret fsnul1 \
@@ -3313,6 +3315,11 @@ dfastress:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+divzero:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 dynlj:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 1bee55b4..c2854288 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -277,6 +277,11 @@ dfastress:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+divzero:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 dynlj:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/divzero.awk b/test/divzero.awk
new file mode 100644
index 00000000..3d9617a9
--- /dev/null
+++ b/test/divzero.awk
@@ -0,0 +1 @@
+BEGIN { print (0 && ((4)/0)) }
diff --git a/test/divzero.ok b/test/divzero.ok
new file mode 100644
index 00000000..b9f8715d
--- /dev/null
+++ b/test/divzero.ok
@@ -0,0 +1,2 @@
+gawk: divzero.awk:1: error: division by zero attempted
+EXIT CODE: 1

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

Summary of changes:
 ChangeLog        |  6 ++++++
 awkgram.c        | 12 ++++++++++++
 awkgram.y        | 12 ++++++++++++
 pc/ChangeLog     |  4 ++++
 pc/Makefile.tst  |  7 ++++++-
 test/ChangeLog   |  5 +++++
 test/Makefile.am |  4 +++-
 test/Makefile.in |  9 ++++++++-
 test/Maketests   |  5 +++++
 test/divzero.awk |  1 +
 test/divzero.ok  |  2 ++
 11 files changed, 64 insertions(+), 3 deletions(-)
 create mode 100644 test/divzero.awk
 create mode 100644 test/divzero.ok


hooks/post-receive
-- 
gawk



reply via email to

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