Re: Possible flex-2.5.4 bug
Hi,
[In response to my post regarding a possible flex-2.5.4 bug]
Manoj Srivastava <srivasta@datasync.com> wrote:
> Each argument is scanned separately, with yy_scan_string. An
> end of file is generated, then, at the end of each string (each
> argument). There is no yywrap function defined.
Right. My intention was not to wrap but to call yylex() thrice, thus
my use of "%option noyywrap". I fear that the multiple calls in my
example may have obscured the problem.
> So, you call yylex thrice, on three separate, non-wrapped files. The
> second file (string, argument, whatever) does end inside a comment,
> and since there is no wrapping, the eof is final. The error is as
> you asked it to be reported.
Right, but the program (when build with flex-2.5.4) then dies inside
the yylex() call and the third argument is never processed. To
clarify this, I have modified the example to print a message when
yylex() returns. For variety, I have also added an explicit yywrap()
function (which always returns 1). This time I provide single
arguments to the program to avoid the red herring of the multiple
yylex() calls.
In the example below, the program is run twice when built with
flex-2.5.2 and twice when built with flex-2.5.4, first with a
terminated comment and then with an unterminated comment. Notice that
when built with flex-2.5.4, it dies immediately following the "input
in flex scanner failed" message (generated internally by the flex
skeleton) when given the unterminated comment.
Manoj, thanks for the quick response. I receive a little grief at
work for my support of free software, especially from people who think
that an 800 phone number is necessary for support, but I feel that
commonly used free software typically has better support than most
commercial software. This is not an emergency since I was able to
install flex-2.5.2 on our RS/6000 from the sources on my rex disk. My
goal now is simply to report this bug. I am still a little skeptical
of my own code since it is not doing anything obscure and flex-2.5.4
has been out for over a year now. One thing which is clear is that my
program does what I expect it to with flex-2.5.2 but not with
flex-2.5.4.
Kirk Hilliard
----------------------------------------------------------------------
~/flexbug $ flex --version
flex version 2.5.2
~/flexbug $ ./flex-2.5.4 --version
./flex-2.5.4 version 2.5.4
~/flexbug $ cat foo2.l
%array
%%
"<" { int c;
while ( (c = input()) != '>' && c != EOF )
; /* eat up text of comment */
if ( c == EOF ) printf( "\n" "error: EOF in comment\n" );
}
foo printf("bar");
%%
void main(int argc, char **argv) {
YY_BUFFER_STATE ybsInputBuffer;
while(--argc) {
ybsInputBuffer = yy_scan_string(*++argv);
yylex();
printf( "\n" "yylex() done\n" );
yy_delete_buffer(ybsInputBuffer);
}
} /* main */
int yywrap(void) {
return 1;
} /* yywrap */
~/flexbug $ flex foo2.l
~/flexbug $ gcc lex.yy.c
~/flexbug $ ./a.out "foo<bleh>bell"
barbell
yylex() done
~/flexbug $ ./a.out "foo<bleh"
bar
error: EOF in comment
yylex() done
~/flexbug $ ./flex-2.5.4 foo2.l
~/flexbug $ gcc lex.yy.c
~/flexbug $ ./a.out "foo<bleh>bell"
barbell
yylex() done
~/flexbug $ echo "*** Here comes the bug. ***" > /dev/null
~/flexbug $ ./a.out "foo<bleh"
bar
error: EOF in comment
input in flex scanner failed
~/flexbug $ echo "Notice that it died inside the yylex() call." > /dev/null
----------------------------------------------------------------------
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: