When printing an error message, don't choke if tok->buf is NULL.

This commit is contained in:
Guido van Rossum 1991-06-07 13:58:56 +00:00
parent 64b4552069
commit 56b07c8ad9
1 changed files with 14 additions and 10 deletions

View File

@ -89,6 +89,9 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret)
char *p;
fprintf(stderr, "Parsing error: file %s, line %d:\n",
filename, tok->lineno);
if (tok->buf == NULL)
fprintf(stderr, "(EOF)\n");
else {
*tok->inp = '\0';
if (tok->inp > tok->buf && tok->inp[-1] == '\n')
tok->inp[-1] = '\0';
@ -101,6 +104,7 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret)
}
fprintf(stderr, "^\n");
}
}
tok_free(tok);
return ret;
}