This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[Ptach] Remove the obsolete _M_underflow trick


Hi,

this all started with the following obsolete comment in std_fstream.h:

 // The only difference between underflow() and uflow() is that the
 // latter bumps _M_in_cur after the read.  In the sync_with_stdio
 // case, this is important, as we need to unget the read character in
 // the underflow() case in order to maintain synchronization.  So
 // instead of calling underflow() from uflow(), we create a common
 // subroutine to do the real work.

I wanted to just fix it but then I realized that we don't have anymore
any reason to use the machinery both in filebuf and in stringbuf (where,
my bad, I have blindly introduced it recently, in the rush for the
_M_out_lim removal work).

Thus the below, which basically has filebuf and stringbuf providing only
underflow, and uflow (defined in terms of underflow) provided by
streambuf. Seems a nice clean up.

Tested x86-linux.

Anyone objecting to it? Otherwise will commit, say, on monday

Paolo.

/////////
2003-06-28  Paolo Carlini  <pcarlini@unitus.it>

	* include/std/std_fstream.h (_M_underflow): Remove.
	(uflow): Remove, inherited from streambuf.
	(underflow): Only declare.
	* include/bits/fstream.tcc (_M_underflow): Rename to 
	underflow, to which is equivalent for __bump == false,
	simplify.
	* include/std/std_sstream.h (_M_underflow): Remove.
	(uflow): Remove, inherited from streambuf.
	(underflow): Only declare.
	* include/bits/sstream.tcc (_M_underflow): Rename to 
	underflow, to which is equivalent for __bump == false,
	simplify.
diff -urN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
--- libstdc++-v3-orig/include/bits/fstream.tcc	2003-06-27 20:28:53.000000000 +0200
+++ libstdc++-v3/include/bits/fstream.tcc	2003-06-28 22:18:41.000000000 +0200
@@ -180,7 +180,7 @@
   template<typename _CharT, typename _Traits>
     typename basic_filebuf<_CharT, _Traits>::int_type 
     basic_filebuf<_CharT, _Traits>::
-    _M_underflow(bool __bump)
+    underflow()
     {
       int_type __ret = traits_type::eof();
       const bool __testin = this->_M_mode & ios_base::in;
@@ -194,12 +194,7 @@
 	  _M_destroy_pback();
 
 	  if (this->gptr() < this->egptr())
-	    {
-	      __ret = traits_type::to_int_type(*this->gptr());
-	      if (__bump)
-		this->gbump(1);
-	      return __ret;
-	    }
+	    return traits_type::to_int_type(*this->gptr());
 
 	  // Get and convert input sequence.
 	  const size_t __buflen = this->_M_buf_size > 1
@@ -247,8 +242,6 @@
 	      _M_set_buffer(__ilen);
 	      _M_reading = true;
 	      __ret = traits_type::to_int_type(*this->gptr());
-	      if (__bump)
-		this->gbump(1);
 	    }
 	  else if (__elen == 0)
 	    {
diff -urN libstdc++-v3-orig/include/bits/sstream.tcc libstdc++-v3/include/bits/sstream.tcc
--- libstdc++-v3-orig/include/bits/sstream.tcc	2003-06-22 20:37:09.000000000 +0200
+++ libstdc++-v3/include/bits/sstream.tcc	2003-06-28 22:19:25.000000000 +0200
@@ -115,7 +115,7 @@
   template <class _CharT, class _Traits, class _Alloc>
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type 
     basic_stringbuf<_CharT, _Traits, _Alloc>::
-    _M_underflow(bool __bump)
+    underflow()
     {
       int_type __ret = traits_type::eof();
       const bool __testin = this->_M_mode & ios_base::in;
@@ -125,11 +125,7 @@
 	  _M_update_egptr();
 
 	  if (this->gptr() < this->egptr())
-	    {
-	      __ret = traits_type::to_int_type(*this->gptr());
-	      if (__bump)
-		this->gbump(1);
-	    }
+	    __ret = traits_type::to_int_type(*this->gptr());
 	}
       return __ret;
     }
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-06-24 15:48:09.000000000 +0200
+++ libstdc++-v3/include/std/std_fstream.h	2003-06-28 22:22:47.000000000 +0200
@@ -281,29 +281,9 @@
       // charater from the real input source when the buffer is empty.
       // Buffered input uses underflow()
 
-      // The only difference between underflow() and uflow() is that the
-      // latter bumps _M_in_cur after the read.  In the sync_with_stdio
-      // case, this is important, as we need to unget the read character in
-      // the underflow() case in order to maintain synchronization.  So
-      // instead of calling underflow() from uflow(), we create a common
-      // subroutine to do the real work.
-      /**
-       *  @if maint
-       *  @doctodo
-       *  @endif
-      */
-      int_type
-      _M_underflow(bool __bump);
-
-      // [documentation is inherited]
-      virtual int_type
-      underflow()
-      { return _M_underflow(false); }
-
       // [documentation is inherited]
       virtual int_type
-      uflow()
-      { return _M_underflow(true); }
+      underflow();
 
       // [documentation is inherited]
       virtual int_type
diff -urN libstdc++-v3-orig/include/std/std_sstream.h libstdc++-v3/include/std/std_sstream.h
--- libstdc++-v3-orig/include/std/std_sstream.h	2003-06-22 20:37:10.000000000 +0200
+++ libstdc++-v3/include/std/std_sstream.h	2003-06-28 22:22:35.000000000 +0200
@@ -179,18 +179,9 @@
 	_M_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
       }
 
-      int_type
-      _M_underflow(bool __bump);
-
-      // [documentation is inherited]
-      virtual int_type
-      underflow()
-      { return _M_underflow(false); }
-
       // [documentation is inherited]
       virtual int_type
-      uflow()
-      { return _M_underflow(true); }
+      underflow();
 
       // [documentation is inherited]
       virtual int_type

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]