summaryrefslogtreecommitdiffstats
path: root/Parser/parsetok.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-06-07 13:58:56 (GMT)
committerGuido van Rossum <guido@python.org>1991-06-07 13:58:56 (GMT)
commit56b07c8ad98d9bc410e08151b9d0bbb900722f01 (patch)
treef55d91d3e02b2e271e2be4be4cefc767bfb0832c /Parser/parsetok.c
parent64b4552069484c19c0127d3168931b38c557e039 (diff)
downloadcpython-56b07c8ad98d9bc410e08151b9d0bbb900722f01.zip
cpython-56b07c8ad98d9bc410e08151b9d0bbb900722f01.tar.gz
cpython-56b07c8ad98d9bc410e08151b9d0bbb900722f01.tar.bz2
When printing an error message, don't choke if tok->buf is NULL.
Diffstat (limited to 'Parser/parsetok.c')
-rw-r--r--Parser/parsetok.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index a0bac20..31c2385 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -89,17 +89,21 @@ parsefile(fp, filename, g, start, ps1, ps2, n_ret)
char *p;
fprintf(stderr, "Parsing error: file %s, line %d:\n",
filename, tok->lineno);
- *tok->inp = '\0';
- if (tok->inp > tok->buf && tok->inp[-1] == '\n')
- tok->inp[-1] = '\0';
- fprintf(stderr, "%s\n", tok->buf);
- for (p = tok->buf; p < tok->cur; p++) {
- if (*p == '\t')
- putc('\t', stderr);
- else
- putc(' ', stderr);
+ 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';
+ fprintf(stderr, "%s\n", tok->buf);
+ for (p = tok->buf; p < tok->cur; p++) {
+ if (*p == '\t')
+ putc('\t', stderr);
+ else
+ putc(' ', stderr);
+ }
+ fprintf(stderr, "^\n");
}
- fprintf(stderr, "^\n");
}
tok_free(tok);
return ret;