From b4253f5d3cde3ddbf46695436953a89d977f07c1 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 23 Apr 2002 21:01:22 +0000 Subject: [PATCH] PR libstdc++/6414 * include/bits/fstream.tcc (basic_filebuf::seekoff): Adjust return value properly in the trivial case. * testsuite/27_io/istream_seeks.cc (test04): Make sure that tellg() returns the right value after a read. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52679 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 8 ++++++++ libstdc++-v3/include/bits/fstream.tcc | 2 +- libstdc++-v3/testsuite/27_io/istream_seeks.cc | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b69477b..c3667b9 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2002-04-23 Jason Merrill + + PR libstdc++/6414 + * include/bits/fstream.tcc (basic_filebuf::seekoff): Adjust return + value properly in the trivial case. + * testsuite/27_io/istream_seeks.cc (test04): Make sure that + tellg() returns the right value after a read. + 2002-04-23 Hans-Peter Nilsson * config/cpu/mmix/bits/cpu_limits.h: New file. diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc index 235b4a8..c530f34 100644 --- a/libstdc++-v3/include/bits/fstream.tcc +++ b/libstdc++-v3/include/bits/fstream.tcc @@ -567,7 +567,7 @@ namespace std else { __ret = _M_file.seekoff(__off, ios_base::cur, __mode); - __ret += max(_M_out_cur, _M_in_cur) - _M_buf; + __ret += _M_in_cur - _M_filepos; } } _M_last_overflowed = false; diff --git a/libstdc++-v3/testsuite/27_io/istream_seeks.cc b/libstdc++-v3/testsuite/27_io/istream_seeks.cc index dac5f3c..6574b0a 100644 --- a/libstdc++-v3/testsuite/27_io/istream_seeks.cc +++ b/libstdc++-v3/testsuite/27_io/istream_seeks.cc @@ -229,7 +229,14 @@ void test04(void) VERIFY( pos05 == pos06 + off_type(10) ); VERIFY( state01 == state02 ); pos06 = is03.tellg(); - VERIFY( pos05 == pos06 ); + VERIFY( pos05 == pos06 ); + + // libstdc++/6414 + if01.seekg(0, std::ios_base::beg); + pos01 = if01.tellg(); + if01.peek(); + pos02 = if01.tellg(); + VERIFY( pos02 == pos01 ); #ifdef DEBUG_ASSERT assert(test); -- 2.7.4