[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Computed regex and getline bug / issue
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] Computed regex and getline bug / issue |
Date: |
Fri, 9 May 2014 09:36:40 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hi Arnold,
On Fri, May 09, 2014 at 11:54:36AM +0300, Aharon Robbins wrote:
> Thanks everyone for their help cutting the test case down, and to Andy for
> setting up some test cases to drop into the test suite. The fix is below.
> I will push it into the repo shortly.
I'm afraid my test cases were not comprehensive.
> diff --git a/io.c b/io.c
> index 2bb8f28..dab1c07 100644
> --- a/io.c
> +++ b/io.c
> @@ -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 */
>
The logic here depends on having access to the st_size. When reading data
from stdin, this doesn't seem to work. We need another test case that
reads from stdin instead of from a file. After rebuilding with your patch,
I see this:
bash-4.2$ ./gawk -f test/rsgetline.awk < test/rsgetline.in
[1] [,]
-1-
[2] [,]
bash-4.2$ cat test/rsgetline.in
1,2,bash-4.2$
bash-4.2$ printf '1,2,' | ./gawk -f test/rsgetline.awk
[1] [,]
-0-
[1] [,]
bash-4.2$
So the fix works when reading from a regular file, but apparently not
from stdin.
Regards,
Andy
- [bug-gawk] Computed regex and getline bug / issue, Grail Dane, 2014/05/04
- Re: [bug-gawk] Computed regex and getline bug / issue, Davide Brini, 2014/05/04
- Re: [bug-gawk] Computed regex and getline bug / issue, Andrew J. Schorr, 2014/05/04
- Re: [bug-gawk] Computed regex and getline bug / issue, Aharon Robbins, 2014/05/09
- Re: [bug-gawk] Computed regex and getline bug / issue,
Andrew J. Schorr <=
- Re: [bug-gawk] Computed regex and getline bug / issue, Aharon Robbins, 2014/05/10
- Re: [bug-gawk] Computed regex and getline bug / issue, Andrew J. Schorr, 2014/05/11
- Re: [bug-gawk] Computed regex and getline bug / issue, arnold, 2014/05/11