Use fseeko() to properly support large files.
This commit is contained in:
parent
2eada6bc8e
commit
2fa2fea101
@ -326,12 +326,12 @@ toomuch(FILE *ofp, long n)
|
||||
if (ftello(ofp) < (off_t)sizeof(buf))
|
||||
rewind(ofp);
|
||||
else
|
||||
fseek(ofp, -(long)sizeof(buf), SEEK_CUR);
|
||||
fseeko(ofp, -(off_t)sizeof(buf), SEEK_CUR);
|
||||
if (ferror(ofp))
|
||||
errx(1, "%s: can't seek", currfile);
|
||||
if ((nread = fread(buf, 1, sizeof(buf), ofp)) == 0)
|
||||
errx(1, "can't read overflowed output");
|
||||
if (fseek(ofp, -(long)nread, SEEK_CUR) != 0)
|
||||
if (fseeko(ofp, -(off_t)nread, SEEK_CUR) != 0)
|
||||
err(1, "%s", currfile);
|
||||
for (i = 1; i <= nread; i++)
|
||||
if (buf[nread - i] == '\n' && n-- == 0)
|
||||
@ -339,7 +339,7 @@ toomuch(FILE *ofp, long n)
|
||||
if (ftello(ofp) == 0)
|
||||
break;
|
||||
} while (n > 0);
|
||||
if (fseek(ofp, nread - i + 1, SEEK_CUR) != 0)
|
||||
if (fseeko(ofp, nread - i + 1, SEEK_CUR) != 0)
|
||||
err(1, "%s", currfile);
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user