From: Guido van Rossum Date: Fri, 7 Jun 1991 13:58:56 +0000 (+0000) Subject: When printing an error message, don't choke if tok->buf is NULL. X-Git-Tag: v0.9.8~903 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=56b07c8ad98d9bc410e08151b9d0bbb900722f01;p=thirdparty%2FPython%2Fcpython.git When printing an error message, don't choke if tok->buf is NULL. --- diff --git a/Parser/parsetok.c b/Parser/parsetok.c index a0bac20ec6b3..31c23853f954 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;