From eb6143a73ea359a277c4ff8df2ea68bbd4569ab4 Mon Sep 17 00:00:00 2001 From: ache Date: Sun, 2 Sep 2001 21:22:00 +0000 Subject: 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 --- lib/libc/stdio/fopen.c | 2 -- lib/libc/stdio/fseek.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/libc') 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; } -- cgit v1.1