OSDN Git Service

* include/bits/fstream.tcc (basic_filebuf::seekoff): Fix for
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Apr 2002 21:56:10 +0000 (21:56 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Apr 2002 21:56:10 +0000 (21:56 +0000)
        output-only filebufs.
        * include/std/std_fstream.h (basic_filebuf::_M_set_indeterminate):
        Likewise.
        (basic_filebuf::_M_set_determinate): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52685 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/std/std_fstream.h
libstdc++-v3/testsuite/27_io/ostream_seeks.cc

index c3667b9..bc89207 100644 (file)
@@ -1,5 +1,11 @@
 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
        * include/bits/fstream.tcc (basic_filebuf::seekoff): Adjust return
        value properly in the trivial case.
index c530f34..6019cd1 100644 (file)
@@ -567,7 +567,7 @@ namespace std
          else
            {
              __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;      
index c0d80da..0b20df1 100644 (file)
@@ -264,7 +264,7 @@ namespace std
          this->setg(_M_buf, _M_buf, _M_buf);
        if (_M_mode & ios_base::out)
          this->setp(_M_buf, _M_buf);
-       _M_filepos = _M_in_end;
+       _M_filepos = _M_buf;
       }
 
       void
@@ -276,7 +276,7 @@ namespace std
          this->setg(_M_buf, _M_buf, _M_buf + __off);
        if (__testout)
          this->setp(_M_buf, _M_buf + __off);
-       _M_filepos = _M_in_end;
+       _M_filepos = _M_buf + __off;
       }
 
       bool
index 7022a2f..5afc675 100644 (file)
@@ -167,6 +167,13 @@ void test04(void)
   pos06 = is03.tellp(); 
   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);
 #endif