summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2001-09-25 19:39:46 +0000
committerManuel Novoa III <mjn3@codepoet.org>2001-09-25 19:39:46 +0000
commit65eee187317b93773d2409d0e7e2814d34c6a0e1 (patch)
treef0d7b03a85a5d0abab91b505d43f129ccc4313c2 /libc
parent7cfcc4fce51ba4ac558ce5299e4eeba38d45d624 (diff)
Fix fseek behavior.
Diffstat (limited to 'libc')
-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;