std_fstream.h (_S_pback_size): Remove definition.
authorPaolo Carlini <pcarlini@unitus.it>
Thu, 22 May 2003 22:16:41 +0000 (00:16 +0200)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 22 May 2003 22:16:41 +0000 (22:16 +0000)
2003-05-22  Paolo Carlini  <pcarlini@unitus.it>

* include/std/std_fstream.h (_S_pback_size): Remove definition.
(_M_create_pback(), _M_destroy_pback()): Simplify for a single-char
pback buffer.
* include/bits/fstream.tcc (_S_pback_size): Remove declaration.
* testsuite/27_io/basic_filebuf/3.cc: Remove explicit instantiation
of _S_pback_size for systems with no COMDAT or weak support.
* testsuite/27_io/basic_filebuf/seekoff/10132-2.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/10132-3.cc: Likewise.
* testsuite/27_io/basic_filebuf/underflow/10096.cc: Likewise.
* testsuite/27_io/basic_fstream/3.cc: Likewise.
* testsuite/27_io/basic_ifstream/3.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc: Likewise.
* testsuite/27_io/basic_ofstream/3.cc: Likewise.
* testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc: Likewise.
* testsuite/27_io/basic_streambuf/3.cc: Likewise.

From-SVN: r67102

13 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/std/std_fstream.h
libstdc++-v3/testsuite/27_io/basic_filebuf/3.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc
libstdc++-v3/testsuite/27_io/basic_fstream/3.cc
libstdc++-v3/testsuite/27_io/basic_ifstream/3.cc
libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc
libstdc++-v3/testsuite/27_io/basic_ofstream/3.cc
libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc
libstdc++-v3/testsuite/27_io/basic_streambuf/3.cc

index 29f972cbb2e2b1f7c3c0337d2c706c84e1914410..28cee922693d1eaf8fd5c90e2c8e103e96788bf2 100644 (file)
@@ -1,6 +1,24 @@
 2003-05-22  Paolo Carlini  <pcarlini@unitus.it>
 
-       * include/bits/fstream.tcc (_M_underflow): simplify:
+       * include/std/std_fstream.h (_S_pback_size): Remove definition.
+       (_M_create_pback(), _M_destroy_pback()): Simplify for a single-char
+       pback buffer.
+       * include/bits/fstream.tcc (_S_pback_size): Remove declaration.
+       * testsuite/27_io/basic_filebuf/3.cc: Remove explicit instantiation
+       of _S_pback_size for systems with no COMDAT or weak support.
+       * testsuite/27_io/basic_filebuf/seekoff/10132-2.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/seekpos/10132-3.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/underflow/10096.cc: Likewise.
+       * testsuite/27_io/basic_fstream/3.cc: Likewise.
+       * testsuite/27_io/basic_ifstream/3.cc: Likewise.
+       * testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc: Likewise.
+       * testsuite/27_io/basic_ofstream/3.cc: Likewise.
+       * testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc: Likewise.
+       * testsuite/27_io/basic_streambuf/3.cc: Likewise.
+
+2003-05-22  Paolo Carlini  <pcarlini@unitus.it>
+
+       * include/bits/fstream.tcc (_M_underflow): Simplify:
        !__testout implies _M_filepos == _M_in_end, therefore
        the first _M_file.seekoff call is never issued.
 
index 0aa93fef7bb63f8e054a6915499a0bfe3b1f85b7..cda0bacd9f9cf7f7f711b1ca9081edfcd17834fb 100644 (file)
 
 namespace std
 {
-  template<typename _CharT, typename _Traits>
-    const size_t
-    basic_filebuf<_CharT, _Traits>::_S_pback_size;
-
   template<typename _CharT, typename _Traits>
     void
     basic_filebuf<_CharT, _Traits>::
index 24c9f7fc6db98fe2af13cdb359c8946f24125151..27794881c75d5e1e7b491df70b6dabdfa3a3c86c 100644 (file)
@@ -158,8 +158,7 @@ namespace std
        *  @note pbacks of over one character are not currently supported.
        *  @endif
       */
-      static const size_t      _S_pback_size = 1; 
-      char_type                        _M_pback[_S_pback_size]; 
+      char_type                        _M_pback[1]; 
       char_type*               _M_pback_cur_save;
       char_type*               _M_pback_end_save;
       bool                     _M_pback_init; 
@@ -176,12 +175,9 @@ namespace std
       {
        if (!_M_pback_init)
          {
-           size_t __dist = this->_M_in_end - this->_M_in_cur;
-           size_t __len = std::min(_S_pback_size, __dist);
-           traits_type::copy(_M_pback, this->_M_in_cur, __len);
            _M_pback_cur_save = this->_M_in_cur;
            _M_pback_end_save = this->_M_in_end;
-           this->setg(_M_pback, _M_pback, _M_pback + __len);
+           this->setg(_M_pback, _M_pback, _M_pback + 1);
            _M_pback_init = true;
          }
       }
@@ -195,17 +191,9 @@ namespace std
        if (_M_pback_init)
          {
            // Length _M_in_cur moved in the pback buffer.
-           size_t __off_cur = this->_M_in_cur - _M_pback;
-           
-           // For in | out buffers, the end can be pushed back...
-           size_t __off_end = 0;
-           size_t __pback_len = this->_M_in_end - _M_pback;
-           size_t __save_len = _M_pback_end_save - this->_M_buf;
-           if (__pback_len > __save_len)
-             __off_end = __pback_len - __save_len;
-
+           const size_t __off_cur = this->_M_in_cur - _M_pback;
            this->setg(this->_M_buf, _M_pback_cur_save + __off_cur, 
-                      _M_pback_end_save + __off_end);
+                      _M_pback_end_save);
            _M_pback_init = false;
          }
       }
index ddec01c02e312d5c69057168b712343690af665d..54cfba150bd801ab3ad26362d2b529f92ef29f33 100644 (file)
@@ -127,13 +127,6 @@ void test07()
     }
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<gnu_char_type>::int_type
-  std::basic_filebuf<gnu_char_type>::_S_pback_size;
-#endif
-
 int main() 
 {
   test07();
index e1628c4a8844fc6b03d05e892b04fc2a2bb537fb..a391d22fc033c37b430a7f9836edc4b32d955f63 100644 (file)
@@ -129,13 +129,6 @@ void test07()
     }
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<gnu_char_type>::int_type
-  std::basic_filebuf<gnu_char_type>::_S_pback_size;
-#endif
-
 int main() 
 {
   test07();
index 0f1ee2e1d6148d196cf311b5309cf94f00e47583..02f7b67047cd685b64e1dc154ee9d09745d0c8a2 100644 (file)
@@ -129,13 +129,6 @@ void test07()
     }
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<gnu_char_type>::int_type
-  std::basic_filebuf<gnu_char_type>::_S_pback_size;
-#endif
-
 int main() 
 {
   test07();
index 588a625e4757d50b46281b343e209a452ff27726..8dd24343f2e9d8a8cff43623b3f75478e0f01dd4 100644 (file)
@@ -63,13 +63,6 @@ void test01()
   VERIFY( fb.sgetc() == MyTraits::eof() );
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<char, MyTraits>::int_type
-  std::basic_filebuf<char, MyTraits>::_S_pback_size;
-#endif
-
 int main()
 {
   test01();
index 216e9a2621650f898e5d0893ff9454c5e4d5b601..4f78ed0d19395a8b6cf0da7d5b1d97dc1ef4dd5a 100644 (file)
@@ -131,13 +131,6 @@ void test07()
     }
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<gnu_char_type>::int_type
-  std::basic_filebuf<gnu_char_type>::_S_pback_size;
-#endif
-
 int main() 
 {
   test07();
index 9de0c62a0197f00a24475b4136fdfc24c4fdd1f9..dd38b252c656b57761155da29c070693fe42e33b 100644 (file)
@@ -131,13 +131,6 @@ void test07()
     }
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<gnu_char_type>::int_type
-  std::basic_filebuf<gnu_char_type>::_S_pback_size;
-#endif
-
 int main() 
 {
   test07();
index c70275745ceb46a5bba5e347b523ccba31691285..99dd0b09bc17122921b647239ecbeb4a8854e027 100644 (file)
@@ -180,10 +180,6 @@ template
 template 
   unsigned char
   std::basic_string<unsigned char>::_Rep::_S_terminal;
-
-template
-  std::basic_filebuf<unsigned char>::int_type
-  std::basic_filebuf<unsigned char>::_S_pback_size;
 #endif
 
 int main()
index 5149ecd55807c479e25e73c26723456e45d253fc..3bba780a4c6b0b6b79655063ece3073262bcca9e 100644 (file)
@@ -131,13 +131,6 @@ void test07()
     }
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<gnu_char_type>::int_type
-  std::basic_filebuf<gnu_char_type>::_S_pback_size;
-#endif
-
 int main() 
 {
   test07();
index a38bddc162b114998637d894bfb50d2f8f1a3faa..3cdf3b833102052a627ed1342a81f89a41a3a8cc 100644 (file)
@@ -151,10 +151,6 @@ template
 template 
   unsigned char
   std::basic_string<unsigned char>::_Rep::_S_terminal;
-
-template
-  std::basic_filebuf<unsigned char>::int_type
-  std::basic_filebuf<unsigned char>::_S_pback_size;
 #endif
 
 int main()
index 36e5290540d941b06ee36852238fc552b2be4e2f..c599985d43f299974a9428aa3e05ee173e4db64c 100644 (file)
@@ -129,13 +129,6 @@ void test07()
     }
 }
 
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_filebuf<gnu_char_type>::int_type
-  std::basic_filebuf<gnu_char_type>::_S_pback_size;
-#endif
-
 int main() 
 {
   test07();