aboutsummaryrefslogtreecommitdiffstats
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
parent57dfae2cdd29002643719cfb42b42aeb50e57bfe (diff)
parent0ebae58196378b06e083109701875f15c60a7b9a (diff)
downloadegawk-4336a9ce853edb66dbfb43bb6856d007a97191d0.tar.gz
egawk-4336a9ce853edb66dbfb43bb6856d007a97191d0.tar.bz2
egawk-4336a9ce853edb66dbfb43bb6856d007a97191d0.zip
Merge branch 'gawk-4.1-stable'
-rw-r--r--ChangeLog6
-rw-r--r--io.c17
-rw-r--r--test/ChangeLog5
-rw-r--r--test/Makefile.am8
-rw-r--r--test/Makefile.in8
-rw-r--r--test/rsglstdin.ok3
6 files changed, 42 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 3a32a238..b3eea53f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-05-10 Arnold D. Robbins <arnold@skeeve.com>
+
+ * io.c (get_a_record): Finish TERMNEAREND handling in case
+ we don't have a regular file but aren't going to get more data.
+ Added some additional comments.
+
2014-05-09 Arnold D. Robbins <arnold@skeeve.com>
* debug.c (do_eval): Don't free `f' which points into the context
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;
diff --git a/test/ChangeLog b/test/ChangeLog
index 878766c7..0fe4c033 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-10 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Makefile.am (rsglstdin): New test.
+ * rsglstdin.ok: New file.
+
2014-05-09 Andrew J. Schorr <aschorr@telemetry-investments.com>
* Makefile.am (rebuf): Force buffer size to 4096 via AWKBUFSIZE
diff --git a/test/Makefile.am b/test/Makefile.am
index ba6bbeec..d2c8b364 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -762,6 +762,7 @@ EXTRA_DIST = \
rsgetline.awk \
rsgetline.in \
rsgetline.ok \
+ rsglstdin.ok \
rsnul1nl.awk \
rsnul1nl.in \
rsnul1nl.ok \
@@ -1003,7 +1004,7 @@ GAWK_EXT_TESTS = \
nastyparm next nondec nondec2 \
patsplit posix printfbad1 printfbad2 printfbad3 procinfs \
profile1 profile2 profile3 profile4 profile5 pty1 \
- rebuf regx8bit reginttrad reint reint2 rsgetline rsstart1 \
+ rebuf regx8bit reginttrad reint reint2 rsgetline rsglstdin rsstart1 \
rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \
splitarg4 strftime \
strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
@@ -1337,6 +1338,11 @@ rebuf::
@AWKBUFSIZE=4096 AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+rsglstdin::
+ @echo $@
+ @cat "$(srcdir)"/rsgetline.in | AWKPATH="$(srcdir)" $(AWK) -f rsgetline.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
reint::
@echo $@
@$(AWK) --re-interval -f "$(srcdir)"/reint.awk "$(srcdir)"/reint.in >_$@
diff --git a/test/Makefile.in b/test/Makefile.in
index b192b561..00ce2b06 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1008,6 +1008,7 @@ EXTRA_DIST = \
rsgetline.awk \
rsgetline.in \
rsgetline.ok \
+ rsglstdin.ok \
rsnul1nl.awk \
rsnul1nl.in \
rsnul1nl.ok \
@@ -1248,7 +1249,7 @@ GAWK_EXT_TESTS = \
nastyparm next nondec nondec2 \
patsplit posix printfbad1 printfbad2 printfbad3 procinfs \
profile1 profile2 profile3 profile4 profile5 pty1 \
- rebuf regx8bit reginttrad reint reint2 rsgetline rsstart1 \
+ rebuf regx8bit reginttrad reint reint2 rsgetline rsglstdin rsstart1 \
rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \
splitarg4 strftime \
strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \
@@ -1762,6 +1763,11 @@ rebuf::
@AWKBUFSIZE=4096 AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+rsglstdin::
+ @echo $@
+ @cat "$(srcdir)"/rsgetline.in | AWKPATH="$(srcdir)" $(AWK) -f rsgetline.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
reint::
@echo $@
@$(AWK) --re-interval -f "$(srcdir)"/reint.awk "$(srcdir)"/reint.in >_$@
diff --git a/test/rsglstdin.ok b/test/rsglstdin.ok
new file mode 100644
index 00000000..1388369a
--- /dev/null
+++ b/test/rsglstdin.ok
@@ -0,0 +1,3 @@
+[1] [,]
+-1-
+[2] [,]