summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-09-19 08:08:50 (GMT)
committerGuido van Rossum <guido@python.org>1994-09-19 08:08:50 (GMT)
commit798199d8a60528a0c565926fbf21a299fd3adbf5 (patch)
treecdf5673919b07f352a90fde5826132dedff68b7b /Python/pythonrun.c
parent1a817c0911f6fe64905b28afa808f4841681f683 (diff)
downloadcpython-798199d8a60528a0c565926fbf21a299fd3adbf5.zip
cpython-798199d8a60528a0c565926fbf21a299fd3adbf5.tar.gz
cpython-798199d8a60528a0c565926fbf21a299fd3adbf5.tar.bz2
* Python/pythonrun.c (print_error): print only last line of
multi-line source line
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index e547f92..978e4b8 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -286,6 +286,18 @@ print_error()
writestring(buf, f);
writestring("\n", f);
if (text != NULL) {
+ char *nl;
+ if (offset > 0 &&
+ offset == strlen(text))
+ offset--;
+ for (;;) {
+ nl = strchr(text, '\n');
+ if (nl == NULL ||
+ nl-text >= offset)
+ break;
+ offset -= (nl+1-text);
+ text = nl+1;
+ }
while (*text == ' ' || *text == '\t') {
text++;
offset--;