Commit 736020b4 by Jason Merrill Committed by Jason Merrill

fstream.tcc (basic_filebuf::seekoff): Fix for output-only filebufs.

        * include/bits/fstream.tcc (basic_filebuf::seekoff): Fix for
        output-only filebufs.
        * include/std/std_fstream.h (basic_filebuf::_M_set_indeterminate):
        Likewise.
        (basic_filebuf::_M_set_determinate): Likewise.

From-SVN: r52685
parent 74c263af
2002-04-23 Jason Merrill <jason@redhat.com> 2002-04-23 Jason Merrill <jason@redhat.com>
* include/bits/fstream.tcc (basic_filebuf::seekoff): Fix for
output-only filebufs.
* include/std/std_fstream.h (basic_filebuf::_M_set_indeterminate):
Likewise.
(basic_filebuf::_M_set_determinate): Likewise.
PR libstdc++/6414 PR libstdc++/6414
* include/bits/fstream.tcc (basic_filebuf::seekoff): Adjust return * include/bits/fstream.tcc (basic_filebuf::seekoff): Adjust return
value properly in the trivial case. value properly in the trivial case.
......
...@@ -567,7 +567,7 @@ namespace std ...@@ -567,7 +567,7 @@ namespace std
else else
{ {
__ret = _M_file.seekoff(__off, ios_base::cur, __mode); __ret = _M_file.seekoff(__off, ios_base::cur, __mode);
__ret += _M_in_cur - _M_filepos; __ret += max(_M_out_cur, _M_in_cur) - _M_filepos;
} }
} }
_M_last_overflowed = false; _M_last_overflowed = false;
......
...@@ -264,7 +264,7 @@ namespace std ...@@ -264,7 +264,7 @@ namespace std
this->setg(_M_buf, _M_buf, _M_buf); this->setg(_M_buf, _M_buf, _M_buf);
if (_M_mode & ios_base::out) if (_M_mode & ios_base::out)
this->setp(_M_buf, _M_buf); this->setp(_M_buf, _M_buf);
_M_filepos = _M_in_end; _M_filepos = _M_buf;
} }
void void
...@@ -276,7 +276,7 @@ namespace std ...@@ -276,7 +276,7 @@ namespace std
this->setg(_M_buf, _M_buf, _M_buf + __off); this->setg(_M_buf, _M_buf, _M_buf + __off);
if (__testout) if (__testout)
this->setp(_M_buf, _M_buf + __off); this->setp(_M_buf, _M_buf + __off);
_M_filepos = _M_in_end; _M_filepos = _M_buf + __off;
} }
bool bool
......
...@@ -167,6 +167,13 @@ void test04(void) ...@@ -167,6 +167,13 @@ void test04(void)
pos06 = is03.tellp(); pos06 = is03.tellp();
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 #ifdef DEBUG_ASSERT
assert(test); assert(test);
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment