summaryrefslogtreecommitdiff
path: root/flex.skl
diff options
context:
space:
mode:
authorVern Paxson <vern@ee.lbl.gov>1996-07-02 16:35:35 +0000
committerVern Paxson <vern@ee.lbl.gov>1996-07-02 16:35:35 +0000
commit64c1d36fde1c7cedc75b75e0370a9cc86af09026 (patch)
treeeb16f9c66118219dde7acaecae21cd562c5475b6 /flex.skl
parentae3130c761a783b304811de10e44a221e15c9ef2 (diff)
(attempted) fix for input() crossing a file boundary
Diffstat (limited to 'flex.skl')
-rw-r--r--flex.skl35
1 files changed, 21 insertions, 14 deletions
diff --git a/flex.skl b/flex.skl
index 7aa9869..a491f65 100644
--- a/flex.skl
+++ b/flex.skl
@@ -783,7 +783,7 @@ int yyFlexLexer::yy_get_next_buffer()
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
- yy_n_chars = 0;
+ yy_current_buffer->yy_n_chars = yy_n_chars = 0;
else
{
@@ -838,6 +838,8 @@ int yyFlexLexer::yy_get_next_buffer()
/* Read in more data. */
YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
yy_n_chars, num_to_read );
+
+ yy_current_buffer->yy_n_chars = yy_n_chars;
}
if ( yy_n_chars == 0 )
@@ -947,7 +949,8 @@ void yyFlexLexer::yyunput( int c, register char* yy_bp )
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
- yy_n_chars = yy_current_buffer->yy_buf_size;
+ yy_current_buffer->yy_n_chars =
+ yy_n_chars = yy_current_buffer->yy_buf_size;
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
@@ -997,13 +1000,26 @@ int yyFlexLexer::yyinput()
switch ( yy_get_next_buffer() )
{
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart( yyin );
+
+ /* fall through */
+
case EOB_ACT_END_OF_FILE:
{
if ( yywrap() )
- {
- yy_c_buf_p = yytext_ptr + offset;
return EOF;
- }
if ( ! yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
@@ -1017,15 +1033,6 @@ int yyFlexLexer::yyinput()
case EOB_ACT_CONTINUE_SCAN:
yy_c_buf_p = yytext_ptr + offset;
break;
-
- case EOB_ACT_LAST_MATCH:
-#ifdef __cplusplus
- YY_FATAL_ERROR(
- "unexpected last match in yyinput()" );
-#else
- YY_FATAL_ERROR(
- "unexpected last match in input()" );
-#endif
}
}
}