Skip to content

yyinput() with EOF has inconsistent behavior with documentation #444

@forewing

Description

@forewing

Current Behavior

f863c94 changed the return value of yyinput() from EOF to 0 when encountering an end-of-file:

flex/src/flex.skl

Lines 1970 to 1973 in 3a4af34

case EOB_ACT_END_OF_FILE:
{
if ( yywrap( M4_YY_CALL_ONLY_ARG ) )
return EOF;

flex/src/flex.skl

Lines 1970 to 1973 in f863c94

case EOB_ACT_END_OF_FILE:
{
if ( yywrap( M4_YY_CALL_ONLY_ARG ) )
return 0;

Inconsistence

But as documentation showed, yyinput() return EOF when encountering an end-of-file:

flex/doc/flex.texi

Lines 4549 to 4553 in 8b1fbf6

The @code{input()} routine is not redefinable, though it may be called
to read characters following whatever has been matched by a rule. If
@code{input()} encounters an end-of-file the normal @code{yywrap()}
processing is done. A ``real'' end-of-file is returned by
@code{input()} as @code{EOF}.

And the example of comments discarding use EOF to check:

flex/doc/flex.texi

Lines 1410 to 1411 in 8b1fbf6

while ( (c = input()) != '*' &&
c != EOF )

flex/doc/flex.texi

Lines 1422 to 1426 in 8b1fbf6

if ( c == EOF )
{
error( "EOF in comment" );
break;
}

which will never break from the loop in current version.

Possible Solution

The documentation should be updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions