You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you provide a reproducible test case that shows yyinput() does not return EOF on end of file?
Isn't the code change you've pointed to what's described in chapter 9 of the doc?
"When the scanner receives an end-of-file indication from YY INPUT, it then checks the yywrap() function. If yywrap() returns false (zero), then it is assumed that the function has gone ahead and set up yyin to point to another input file, and scanning continues. If it returns true (non-zero), then the scanner terminates, returning 0 to its caller."
You're right - input() is shown returning EOF on end of file in some parts of flex docs while it returns 0 in other places - I found the Posix spec for input() - https://pubs.opengroup.org/onlinepubs/9699919799/utilities/lex.html - it's supposed to return 0 not EOF on end of file
int input(void)
Returns the next character from the input, or zero on end-of-file. It shall obtain input from the stream pointer yyin, although possibly via an intermediate buffer. Thus, once scanning has begun, the effect of altering the value of yyin is undefined. The character read shall be removed from the input stream of the scanner without any processing by the scanner.
Current Behavior
f863c94 changed the return value of
yyinput()
fromEOF
to0
when encountering an end-of-file:flex/src/flex.skl
Lines 1970 to 1973 in 3a4af34
flex/src/flex.skl
Lines 1970 to 1973 in f863c94
Inconsistence
But as documentation showed,
yyinput()
return EOF when encountering an end-of-file:flex/doc/flex.texi
Lines 4549 to 4553 in 8b1fbf6
And the example of comments discarding use EOF to check:
flex/doc/flex.texi
Lines 1410 to 1411 in 8b1fbf6
flex/doc/flex.texi
Lines 1422 to 1426 in 8b1fbf6
which will never break from the loop in current version.
Possible Solution
The documentation should be updated.
The text was updated successfully, but these errors were encountered: