Calling yyinput() in sequence leaves the buffer with sequence of null chars. The reason is that the yy_hold_char is set from next character value instead of the one which is set to null. The end of implementation of yyinput() like:
c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
*(yy_c_buf_p) = '\0'; /* preserve yytext */
(yy_hold_char) = *++(yy_c_buf_p);
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
return c;
As it can be seen that yy_hold_char holds the value of character at the position next to the char that is being returned. In the next call to yyinput() following line has no effect:
*(yy_c_buf_p) = (yy_hold_char);
As yy_c_buf_p is not the position that was set to null.
Calling yyinput() in sequence leaves the buffer with sequence of null chars. The reason is that the yy_hold_char is set from next character value instead of the one which is set to null. The end of implementation of yyinput() like:
As it can be seen that yy_hold_char holds the value of character at the position next to the char that is being returned. In the next call to yyinput() following line has no effect:
As yy_c_buf_p is not the position that was set to null.