From 65eee187317b93773d2409d0e7e2814d34c6a0e1 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Tue, 25 Sep 2001 19:39:46 +0000 Subject: Fix fseek behavior. --- libc/stdio/stdio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libc/stdio/stdio.c') 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; -- cgit v1.2.3