aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-05-10 23:46:00 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-05-10 23:46:00 +0300
commit4336a9ce853edb66dbfb43bb6856d007a97191d0 (patch)
tree21f7c006ef2c97e13fc2f6beec580a42a1e2d01c /io.c
parent57dfae2cdd29002643719cfb42b42aeb50e57bfe (diff)
parent0ebae58196378b06e083109701875f15c60a7b9a (diff)
downloadegawk-4336a9ce853edb66dbfb43bb6856d007a97191d0.tar.gz
egawk-4336a9ce853edb66dbfb43bb6856d007a97191d0.tar.bz2
egawk-4336a9ce853edb66dbfb43bb6856d007a97191d0.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/io.c b/io.c
index b1c9fa18..3d7b00ab 100644
--- a/io.c
+++ b/io.c
@@ -3473,8 +3473,15 @@ get_a_record(char **out, /* pointer to pointer to data */
ret = (*matchrec)(iop, & recm, & state);
iop->flag &= ~IOP_AT_START;
+ /* found the record, we're done, break the loop */
if (ret == REC_OK)
break;
+
+ /*
+ * Likely found the record; if there's no more data
+ * to be had (like from a tiny regular file), break the
+ * loop. Otherwise, see if we can read more.
+ */
if (ret == TERMNEAREND && buffer_has_all_data(iop))
break;
@@ -3527,10 +3534,14 @@ get_a_record(char **out, /* pointer to pointer to data */
break;
} else if (iop->count == 0) {
/*
- * hit EOF before matching RS, so end
- * the record and set RT to ""
+ * Hit EOF before being certain that we've matched
+ * the end of the record. If ret is TERMNEAREND,
+ * we need to pull out what we've got in the buffer.
+ * Eventually we'll come back here and see the EOF,
+ * end the record and set RT to "".
*/
- iop->flag |= IOP_AT_EOF;
+ if (ret != TERMNEAREND)
+ iop->flag |= IOP_AT_EOF;
break;
} else
iop->dataend += iop->count;