Skip to content

Calling yyless(n) after input() causes a character duplicated. #547

@SouravKB

Description

@SouravKB
"a" {
    input();
    yyless(0);
}

"azz" {
    printf("Never should have been matched!\n");
}

This sample scanner with input ayz should never match rule 2.

But after matching 'a' inside rule 1, calling input() returns 'y'. It increments yy_c_buf_p to point to 'z', and character at yy_c_buf_p, i.e. 'z' into yy_hold_char. But yyless macro is using outdated variable yy_cp to restore the yy_hold_char, which replaces it in a different position essentially causing duplication of character held by yy_hold_char.

Now the buffer contains azz which would erroneously match rule 2.

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