Use fseeko() to properly support large files.

This commit is contained in:
Tim J. Robbins 2004-03-22 11:15:03 +00:00
parent 2eada6bc8e
commit 2fa2fea101
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127300

View File

@ -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);
/*