From: Bob R. <bob...@co...> - 2007-11-13 15:49:17
|
Hi, The generated scanners produce a compiler warning, lexer.cc:1387: warning: comparison between signed and unsigned integer expressions It happens here, /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), num_to_read ); which expands to this, if ( (yy_buffer_stack)[(yy_buffer_stack_top)]->yy_is_interactive ) { int c = '*'; size_t n; for ( n = 0; n < num_to_read && (c = getc( in )) != (-1) && c != '\n'; ++n ) (&(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[number_to_move])[n] = (char) c; if ( c == '\n' ) (&(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[number_to_move])[n++] = (char) c; if ( c == (-1) && ferror( in ) ) yy_fatal_error( "input in flex scanner failed" ); (yy_n_chars) = n; } else { (*__errno_location ())=0; while ( ((yy_n_chars) = fread((&(yy_buffer_stack)[(yy_buffer_stack_top)]->yy_ch_buf[number_to_move]), 1, num_to_read, in))==0 && ferror(in)) { if( (*__errno_location ()) != 4) { yy_fatal_error( "input in flex scanner failed" ); break; } (*__errno_location ())=0; clearerr(in); } }; where 'size_t n' is compared to 'int num_to_read'. By changing num_to_read to type size_t, the compiler warning goes away. Since I'm not a flex programmer, I'm not sure if this is the correct fix, but it seems to be OK. Can this be applied? diff -u tmp/flex-2.5.33/flex.skl flex-2.5.33/flex.skl --- tmp/flex-2.5.33/flex.skl 2006-02-16 17:20:43.000000000 -0500 +++ flex-2.5.33/flex.skl 2007-11-13 10:42:14.000000000 -0500 @@ -1578,7 +1578,7 @@ else { - int num_to_read = + size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) Thanks, Bob Rossi |