summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/ftell.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-08-31 14:11:14 +0000
committerache <ache@FreeBSD.org>2001-08-31 14:11:14 +0000
commitef96044374af37896b3d0581d9f4d0f245b18587 (patch)
treea2d1a1b9254a7815b37cbf9e719ce4cd5e0843f5 /lib/libc/stdio/ftell.c
parentd4e4fe55ba1f2260686035864158f84af99abac6 (diff)
downloadFreeBSD-src-ef96044374af37896b3d0581d9f4d0f245b18587.zip
FreeBSD-src-ef96044374af37896b3d0581d9f4d0f245b18587.tar.gz
If file offset is smaller than internal buffer character left count, just drop
internal buffer and trust offset, not return error.
Diffstat (limited to 'lib/libc/stdio/ftell.c')
-rw-r--r--lib/libc/stdio/ftell.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/libc/stdio/ftell.c b/lib/libc/stdio/ftell.c
index 46a309c..33184c5 100644
--- a/lib/libc/stdio/ftell.c
+++ b/lib/libc/stdio/ftell.c
@@ -75,7 +75,7 @@ off_t
ftello(fp)
register FILE *fp;
{
- register fpos_t pos;
+ register fpos_t pos, spos;
size_t n;
if (fp->_seek == NULL) {
@@ -103,6 +103,7 @@ ftello(fp)
* those from ungetc) cause the position to be
* smaller than that in the underlying object.
*/
+ spos = pos;
pos -= fp->_r;
if (pos < 0) {
if (HASUB(fp)) {
@@ -110,9 +111,9 @@ ftello(fp)
fp->_r += pos;
pos = 0;
} else {
- errno = EBADF;
- FUNLOCKFILE(fp);
- return (-1);
+ fp->_p = fp->_bf._base;
+ fp->_r = 0;
+ pos = spos;
}
}
if (HASUB(fp)) {
@@ -123,9 +124,10 @@ ftello(fp)
fp->_r += pos;
pos = 0;
} else {
- errno = EBADF;
- FUNLOCKFILE(fp);
- return (-1);
+ fp->_p = fp->_bf._base;
+ fp->_r = 0;
+ FREEUB(fp);
+ pos = spos;
}
}
}
OpenPOWER on IntegriCloud