]> granicus.if.org Git - flex/commitdiff
read up to newline for interactive reads, rather than one char
authorVern Paxson <vern@ee.lbl.gov>
Mon, 20 Mar 1995 14:02:02 +0000 (14:02 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Mon, 20 Mar 1995 14:02:02 +0000 (14:02 +0000)
gen.c

diff --git a/gen.c b/gen.c
index 75ee2f6070319f9cea166c3e999d84eac6710fa6..a16a2b6058304dabfeb5f854742b2dac736bd112 100644 (file)
--- a/gen.c
+++ b/gen.c
@@ -1281,9 +1281,16 @@ void make_tables()
                        outn(
                        "\tif ( yy_current_buffer->yy_is_interactive ) \\" );
                        outn( "\t\t{ \\" );
-                       outn( "\t\tint c = getc( yyin ); \\" );
-                       outn( "\t\tresult = c == EOF ? 0 : 1; \\" );
-                       outn( "\t\tbuf[0] = (char) c; \\" );
+                       outn( "\t\tint c = '*', n; \\" );
+                       outn( "\t\tfor ( n = 0; n < max_size && \\" );
+       outn( "\t\t\t     (c = getc( yyin )) != EOF && c != '\\n'; ++n ) \\" );
+                       outn( "\t\t\tbuf[n] = (char) c; \\" );
+                       outn( "\t\tif ( c == '\\n' ) \\" );
+                       outn( "\t\t\tbuf[n++] = (char) c; \\" );
+                       outn( "\t\tif ( c == EOF && ferror( yyin ) ) \\" );
+                       outn(
+       "\t\t\tYY_FATAL_ERROR( \"input in flex scanner failed\" ); \\" );
+                       outn( "\t\tresult = n; \\" );
                        outn( "\t\t} \\" );
                        outn(
        "\telse if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \\" );