summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2001-09-02 21:22:00 +0000
committerache <ache@FreeBSD.org>2001-09-02 21:22:00 +0000
commiteb6143a73ea359a277c4ff8df2ea68bbd4569ab4 (patch)
tree56b8a450e69d2c121691ed5706cfdd97b48def32
parent7de8ea47fb3b4ae8bb2dc3673a95dae660d651de (diff)
downloadFreeBSD-src-eb6143a73ea359a277c4ff8df2ea68bbd4569ab4.zip
FreeBSD-src-eb6143a73ea359a277c4ff8df2ea68bbd4569ab4.tar.gz
Internal seeks are overoptimized. They should remember fp->_offset only for
plain regular files, i.e. files with __SOPT flag set. Fix it, so ftell(stdout) always returns the same as lseek(1, 0, 1) now. NOTE: this bug was in original stdio code
-rw-r--r--lib/libc/stdio/fopen.c2
-rw-r--r--lib/libc/stdio/fseek.c2
2 files changed, 1 insertions, 3 deletions
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c
index 709316d..84989ae 100644
--- a/lib/libc/stdio/fopen.c
+++ b/lib/libc/stdio/fopen.c
@@ -69,8 +69,6 @@ fopen(file, mode)
}
fp->_file = f;
fp->_flags = flags;
- fp->_flags |= __SOFF;
- fp->_offset = 0;
fp->_cookie = fp;
fp->_read = __sread;
fp->_write = __swrite;
diff --git a/lib/libc/stdio/fseek.c b/lib/libc/stdio/fseek.c
index 0cbf798..1f7ebde 100644
--- a/lib/libc/stdio/fseek.c
+++ b/lib/libc/stdio/fseek.c
@@ -344,7 +344,7 @@ _sseek(fp, offset, whence)
}
fp->_flags &= ~__SOFF;
ret = -1;
- } else {
+ } else if (fp->_flags & __SOPT) {
fp->_flags |= __SOFF;
fp->_offset = ret;
}
OpenPOWER on IntegriCloud