]> granicus.if.org Git - flex/commitdiff
Added yy_fill_buffer
authorVern Paxson <vern@ee.lbl.gov>
Sat, 11 Dec 1993 10:56:41 +0000 (10:56 +0000)
committerVern Paxson <vern@ee.lbl.gov>
Sat, 11 Dec 1993 10:56:41 +0000 (10:56 +0000)
flex.skl

index 244a930d85d092ceba8bdc5326dda7d743a8d992..f97e506f09d272cb1257a182c6164c6e6f5b6208 100644 (file)
--- a/flex.skl
+++ b/flex.skl
@@ -174,7 +174,12 @@ struct yy_buffer_state
         * instead of fread(), to make sure we stop fetching input after
         * each newline.
         */
-       int is_interactive;
+       int yy_is_interactive;
+
+       /* Whether to try to fill the input buffer when we reach the
+        * end of it.
+        */
+       int yy_fill_buffer;
 
        /* Whether we've seen an EOF on this buffer. */
        int yy_eof_status;
@@ -591,6 +596,25 @@ int yyFlexLexer::yy_get_next_buffer()
                YY_FATAL_ERROR(
                "fatal flex scanner internal error--end of buffer missed" );
 
+       if ( yy_current_buffer->yy_fill_buffer == 0 )
+               { /* Don't try to fill the buffer, so this is an EOF. */
+               if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+                       {
+                       /* We matched a singled characater, the EOB, so
+                        * treat this as a final EOF.
+                        */
+                       return EOB_ACT_END_OF_FILE;
+                       }
+
+               else
+                       {
+                       /* We matched some text prior to the EOB, first
+                        * process it.
+                        */
+                       return EOB_ACT_LAST_MATCH;
+                       }
+               }
+
        /* Try to read more data. */
 
        /* First move last chars to start of buffer. */
@@ -1004,11 +1028,13 @@ void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
        b->yy_buf_pos = &b->yy_ch_buf[1];
 
 %-
-       b->is_interactive = file ? isatty( fileno(file) ) : 0;
+       b->yy_is_interactive = file ? isatty( fileno(file) ) : 0;
 %+
-       b->is_interactive = 0;
+       b->yy_is_interactive = 0;
 %*
 
+       b->yy_fill_buffer = 1;
+
        b->yy_eof_status = EOF_NOT_SEEN;
        }