summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVern Paxson <vern@ee.lbl.gov>1993-10-03 16:01:56 +0000
committerVern Paxson <vern@ee.lbl.gov>1993-10-03 16:01:56 +0000
commit1fd6facb52598dc4b6c307101fbd3de5cd8bf0a1 (patch)
tree9255a7f1572adfb2a74e909b0dd1a5c469403cd9
parent640e372ac8831e9566c47e0fbf4230ecb86105ba (diff)
Minimized use of YY_CHAR
-rw-r--r--flex.skl38
-rw-r--r--gen.c17
2 files changed, 28 insertions, 27 deletions
diff --git a/flex.skl b/flex.skl
index 3615ab4..09c765c 100644
--- a/flex.skl
+++ b/flex.skl
@@ -218,8 +218,8 @@ struct yy_buffer_state
istream* yy_input_file;
%*
- YY_CHAR *yy_ch_buf; /* input buffer */
- YY_CHAR *yy_buf_pos; /* current position in input buffer */
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
/* Size of input buffer in bytes, not including room for EOB
* characters.
@@ -256,7 +256,7 @@ static YY_BUFFER_STATE yy_current_buffer = 0;
%- Standard (non-C++) definition
/* yy_hold_char holds the character lost when yytext is formed. */
-static YY_CHAR yy_hold_char;
+static char yy_hold_char;
static int yy_n_chars; /* number of characters read into yy_ch_buf */
@@ -266,7 +266,7 @@ int yyleng;
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
/* Points to current character in buffer. */
-static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
+static char *yy_c_buf_p = (char *) 0;
static int yy_init = 1; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
@@ -275,7 +275,7 @@ static int yy_start = 0; /* start state number */
*/
static int yy_did_buffer_switch_on_eof;
-static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
void yyrestart YY_PROTO(( FILE *input_file ));
void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
void yy_load_buffer_state YY_PROTO(( void ));
@@ -320,7 +320,7 @@ static int yy_get_next_buffer YY_PROTO(( void ));
YY_DECL
{
register yy_state_type yy_current_state;
- register YY_CHAR *yy_cp, *yy_bp;
+ register char *yy_cp, *yy_bp;
register int yy_act;
%% user's declarations go here
@@ -547,8 +547,8 @@ static int yy_get_next_buffer()
int yyFlexLexer::yy_get_next_buffer()
%*
{
- register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
- register YY_CHAR *source = yytext_ptr - 1; /* copy prev. char, too */
+ register char *dest = yy_current_buffer->yy_ch_buf;
+ register char *source = yytext_ptr - 1; /* copy prev. char, too */
register int number_to_move, i;
int ret_val;
@@ -584,7 +584,7 @@ int yyFlexLexer::yy_get_next_buffer()
int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf;
b->yy_buf_size *= 2;
- b->yy_ch_buf = (YY_CHAR *)
+ b->yy_ch_buf = (char *)
yy_flex_realloc( (void *) b->yy_ch_buf,
b->yy_buf_size );
@@ -649,7 +649,7 @@ yy_state_type yyFlexLexer::yy_get_previous_state()
%*
{
register yy_state_type yy_current_state;
- register YY_CHAR *yy_cp;
+ register char *yy_cp;
%% code to get the start state into yy_current_state goes here
@@ -688,17 +688,17 @@ yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
%-
#ifdef YY_USE_PROTOS
-static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
+static void yyunput( int c, register char *yy_bp )
#else
static void yyunput( c, yy_bp )
-YY_CHAR c;
-register YY_CHAR *yy_bp;
+int c;
+register char *yy_bp;
#endif
%+
-void yyFlexLexer::yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
+void yyFlexLexer::yyunput( int c, register char* yy_bp )
%*
{
- register YY_CHAR *yy_cp = yy_c_buf_p;
+ register char *yy_cp = yy_c_buf_p;
/* undo effects of setting up yytext */
*yy_cp = yy_hold_char;
@@ -707,9 +707,9 @@ void yyFlexLexer::yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
register int number_to_move = yy_n_chars + 2;
- register YY_CHAR *dest = &yy_current_buffer->yy_ch_buf[
+ register char *dest = &yy_current_buffer->yy_ch_buf[
yy_current_buffer->yy_buf_size + 2];
- register YY_CHAR *source =
+ register char *source =
&yy_current_buffer->yy_ch_buf[number_to_move];
while ( source > yy_current_buffer->yy_ch_buf )
@@ -726,7 +726,7 @@ void yyFlexLexer::yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
yy_cp[-2] = '\n';
- *--yy_cp = c;
+ *--yy_cp = (char) c;
/* Note: the formal parameter *must* be called "yy_bp" for this
* macro to now work correctly.
@@ -901,7 +901,7 @@ YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (YY_CHAR *) yy_flex_alloc( b->yy_buf_size + 2 );
+ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
diff --git a/gen.c b/gen.c
index d31ff93..9f2f558 100644
--- a/gen.c
+++ b/gen.c
@@ -484,7 +484,7 @@ void gen_next_match()
if ( fulltbl )
{
indent_put2s(
- "while ( (yy_current_state = yy_nxt[yy_current_state][%s]) > 0 )",
+"while ( (yy_current_state = yy_nxt[yy_current_state][(unsigned int)%s]) > 0 )",
char_map );
indent_up();
@@ -594,7 +594,8 @@ int worry_about_NULs;
}
else
- (void) strcpy( char_map, useecs ? "yy_ec[*yy_cp]" : "*yy_cp" );
+ (void) strcpy( char_map,
+ useecs ? "yy_ec[(unsigned int) *yy_cp]" : "*yy_cp" );
if ( worry_about_NULs && nultrans )
{
@@ -609,12 +610,12 @@ int worry_about_NULs;
if ( fulltbl )
indent_put2s(
- "yy_current_state = yy_nxt[yy_current_state][%s];",
+ "yy_current_state = yy_nxt[yy_current_state][(unsigned int) %s];",
char_map );
else if ( fullspd )
indent_put2s(
- "yy_current_state += yy_current_state[%s].yy_nxt;",
+ "yy_current_state += yy_current_state[(unsigned int) %s].yy_nxt;",
char_map );
else
@@ -648,7 +649,7 @@ void gen_NUL_trans()
if ( need_backing_up )
/* We'll need yy_cp lying around for the gen_backing_up(). */
- indent_puts( "register YY_CHAR *yy_cp = yy_c_buf_p;" );
+ indent_puts( "register char *yy_cp = yy_c_buf_p;" );
putchar( '\n' );
@@ -1112,7 +1113,7 @@ void make_tables()
indent_puts(
"static yy_state_type yy_last_accepting_state;" );
indent_puts(
- "static YY_CHAR *yy_last_accepting_cpos;\n" );
+ "static char *yy_last_accepting_cpos;\n" );
}
}
@@ -1150,7 +1151,7 @@ void make_tables()
{
puts(
"static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr;" );
- puts( "static YY_CHAR *yy_full_match;" );
+ puts( "static char *yy_full_match;" );
puts( "static int yy_lp;" );
}
@@ -1356,7 +1357,7 @@ void make_tables()
skelout();
if ( bol_needed )
- indent_puts( "register YY_CHAR *yy_bp = yytext_ptr;\n" );
+ indent_puts( "register char *yy_bp = yytext_ptr;\n" );
gen_start_state();