Skip to content

yyinput() doesn't correctly restore yy_hold_char #395

@satya-das

Description

@satya-das

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions