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]

[RFC] Are we going to support multiple pbacks in the near future?


Hi,

I'm looking at _M_create_pback and _M_destroy_pback and
definitely they can be simplified considerably if we are
not going to support more than one putback in the near
future (indeed, according to at least one party, this is not
really important).

What do you all think?

To explain more concretely what I mean, I'm attaching a
**preliminary** patch which already passes make check and
some other sanity checks.

Paolo.

////////
--- std_fstream.h.~1.39.~	2003-05-21 22:05:58.000000000 +0200
+++ std_fstream.h	2003-05-22 20:00:22.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;
 	  }
       }

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