diff options
Diffstat (limited to 'lib/libc/stdio/rewind.c')
-rw-r--r-- | lib/libc/stdio/rewind.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libc/stdio/rewind.c b/lib/libc/stdio/rewind.c index c4de2c1..af9232a 100644 --- a/lib/libc/stdio/rewind.c +++ b/lib/libc/stdio/rewind.c @@ -52,9 +52,13 @@ static const char rcsid[] = void rewind(FILE *fp) { + /* make sure stdio is set up */ + if (!__sdidinit) + __sinit(); + FLOCKFILE(fp); - (void) _fseeko(fp, (off_t)0, SEEK_SET); - clearerr(fp); + if (_fseeko(fp, (off_t)0, SEEK_SET, 1) == 0) + clearerr_unlocked(fp); FUNLOCKFILE(fp); - errno = 0; /* not required, but seems reasonable */ + /* errno required by POSIX to sense error, don't zero it here */ } |