diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 2001-08-30 20:49:47 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 2001-08-30 20:49:47 +0000 |
| commit | 57935eeb3db88d457a4cf191698c1eda65f1bc2e (patch) | |
| tree | b5233f91f9af0f77f51575cc524e26be94066702 /lib/libc/stdio/fseek.c | |
| parent | 77f71bc5aca018193a57bbb8d9fbcc53eb30ada1 (diff) | |
Notes
Diffstat (limited to 'lib/libc/stdio/fseek.c')
| -rw-r--r-- | lib/libc/stdio/fseek.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c index aa886d2d28ab..8af60ba2a761 100644 --- a/lib/libc/stdio/fseek.c +++ b/lib/libc/stdio/fseek.c @@ -151,8 +151,14 @@ _fseeko(fp, offset, whence, ltest) if (HASUB(fp)) { curoff -= fp->_ur; if (curoff < 0) { - errno = EBADF; - return (-1); + if (-curoff <= fp->_r) { + fp->_p -= curoff; + fp->_r += curoff; + curoff = 0; + } else { + errno = EBADF; + return (-1); + } } } } else if ((fp->_flags & __SWR) && fp->_p != NULL) { @@ -261,8 +267,14 @@ _fseeko(fp, offset, whence, ltest) } if (HASUB(fp)) { curoff -= fp->_ur; - if (curoff < 0) - goto dumb; + if (curoff < 0) { + if (-curoff <= fp->_r) { + fp->_p -= curoff; + fp->_r += curoff; + curoff = 0; + } else + goto dumb; + } } } |
