diff options
author | steve <steve@FreeBSD.org> | 1996-12-14 05:48:48 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1996-12-14 05:48:48 +0000 |
commit | f06b28eb4ac4e55e57735cfc793affe386b055df (patch) | |
tree | 536c8090066a8a1145387bb264d01cc0f4c29ede /usr.bin/lex | |
parent | aff08726651db11790b5e6bb4c9b59028f2482c6 (diff) | |
download | FreeBSD-src-f06b28eb4ac4e55e57735cfc793affe386b055df.zip FreeBSD-src-f06b28eb4ac4e55e57735cfc793affe386b055df.tar.gz |
Upgrade to version 2.5.4 of flex.
Inspired by: NetBSD/OpenBSD (I can't remember who I saw do it
first, so I'll give them both some inspiration
points. :)
Diffstat (limited to 'usr.bin/lex')
-rw-r--r-- | usr.bin/lex/NEWS | 11 | ||||
-rw-r--r-- | usr.bin/lex/flex.skl | 52 | ||||
-rw-r--r-- | usr.bin/lex/initscan.c | 54 | ||||
-rw-r--r-- | usr.bin/lex/scan.l | 4 | ||||
-rw-r--r-- | usr.bin/lex/skel.c | 52 | ||||
-rw-r--r-- | usr.bin/lex/version.h | 2 |
6 files changed, 108 insertions, 67 deletions
diff --git a/usr.bin/lex/NEWS b/usr.bin/lex/NEWS index e4ba93f..3e23e7d 100644 --- a/usr.bin/lex/NEWS +++ b/usr.bin/lex/NEWS @@ -1,3 +1,14 @@ +Changes between release 2.5.4 (11Sep96) and release 2.5.3: + + - Fixed a bug introduced in 2.5.3 that blew it when a call + to input() occurred at the end of an input file. + + - Fixed scanner skeleton so the example in the man page of + scanning strings using exclusive start conditions works. + + - Minor Makefile tweaks. + + Changes between release 2.5.3 (29May96) and release 2.5.2: - Some serious bugs in yymore() have been fixed. In particular, diff --git a/usr.bin/lex/flex.skl b/usr.bin/lex/flex.skl index 67ebe57..8dee386 100644 --- a/usr.bin/lex/flex.skl +++ b/usr.bin/lex/flex.skl @@ -1,7 +1,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.89 96/05/25 21:02:21 vern Exp $ + * $Header: /home/ncvs/src/usr.bin/lex/flex.skl,v 1.1.1.2 1996/06/19 20:26:06 nate Exp $ */ #define FLEX_SCANNER @@ -250,7 +250,7 @@ void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); %* @@ -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 } } } @@ -1223,6 +1230,9 @@ YY_BUFFER_STATE b; void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) %* { + if ( ! b ) + return; + b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes @@ -1286,17 +1296,17 @@ yy_size_t size; #ifndef YY_NO_SCAN_STRING %- #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *str ) +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else -YY_BUFFER_STATE yy_scan_string( str ) -yyconst char *str; +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; #endif { int len; - for ( len = 0; str[len]; ++len ) + for ( len = 0; yy_str[len]; ++len ) ; - return yy_scan_bytes( str, len ); + return yy_scan_bytes( yy_str, len ); } %* #endif diff --git a/usr.bin/lex/initscan.c b/usr.bin/lex/initscan.c index ab1766c..f5e9dd1 100644 --- a/usr.bin/lex/initscan.c +++ b/usr.bin/lex/initscan.c @@ -2,7 +2,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /home/ncvs/src/usr.bin/lex/initscan.c,v 1.1.1.2 1996/06/19 20:26:12 nate Exp $ + * $Header: /home/ncvs/src/usr.bin/lex/initscan.c,v 1.3 1996/06/19 20:47:13 nate Exp $ */ #define FLEX_SCANNER @@ -237,7 +237,7 @@ void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); static void *yy_flex_alloc YY_PROTO(( yy_size_t )); @@ -1270,7 +1270,7 @@ char *yytext; * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* $Header: /home/ncvs/src/usr.bin/lex/initscan.c,v 1.1.1.2 1996/06/19 20:26:12 nate Exp $ */ +/* $Header: /home/ncvs/src/usr.bin/lex/initscan.c,v 1.3 1996/06/19 20:47:13 nate Exp $ */ #include "flexdef.h" #include "parse.h" @@ -2929,7 +2929,7 @@ static int 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 { @@ -2984,6 +2984,8 @@ static int 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 ) @@ -3109,7 +3111,8 @@ 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" ); @@ -3152,13 +3155,26 @@ static int input() 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; @@ -3172,15 +3188,6 @@ static int input() 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 } } } @@ -3345,6 +3352,9 @@ YY_BUFFER_STATE b; #endif { + if ( ! b ) + return; + b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes @@ -3404,17 +3414,17 @@ yy_size_t size; #ifndef YY_NO_SCAN_STRING #ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *str ) +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) #else -YY_BUFFER_STATE yy_scan_string( str ) -yyconst char *str; +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; #endif { int len; - for ( len = 0; str[len]; ++len ) + for ( len = 0; yy_str[len]; ++len ) ; - return yy_scan_bytes( str, len ); + return yy_scan_bytes( yy_str, len ); } #endif diff --git a/usr.bin/lex/scan.l b/usr.bin/lex/scan.l index 8643a28..2db8d78 100644 --- a/usr.bin/lex/scan.l +++ b/usr.bin/lex/scan.l @@ -27,7 +27,7 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -/* $Header: /home/ncvs/src/usr.bin/lex/scan.l,v 1.1.1.2 1996/06/19 20:26:31 nate Exp $ */ +/* $Header: /home/ncvs/src/usr.bin/lex/scan.l,v 1.2 1996/06/19 22:25:32 nate Exp $ */ #include "flexdef.h" #include "parse.h" @@ -65,7 +65,7 @@ yymore_used = true; %} -%option caseless nodefault stack noyy_top_state +%option caseless nodefault outfile="scan.c" stack noyy_top_state %option nostdinit %x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE diff --git a/usr.bin/lex/skel.c b/usr.bin/lex/skel.c index adf710f..962c830 100644 --- a/usr.bin/lex/skel.c +++ b/usr.bin/lex/skel.c @@ -6,7 +6,7 @@ const char *skel[] = { "/* A lexical scanner generated by flex */", "", "/* Scanner skeleton version:", - " * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.89 96/05/25 21:02:21 vern Exp $", + " * $Header: /home/ncvs/src/usr.bin/lex/skel.c,v 1.1.1.2 1996/06/19 20:26:34 nate Exp $", " */", "", "#define FLEX_SCANNER", @@ -255,7 +255,7 @@ const char *skel[] = { "#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )", "", "YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));", - "YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));", + "YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));", "YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));", "%*", "", @@ -788,7 +788,7 @@ const char *skel[] = { " /* 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", " {", @@ -843,6 +843,8 @@ const char *skel[] = { " /* 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 )", @@ -952,7 +954,8 @@ const char *skel[] = { "", " 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\" );", @@ -1002,13 +1005,26 @@ const char *skel[] = { "", " 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;", @@ -1022,15 +1038,6 @@ const char *skel[] = { " 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", " }", " }", " }", @@ -1228,6 +1235,9 @@ const char *skel[] = { "void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )", "%*", " {", + " if ( ! b )", + " return;", + "", " b->yy_n_chars = 0;", "", " /* We always need two end-of-buffer characters. The first causes", @@ -1291,17 +1301,17 @@ const char *skel[] = { "#ifndef YY_NO_SCAN_STRING", "%-", "#ifdef YY_USE_PROTOS", - "YY_BUFFER_STATE yy_scan_string( yyconst char *str )", + "YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )", "#else", - "YY_BUFFER_STATE yy_scan_string( str )", - "yyconst char *str;", + "YY_BUFFER_STATE yy_scan_string( yy_str )", + "yyconst char *yy_str;", "#endif", " {", " int len;", - " for ( len = 0; str[len]; ++len )", + " for ( len = 0; yy_str[len]; ++len )", " ;", "", - " return yy_scan_bytes( str, len );", + " return yy_scan_bytes( yy_str, len );", " }", "%*", "#endif", diff --git a/usr.bin/lex/version.h b/usr.bin/lex/version.h index a7c072c..623ca12 100644 --- a/usr.bin/lex/version.h +++ b/usr.bin/lex/version.h @@ -1 +1 @@ -#define FLEX_VERSION "2.5.3" +#define FLEX_VERSION "2.5.4" |