Mercurial > cpython-lru_cache-weakref
comparison Python/traceback.c @ 11294:d3696bf08eee legacy-trunk
Tim Peters fixed PR#75: very long lines cause incorrect tracebacks.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sat, 18 Sep 1999 20:49:39 +0000 |
| parents | 79e49cbce2ef |
| children | c94247b5c355 |
comparison
equal
deleted
inserted
replaced
| 11293:a9d28a07a327 | 11294:d3696bf08eee |
|---|---|
| 195 sprintf(linebuf, FMT, filename, lineno, name); | 195 sprintf(linebuf, FMT, filename, lineno, name); |
| 196 err = PyFile_WriteString(linebuf, f); | 196 err = PyFile_WriteString(linebuf, f); |
| 197 if (xfp == NULL || err != 0) | 197 if (xfp == NULL || err != 0) |
| 198 return err; | 198 return err; |
| 199 for (i = 0; i < lineno; i++) { | 199 for (i = 0; i < lineno; i++) { |
| 200 if (fgets(linebuf, sizeof linebuf, xfp) == NULL) | 200 char* pLastChar = &linebuf[sizeof(linebuf)-2]; |
| 201 break; | 201 do { |
| 202 *pLastChar = '\0'; | |
| 203 if (fgets(linebuf, sizeof linebuf, xfp) == NULL) | |
| 204 break; | |
| 205 /* fgets read *something*; if it didn't get as | |
| 206 far as pLastChar, it must have found a newline | |
| 207 or hit the end of the file; if pLastChar is \n, | |
| 208 it obviously found a newline; else we haven't | |
| 209 yet seen a newline, so must continue */ | |
| 210 } while (*pLastChar != '\0' && *pLastChar != '\n'); | |
| 202 } | 211 } |
| 203 if (i == lineno) { | 212 if (i == lineno) { |
| 204 char *p = linebuf; | 213 char *p = linebuf; |
| 205 while (*p == ' ' || *p == '\t' || *p == '\014') | 214 while (*p == ' ' || *p == '\t' || *p == '\014') |
| 206 p++; | 215 p++; |
