]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* Python/pythonrun.c (print_error): print only last line of
authorGuido van Rossum <guido@python.org>
Mon, 19 Sep 1994 08:08:50 +0000 (08:08 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 19 Sep 1994 08:08:50 +0000 (08:08 +0000)
multi-line source line

Python/pythonrun.c

index e547f9238a0c11599127780a286723855f80e699..978e4b866bdfb3658ead96bceb487e18cc025e66 100644 (file)
@@ -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--;