diff --git a/src/dj.c b/src/dj.c index a20b472..41fd65f 100644 --- a/src/dj.c +++ b/src/dj.c @@ -133,7 +133,9 @@ Io_fdopen(struct Io *io, char *fn){ } /* Seeks io->seek bytes through *io's file descriptor, subtracting the number - * of sought bytes from io->seek. This procedure leaves garbage in io->buf. */ + * of sought bytes from io->seek. This procedure leaves garbage in io->buf. + * Read/written bytes here aren't counted in the statistics because successful + * seeking is guaranteed. */ static void Io_fdseek(struct Io *io){ @@ -143,8 +145,10 @@ Io_fdseek(struct Io *io){ assert(io->fd != STDERR_FILENO || io->fl == write_flags); if(io->seek == 0 - || (!fdisstd(io->fd) && lseek(io->fd, io->seek, SEEK_SET) != -1)) + || (!fdisstd(io->fd) && lseek(io->fd, io->seek, SEEK_SET) != -1)){ + io->seek = 0; return; + } if(io->fl == write_flags) memset(io->buf, '\0', io->bs);