This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Clean up single char pback buffer


Hi,

tested x86-linux, reviewed by Benjamin.

Paolo.

///////
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.
diff -urN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
--- libstdc++-v3-orig/include/bits/fstream.tcc	2003-05-22 13:05:45.000000000 +0200
+++ libstdc++-v3/include/bits/fstream.tcc	2003-05-22 22:17:51.000000000 +0200
@@ -40,10 +40,6 @@
 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>::
     _M_allocate_internal_buffer()
diff -urN libstdc++-v3-orig/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
--- libstdc++-v3-orig/include/std/std_fstream.h	2003-05-21 22:05:58.000000000 +0200
+++ libstdc++-v3/include/std/std_fstream.h	2003-05-22 22:18:57.000000000 +0200
@@ -158,8 +158,7 @@
        *  @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 @@
       {
 	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 @@
 	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;
 	  }
       }
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/3.cc libstdc++-v3/testsuite/27_io/basic_filebuf/3.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_filebuf/3.cc	2003-04-24 00:34:49.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_filebuf/3.cc	2003-05-22 23:44:25.000000000 +0200
@@ -127,13 +127,6 @@
     }
 }
 
-#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();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc	2003-04-26 02:23:18.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/10132-2.cc	2003-05-22 23:44:46.000000000 +0200
@@ -129,13 +129,6 @@
     }
 }
 
-#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();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc	2003-04-26 02:23:18.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/10132-3.cc	2003-05-22 23:45:04.000000000 +0200
@@ -129,13 +129,6 @@
     }
 }
 
-#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();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/underflow/10096.cc libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_filebuf/underflow/10096.cc	2003-05-12 18:10:55.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc	2003-05-22 23:45:23.000000000 +0200
@@ -63,13 +63,6 @@
   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();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_fstream/3.cc libstdc++-v3/testsuite/27_io/basic_fstream/3.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_fstream/3.cc	2003-04-24 00:34:49.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_fstream/3.cc	2003-05-22 23:45:44.000000000 +0200
@@ -131,13 +131,6 @@
     }
 }
 
-#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();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_ifstream/3.cc libstdc++-v3/testsuite/27_io/basic_ifstream/3.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_ifstream/3.cc	2003-04-24 00:34:49.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_ifstream/3.cc	2003-05-22 23:46:03.000000000 +0200
@@ -131,13 +131,6 @@
     }
 }
 
-#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();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc	2003-04-24 00:34:50.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_istream/sentry/char/3983-fstream.cc	2003-05-22 23:46:43.000000000 +0200
@@ -180,10 +180,6 @@
 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()
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_ofstream/3.cc libstdc++-v3/testsuite/27_io/basic_ofstream/3.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_ofstream/3.cc	2003-04-24 00:34:50.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_ofstream/3.cc	2003-05-22 23:47:17.000000000 +0200
@@ -131,13 +131,6 @@
     }
 }
 
-#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();
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc	2003-04-24 00:34:50.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_ostream/sentry/char/3983-fstream.cc	2003-05-22 23:47:43.000000000 +0200
@@ -151,10 +151,6 @@
 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()
diff -urN libstdc++-v3-orig/testsuite/27_io/basic_streambuf/3.cc libstdc++-v3/testsuite/27_io/basic_streambuf/3.cc
--- libstdc++-v3-orig/testsuite/27_io/basic_streambuf/3.cc	2003-04-24 00:34:50.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_streambuf/3.cc	2003-05-22 23:48:08.000000000 +0200
@@ -129,13 +129,6 @@
     }
 }
 
-#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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]