summaryrefslogtreecommitdiff
path: root/libc/stdio
diff options
context:
space:
mode:
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/stdio.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index 01588aaeb..e67408d12 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -588,15 +588,16 @@ int fseek(FILE *fp, long int offset, int ref)
--offset; /* adjust offset (clear flag below). */
}
}
- fp->bufpos = fp->bufread = fp->bufstart;
}
if ((fp->mode & __MODE_ERR) ||
(((ref != SEEK_CUR) || offset) && (lseek(fp->fd, offset, ref) < 0))) {
- fp->mode |= __MODE_ERR; /* Possibly redundant, but doesn't hurt. */
return -1;
}
+ if (READING(fp)) {
+ fp->bufpos = fp->bufread = fp->bufstart;
+ }
fp->mode &= ~(__MODE_EOF | __MODE_UNGOT);
return 0;