summaryrefslogtreecommitdiff
path: root/gen.c
diff options
context:
space:
mode:
authorWill Estes <wlestes@users.sourceforge.net>2002-02-06 23:30:29 +0000
committerWill Estes <wlestes@users.sourceforge.net>2002-02-06 23:30:29 +0000
commit52fcba2f0b95c7175d88620f7978407fd623a745 (patch)
tree4599abc82751d5574ee438edfae265cfdfe390a7 /gen.c
parent27598b73c0a62a2132e71c7a61d61acb6619390e (diff)
fix interrupted reads and freads; from the debian package maintainer
Diffstat (limited to 'gen.c')
-rw-r--r--gen.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/gen.c b/gen.c
index 1878500..6eb0b97 100644
--- a/gen.c
+++ b/gen.c
@@ -1344,10 +1344,19 @@ void make_tables()
{
if ( use_read )
{
+ outn( "\terrno=0; \\" );
outn(
-"\tif ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\" );
+"\twhile ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \\" );
+ outn( "\t{ \\" );
+ outn( "\t\tif( errno != EINTR) \\" );
+ outn( "\t\t{ \\" );
outn(
- "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
+ "\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\" );
+ outn( "\t\t\tbreak; \\" );
+ outn( "\t\t} \\" );
+ outn( "\t\terrno=0; \\" );
+ outn( "\t\tclearerr(yyin); \\" );
+ outn( "\t}" );
}
else
@@ -1367,11 +1376,22 @@ void make_tables()
"\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\" );
outn( "\t\tresult = n; \\" );
outn( "\t\t} \\" );
+ outn( "\telse \\" );
+ outn( "\t\t{ \\" );
+ outn( "\t\terrno=0; \\" );
outn(
- "\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\" );
- outn( "\t\t && ferror( yyin ) ) \\" );
+"\t\twhile ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \\" );
+ outn( "\t\t\t{ \\" );
+ outn( "\t\t\tif( errno != EINTR) \\" );
+ outn( "\t\t\t\t{ \\" );
outn(
- "\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" );" );
+ "\t\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\" );
+ outn( "\t\t\t\tbreak; \\" );
+ outn( "\t\t\t\t} \\" );
+ outn( "\t\t\terrno=0; \\" );
+ outn( "\t\t\tclearerr(yyin); \\" );
+ outn( "\t\t\t} \\" );
+ outn( "\t\t}" );
}
}