aboutsummaryrefslogtreecommitdiffstats
path: root/interpret.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2020-08-25 09:59:49 +0300
committerArnold D. Robbins <arnold@skeeve.com>2020-08-25 09:59:49 +0300
commitab992f649d6e8b40f86eb0f31f4b04daf12c0c8d (patch)
treee7e93fae9390290d012404237905fb48c2c2d31f /interpret.h
parent0dcd39b002cff7785c38ce535f6e57d4208fefa6 (diff)
downloadegawk-ab992f649d6e8b40f86eb0f31f4b04daf12c0c8d.tar.gz
egawk-ab992f649d6e8b40f86eb0f31f4b04daf12c0c8d.tar.bz2
egawk-ab992f649d6e8b40f86eb0f31f4b04daf12c0c8d.zip
Clear out the record and fields at start of BEGINFILE rule.
Diffstat (limited to 'interpret.h')
-rw-r--r--interpret.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/interpret.h b/interpret.h
index efbf9b23..fedf5255 100644
--- a/interpret.h
+++ b/interpret.h
@@ -108,7 +108,13 @@ top:
switch (op) {
case Op_rule:
- currule = pc->in_rule; /* for sole use in Op_K_next, Op_K_nextfile, Op_K_getline */
+ currule = pc->in_rule; /* for use in Op_K_next, Op_K_nextfile, Op_K_getline */
+ // 8/2020: See node BEGINFILE/ENDFILE in the manual. We clear the record
+ // since conceptually we are before reading a new record from the
+ // upcoming file but haven't read it yet.
+ if (currule == BEGINFILE)
+ set_record("", 0, NULL);
+
/* fall through */
case Op_func:
source = pc->source_file;