aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-07-24 09:35:24 +0000
committerRoland McGrath <roland@gnu.org>2002-07-24 09:35:24 +0000
commit7e93f91553018f1e24c3610da694a51ffb7f7021 (patch)
tree493a8b80421bb175a8494b28fbd1c69f39fb213c /libio
parent0e94c2176b7fe55c8df404697b538652ef342951 (diff)
downloadglibc-7e93f91553018f1e24c3610da694a51ffb7f7021.zip
glibc-7e93f91553018f1e24c3610da694a51ffb7f7021.tar.gz
glibc-7e93f91553018f1e24c3610da694a51ffb7f7021.tar.bz2
* libio/fileops.c (_IO_file_seekoff_mmap): When just examining the
position, calculate it to take into account an active pushback buffer. * libio/Makefile (tests): Add bug-ungetc. * libio/bug-ungetc.c: New file.
Diffstat (limited to 'libio')
-rw-r--r--libio/fileops.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libio/fileops.c b/libio/fileops.c
index 2079495..fa4c8e0 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -922,8 +922,12 @@ _IO_file_seekoff_mmap (fp, offset, dir, mode)
{
_IO_off64_t result;
+ /* If we are only interested in the current position, calculate it and
+ return right now. This calculation does the right thing when we are
+ using a pushback buffer, but in the usual case has the same value as
+ (fp->_IO_read_ptr - fp->_IO_buf_base). */
if (mode == 0)
- dir = _IO_seek_cur, offset = 0; /* Don't move any pointers. */
+ return fp->_offset - (fp->_IO_read_end - fp->_IO_read_ptr);
switch (dir)
{
@@ -943,10 +947,6 @@ _IO_file_seekoff_mmap (fp, offset, dir, mode)
/* No negative offsets are valid. */
return EOF;
- /* If we are only interested in the current position we've found it now. */
- if (mode == 0)
- return offset;
-
result = _IO_SYSSEEK (fp, offset, 0);
if (result < 0)
return EOF;