Kaydet (Commit) 3aca6531 authored tarafından Guido van Rossum's avatar Guido van Rossum

Tim Peters fixed PR#75: very long lines cause incorrect tracebacks.

üst 458e7fab
......@@ -197,8 +197,17 @@ tb_displayline(f, filename, lineno, name)
if (xfp == NULL || err != 0)
return err;
for (i = 0; i < lineno; i++) {
if (fgets(linebuf, sizeof linebuf, xfp) == NULL)
break;
char* pLastChar = &linebuf[sizeof(linebuf)-2];
do {
*pLastChar = '\0';
if (fgets(linebuf, sizeof linebuf, xfp) == NULL)
break;
/* fgets read *something*; if it didn't get as
far as pLastChar, it must have found a newline
or hit the end of the file; if pLastChar is \n,
it obviously found a newline; else we haven't
yet seen a newline, so must continue */
} while (*pLastChar != '\0' && *pLastChar != '\n');
}
if (i == lineno) {
char *p = linebuf;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment