From ffeaa226cbad2ee5c88f635ddcb73459041400f5 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Sat, 11 Dec 1993 10:56:41 +0000 Subject: [PATCH] Added yy_fill_buffer --- flex.skl | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/flex.skl b/flex.skl index 244a930..f97e506 100644 --- 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; } -- 2.40.0