"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.
This sample scanner with input
ayzshould never match rule 2.But after matching 'a' inside rule 1, calling
input()returns 'y'. It incrementsyy_c_buf_pto point to 'z', and character atyy_c_buf_p, i.e. 'z' intoyy_hold_char. Butyylessmacro is using outdated variableyy_cpto restore theyy_hold_char, which replaces it in a different position essentially causing duplication of character held byyy_hold_char.Now the buffer contains
azzwhich would erroneously match rule 2.