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