From: Jarmo Raiha (jarmo@ksvltd.fi)
Date: 06/01/92


From: jarmo@ksvltd.fi (Jarmo Raiha)
Subject: Re: flex bug?
Date: 1 Jun 1992 10:05:15 GMT

ben@joplin.wri.com (Ben Cox) writes:

>I encountered a problem (dunno if it's a bug or not) using flex the
>other night, with this code:

>\"[^"]* { if ( yytext[yyleng-1] == '\\' ) {
> yymore();
> } else {
> input();
> /* process yytext... */
> }
>}

>/* Note: I used \"[^"]* instead of \"[^\"]* because the BSD4.3 manual
>(yes, I know that's for lex and not flex) says " is not special inside
>[], although my nutshell book says to use `\"[^\"]*': this part works,
>so nutshell must be wrong... :-) */

>The problem is that when the input is

> "abcdefg";

>Then BEFORE the input() yytext contains '"abcdefg' as it should, but
>then AFTER the input(), yytext contains '"abcdefg";'!!

>According to the lex manual (in the BSD4.3 manuals), input() should
>just get the next character off the input stream and return it,
>without putting it into yytext or anything.

According to my manuals too.
But - they don't say that input wouldn't modify what yytext is pointing at.

My ATT lex has yytext as an separate array, but flex's yytext is
a pointer to it's input buffer.

Depending on the flex's input buffer state , input might move
parts of it or modify it. (If I remember correct)

 Jarmo Raiha