No longer segfault upon error at end of file
This commit is contained in:
parent
9c48578042
commit
1c583e006e
@ -123,14 +123,16 @@ static int _parse_check(C99 * c99, TokenCode code)
|
|||||||
|
|
||||||
/* parse_error */
|
/* parse_error */
|
||||||
static int _parse_error(C99 * c99, char const * format, ...)
|
static int _parse_error(C99 * c99, char const * format, ...)
|
||||||
/* FIXME segfaults when EOF (c99->token is NULL) */
|
|
||||||
{
|
{
|
||||||
Token * token = c99->token;
|
Token * token = c99->token;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
if(token == NULL) /* XXX not very elegant */
|
||||||
|
fputs(PACKAGE ": near end of file: error: ", stderr);
|
||||||
|
else
|
||||||
fprintf(stderr, "%s%s:%u, near \"%s\": error: ", PACKAGE ": ",
|
fprintf(stderr, "%s%s:%u, near \"%s\": error: ", PACKAGE ": ",
|
||||||
token_get_filename(token), token_get_line(token),
|
token_get_filename(token),
|
||||||
token_get_string(token));
|
token_get_line(token), token_get_string(token));
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vfprintf(stderr, format, ap);
|
vfprintf(stderr, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
Loading…
Reference in New Issue
Block a user