Mercurial > cpython-lru_cache-weakref
comparison Python/pythonrun.c @ 65694:6ac18576e8fa
decrement offset when it points to a newline (#10186 followup)
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Fri, 29 Oct 2010 03:28:14 +0000 |
| parents | f148f864b168 |
| children | ea14977a36de |
comparison
equal
deleted
inserted
replaced
| 65693:b66ded4bff21 | 65694:6ac18576e8fa |
|---|---|
| 1342 static void | 1342 static void |
| 1343 print_error_text(PyObject *f, int offset, const char *text) | 1343 print_error_text(PyObject *f, int offset, const char *text) |
| 1344 { | 1344 { |
| 1345 char *nl; | 1345 char *nl; |
| 1346 if (offset >= 0) { | 1346 if (offset >= 0) { |
| 1347 if (offset > 0 && offset == strlen(text) && text[offset - 1] == '\n') | |
| 1348 offset--; | |
| 1347 for (;;) { | 1349 for (;;) { |
| 1348 nl = strchr(text, '\n'); | 1350 nl = strchr(text, '\n'); |
| 1349 if (nl == NULL || nl-text >= offset) | 1351 if (nl == NULL || nl-text >= offset) |
| 1350 break; | 1352 break; |
| 1351 offset -= (int)(nl+1-text); | 1353 offset -= (int)(nl+1-text); |
| 1361 if (*text == '\0' || text[strlen(text)-1] != '\n') | 1363 if (*text == '\0' || text[strlen(text)-1] != '\n') |
| 1362 PyFile_WriteString("\n", f); | 1364 PyFile_WriteString("\n", f); |
| 1363 if (offset == -1) | 1365 if (offset == -1) |
| 1364 return; | 1366 return; |
| 1365 PyFile_WriteString(" ", f); | 1367 PyFile_WriteString(" ", f); |
| 1366 while (--offset) | 1368 while (--offset > 0) |
| 1367 PyFile_WriteString(" ", f); | 1369 PyFile_WriteString(" ", f); |
| 1368 PyFile_WriteString("^\n", f); | 1370 PyFile_WriteString("^\n", f); |
| 1369 } | 1371 } |
| 1370 | 1372 |
| 1371 static void | 1373 static void |
