Kaydet (Commit) 56b07c8a authored tarafından Guido van Rossum's avatar Guido van Rossum

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

üst 64b45520
...@@ -89,6 +89,9 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret) ...@@ -89,6 +89,9 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret)
char *p; char *p;
fprintf(stderr, "Parsing error: file %s, line %d:\n", fprintf(stderr, "Parsing error: file %s, line %d:\n",
filename, tok->lineno); filename, tok->lineno);
if (tok->buf == NULL)
fprintf(stderr, "(EOF)\n");
else {
*tok->inp = '\0'; *tok->inp = '\0';
if (tok->inp > tok->buf && tok->inp[-1] == '\n') if (tok->inp > tok->buf && tok->inp[-1] == '\n')
tok->inp[-1] = '\0'; tok->inp[-1] = '\0';
...@@ -101,6 +104,7 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret) ...@@ -101,6 +104,7 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret)
} }
fprintf(stderr, "^\n"); fprintf(stderr, "^\n");
} }
}
tok_free(tok); tok_free(tok);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment