diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-05-09 11:59:29 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-05-09 11:59:29 +0300 |
commit | 40694fc1c11bae6fac8e809a6a4c161c12cc37b7 (patch) | |
tree | 0b7858a44f30c13c0fd0da1423ea965c6b9240b6 | |
parent | 12857707435f1d4bf9adf33b6fbfd57ff91529a7 (diff) | |
download | egawk-40694fc1c11bae6fac8e809a6a4c161c12cc37b7.tar.gz egawk-40694fc1c11bae6fac8e809a6a4c161c12cc37b7.tar.bz2 egawk-40694fc1c11bae6fac8e809a6a4c161c12cc37b7.zip |
Fix in read_a_record for short file with RS=regex.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | io.c | 3 | ||||
-rw-r--r-- | test/ChangeLog | 7 | ||||
-rw-r--r-- | test/Makefile.am | 10 | ||||
-rw-r--r-- | test/Makefile.in | 18 | ||||
-rw-r--r-- | test/Maketests | 8 | ||||
-rw-r--r-- | test/rsgetline.awk | 23 | ||||
-rw-r--r-- | test/rsgetline.in | 1 | ||||
-rw-r--r-- | test/rsgetline.ok | 3 |
9 files changed, 69 insertions, 10 deletions
@@ -8,6 +8,12 @@ (do_eval): Fix a memory leak seen by valgrind on Fedora 20 and Ubuntu 14.04: the new SRCFILE that is added wasn't released. + Unrelated: + + * io.c (get_a_record): Handle return of TERMNEAREND when the + entire file has been read into the buffer and we're using a + regex for RS. Bug report by Grail Dane <grail69@hotmail.com>. + 2014-05-04 Arnold D. Robbins <arnold@skeeve.com> * debug.c (debug_prog): Change check for GAWK_RESTART so that it @@ -206,6 +206,7 @@ typedef enum { CLOSE_ALL, CLOSE_TO, CLOSE_FROM } two_way_close_type; #define at_eof(iop) (((iop)->flag & IOP_AT_EOF) != 0) #define has_no_data(iop) ((iop)->dataend == NULL) #define no_data_left(iop) ((iop)->off >= (iop)->dataend) +#define buffer_has_all_data(iop) ((iop)->dataend - (iop)->off == (iop)->public.sbuf.st_size) /* * The key point to the design is to split out the code that searches through @@ -3474,6 +3475,8 @@ get_a_record(char **out, /* pointer to pointer to data */ iop->flag &= ~IOP_AT_START; if (ret == REC_OK) break; + if (ret == TERMNEAREND && buffer_has_all_data(iop)) + break; /* need to add more data to buffer */ /* shift data down in buffer */ diff --git a/test/ChangeLog b/test/ChangeLog index 7845e8ad..9af1c5bc 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,10 @@ +2014-05-09 Andrew J. Schorr <aschorr@telemetry-investments.com> + + * Makefile.am (rebuf): Force buffer size to 4096 via AWKBUFSIZE + environment variable. + (rsgetline): New test. + * rsgetline.awk, rsgetline.in, rsgetline.ok: New files. + 2014-04-11 Arnold D. Robbins <arnold@skeeve.com> * Makefile.am (charset-msg-start): Add a warning message that tests diff --git a/test/Makefile.am b/test/Makefile.am index 32d6bd7b..856532cd 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -757,6 +757,9 @@ EXTRA_DIST = \ rs.awk \ rs.in \ rs.ok \ + rsgetline.awk \ + rsgetline.in \ + rsgetline.ok \ rsnul1nl.awk \ rsnul1nl.in \ rsnul1nl.ok \ @@ -998,7 +1001,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 rsstart1 \ + rebuf regx8bit reginttrad reint reint2 rsgetline rsstart1 \ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ @@ -1327,6 +1330,11 @@ fmtspcl: fmtspcl.ok $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ ; \ fi +rebuf:: + @echo $@ + @AWKBUFSIZE=4096 AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 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 267fea75..1dbc3359 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1003,6 +1003,9 @@ EXTRA_DIST = \ rs.awk \ rs.in \ rs.ok \ + rsgetline.awk \ + rsgetline.in \ + rsgetline.ok \ rsnul1nl.awk \ rsnul1nl.in \ rsnul1nl.ok \ @@ -1243,7 +1246,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 rsstart1 \ + rebuf regx8bit reginttrad reint reint2 rsgetline rsstart1 \ rsstart2 rsstart3 rstest6 shadow sortfor sortu split_after_fpat \ splitarg4 strftime \ strtonum switch2 symtab1 symtab2 symtab3 symtab4 symtab5 symtab6 \ @@ -1752,6 +1755,11 @@ fmtspcl: fmtspcl.ok $(CMP) "$(srcdir)"/$@-mpfr.ok _$@ && rm -f _$@ ; \ fi +rebuf:: + @echo $@ + @AWKBUFSIZE=4096 AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ + reint:: @echo $@ @$(AWK) --re-interval -f "$(srcdir)"/reint.awk "$(srcdir)"/reint.in >_$@ @@ -3491,14 +3499,14 @@ pty1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ -rebuf: +regx8bit: @echo $@ - @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ -regx8bit: +rsgetline: @echo $@ - @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ rstest6: diff --git a/test/Maketests b/test/Maketests index b9b713c4..e847d765 100644 --- a/test/Maketests +++ b/test/Maketests @@ -1152,14 +1152,14 @@ pty1: @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ -rebuf: +regx8bit: @echo $@ - @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ -regx8bit: +rsgetline: @echo $@ - @AWKPATH="$(srcdir)" $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @AWKPATH="$(srcdir)" $(AWK) -f $@.awk < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@ rstest6: diff --git a/test/rsgetline.awk b/test/rsgetline.awk new file mode 100644 index 00000000..fa327fcf --- /dev/null +++ b/test/rsgetline.awk @@ -0,0 +1,23 @@ +# Date: Sun, 4 May 2014 18:09:01 +0200 +# From: Davide Brini <dave_br@gmx.com> +# To: bug-gawk@gnu.org +# Subject: Re: [bug-gawk] Computed regex and getline bug / issue +# +# I have been able to reduce the behavior to these simple test cases, which +# (unless I'm missing something obvious) should behave identically but don't: +# +# $ printf '1,2,' | gawk 'BEGIN{RS="[,]+"}{print; a = getline; print "-"a"-"; print}' +# 1 +# -0- +# 1 + +BEGIN { + RS = "[,]+" +} + +{ + printf "[%s] [%s]\n", $0, RT + a = getline + print "-"a"-" + printf "[%s] [%s]\n", $0, RT +} diff --git a/test/rsgetline.in b/test/rsgetline.in new file mode 100644 index 00000000..f1782346 --- /dev/null +++ b/test/rsgetline.in @@ -0,0 +1 @@ +1,2,
\ No newline at end of file diff --git a/test/rsgetline.ok b/test/rsgetline.ok new file mode 100644 index 00000000..1388369a --- /dev/null +++ b/test/rsgetline.ok @@ -0,0 +1,3 @@ +[1] [,] +-1- +[2] [,] |