* src/lex.c (parse_percent_token): Be sure to 0-end token_buffer

before returning.
Reported by Benoit Perrot.
This commit is contained in:
Akim Demaille
2002-03-04 12:06:07 +00:00
parent f9abaa2c4c
commit 550245801e
3 changed files with 38 additions and 35 deletions

View File

@@ -485,44 +485,40 @@ parse_percent_token (void)
obstack_1grow (&token_obstack, '%');
obstack_1grow (&token_obstack, c);
switch (c)
{
case '%':
token_buffer = obstack_finish (&token_obstack);
return tok_two_percents;
case '{':
token_buffer = obstack_finish (&token_obstack);
return tok_percent_left_curly;
/* The following guys are here for backward compatibility with
very ancient Yacc versions. The paper of Johnson mentions
them (as ancient :). */
case '<':
token_buffer = obstack_finish (&token_obstack);
return tok_left;
case '>':
token_buffer = obstack_finish (&token_obstack);
return tok_right;
case '2':
token_buffer = obstack_finish (&token_obstack);
return tok_nonassoc;
case '0':
token_buffer = obstack_finish (&token_obstack);
return tok_token;
case '=':
token_buffer = obstack_finish (&token_obstack);
return tok_prec;
}
if (!isalpha (c))
{
obstack_1grow (&token_obstack, '\0');
token_buffer = obstack_finish (&token_obstack);
return tok_illegal;
switch (c)
{
case '%':
return tok_two_percents;
case '{':
return tok_percent_left_curly;
/* The following guys are here for backward compatibility with
very ancient Yacc versions. The paper of Johnson mentions
them (as ancient :). */
case '<':
return tok_left;
case '>':
return tok_right;
case '2':
return tok_nonassoc;
case '0':
return tok_token;
case '=':
return tok_prec;
default:
return tok_illegal;
}
}
while (c = getc (finput), isalpha (c) || c == '_' || c == '-')