[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Awk 3.1.2 reading zero length files
From: |
Aharon Robbins |
Subject: |
Re: GNU Awk 3.1.2 reading zero length files |
Date: |
Thu, 8 May 2003 19:15:44 +0300 |
Greetings. Re this:
> Date: Wed, 07 May 2003 10:45:40 +0100
> From: "Carlos J. G. Duarte" <address@hidden>
> To: address@hidden
> Subject: GNU Awk 3.1.2 reading zero length files
>
> Hi,
> It seems from gawk 3.1.1 to gawk 3.1.2 a minor optimization
> was made-- skipping zero length files.
>
> In linux, files under /proc filesystem have zero length,
> are regular files and they do have contents.
>
> .....
> I think this is not really a gawk bug. A regular file with 0 bytes
> is supposed to be empty. Just to report anyway-- there might
> be some scripts out there broking.
>
> Best regards,
>
> --
> carlos
I consider it a bug, since such files used to get processed. Here is a diff
that fixes this problem, as well as another problem that people have
encountered.
Thanks,
Arnold
---------------------------------
--- io.c.orig 2003-02-25 12:32:30.000000000 +0200
+++ io.c 2003-05-08 10:43:43.000000000 +0300
@@ -2487,11 +2487,13 @@
/* <reset pointers>=
*/
bp = iop->dataend;
+#if 0
} else {
/* <save position, grow buffer>=
*/
iop->scanoff = bp - iop->off;
grow_iop_buffer(iop);
bp = iop->off + iop->scanoff;
+#endif
}
}
@@ -2510,7 +2512,8 @@
/* <put more data into the buffer>=
*/
if ((iop->flag & IOP_IS_INTERNAL) != 0) {
iop->flag |= IOP_AT_EOF;
- } else if (S_ISREG(iop->sbuf.st_mode) && iop->total >=
iop->sbuf.st_size)
+ } else if (S_ISREG(iop->sbuf.st_mode) &&
iop->sbuf.st_size > 0
+ && iop->total >= iop->sbuf.st_size)
iop->flag |= IOP_AT_EOF;
else {
#define min(x, y) (x < y ? x : y)
@@ -2549,7 +2552,8 @@
else {
iop->dataend += iop->count;
iop->total += iop->count;
- if (S_ISREG(iop->sbuf.st_mode) &&
iop->total >= iop->sbuf.st_size)
+ if (S_ISREG(iop->sbuf.st_mode) &&
iop->sbuf.st_size > 0
+ && iop->total >= iop->sbuf.st_size)
iop->flag |= IOP_AT_EOF;
/* reset the sentinel */
/* <set sentinel>=
*/
@@ -2729,11 +2733,13 @@
/* <reset pointers>=
*/
bp = iop->dataend;
+#if 0
} else {
/* <save position, grow buffer>=
*/
iop->scanoff = bp - iop->off;
grow_iop_buffer(iop);
bp = iop->off + iop->scanoff;
+#endif
}
}
@@ -2752,7 +2758,8 @@
/* <put more data into the buffer>=
*/
if ((iop->flag & IOP_IS_INTERNAL) != 0) {
iop->flag |= IOP_AT_EOF;
- } else if (S_ISREG(iop->sbuf.st_mode) && iop->total >=
iop->sbuf.st_size)
+ } else if (S_ISREG(iop->sbuf.st_mode) &&
iop->sbuf.st_size > 0
+ && iop->total >= iop->sbuf.st_size)
iop->flag |= IOP_AT_EOF;
else {
#define min(x, y) (x < y ? x : y)
@@ -2791,7 +2798,8 @@
else {
iop->dataend += iop->count;
iop->total += iop->count;
- if (S_ISREG(iop->sbuf.st_mode) &&
iop->total >= iop->sbuf.st_size)
+ if (S_ISREG(iop->sbuf.st_mode) &&
iop->sbuf.st_size > 0
+ && iop->total >= iop->sbuf.st_size)
iop->flag |= IOP_AT_EOF;
/* reset the sentinel */
/* <set sentinel>=
*/
@@ -2993,11 +3001,13 @@
/* <reset pointers>=
*/
bp = iop->dataend;
+#if 0
} else {
/* <save position, grow buffer>=
*/
iop->scanoff = bp - iop->off;
grow_iop_buffer(iop);
bp = iop->off + iop->scanoff;
+#endif
}
}
@@ -3016,7 +3026,8 @@
/* <put more data into the buffer>=
*/
if ((iop->flag & IOP_IS_INTERNAL) != 0) {
iop->flag |= IOP_AT_EOF;
- } else if (S_ISREG(iop->sbuf.st_mode) && iop->total >=
iop->sbuf.st_size)
+ } else if (S_ISREG(iop->sbuf.st_mode) &&
iop->sbuf.st_size > 0
+ && iop->total >= iop->sbuf.st_size)
iop->flag |= IOP_AT_EOF;
else {
#define min(x, y) (x < y ? x : y)
@@ -3055,7 +3066,8 @@
else {
iop->dataend += iop->count;
iop->total += iop->count;
- if (S_ISREG(iop->sbuf.st_mode) &&
iop->total >= iop->sbuf.st_size)
+ if (S_ISREG(iop->sbuf.st_mode) &&
iop->sbuf.st_size > 0
+ && iop->total >= iop->sbuf.st_size)
iop->flag |= IOP_AT_EOF;
/* reset the sentinel */
/* <set sentinel>=
*/