Re: [Flex-help] [Flex-devel] fix compiler warning
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Bob R. <bob...@co...> - 2007-12-08 22:32:27
|
On Sat, Dec 08, 2007 at 05:30:57PM -0500, Bob Rossi wrote: > On Fri, Nov 30, 2007 at 10:36:11PM -0500, Bob Rossi wrote: > > On Tue, Nov 13, 2007 at 10:49:15AM -0500, Bob Rossi wrote: > > > 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 ) > > > > Ping. Is this being taken seriously? > > Hello? I'll try the flex-help mailing list. Hi, Is this the correct list? Could this patch be applied? Thanks, Bob Rossi |