diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | io.c | 17 | ||||
-rw-r--r-- | test/ChangeLog | 5 | ||||
-rw-r--r-- | test/Makefile.am | 8 | ||||
-rw-r--r-- | test/Makefile.in | 8 | ||||
-rw-r--r-- | test/rsglstdin.ok | 3 |
6 files changed, 42 insertions, 5 deletions
@@ -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 @@ -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 9af1c5bc..095fe155 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 856532cd..260b216a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -760,6 +760,7 @@ EXTRA_DIST = \ rsgetline.awk \ rsgetline.in \ rsgetline.ok \ + rsglstdin.ok \ rsnul1nl.awk \ rsnul1nl.in \ rsnul1nl.ok \ @@ -1001,7 +1002,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 \ @@ -1335,6 +1336,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 1dbc3359..34d5c594 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1006,6 +1006,7 @@ EXTRA_DIST = \ rsgetline.awk \ rsgetline.in \ rsgetline.ok \ + rsglstdin.ok \ rsnul1nl.awk \ rsnul1nl.in \ rsnul1nl.ok \ @@ -1246,7 +1247,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 \ @@ -1760,6 +1761,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] [,] |