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] Sadly, revert the best of basic_stringbuf::str() commit


Hi,

unfortunately, due to the COW nature of v3 basic_string
my previous improvement is incorrect, as revealed by the
failure of 27_io/basic_stringbuf/sputn/char/1.cc, which,
for some reason I didn't notice here (thanks Phil!). We
can only simplify a bit the code...

Also, fix a signed-unsigned warning elsewhere.

Tested x86-linux.

Paolo.

////////
2003-05-01  Paolo Carlini  <pcarlini@unitus.it>

	* include/std/std_sstream.h (str()): Revert the best of the
	previous 'improvement', incorrect due to the COW nature of
	v3 basic_string; simplify.
2003-05-01  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/streambuf.tcc (__copy_streambufs): Adjust the
	type of __avail to ptrdiff_t to avoid signed-unsigned warning.
--- std_sstream.h.orig	2003-05-02 00:39:15.000000000 +0200
+++ std_sstream.h	2003-05-02 01:09:04.000000000 +0200
@@ -136,14 +136,9 @@
 	__string_type __ret = _M_string;
 	if (this->_M_mode & ios_base::out)
 	  {
-	    // This is the deal: _M_string.size() is a value that
-	    // represents the size of the initial string used to
-	    // created the buffer, and may not be the correct size of
-	    // the current stringbuf internal buffer.
-	    const __size_type __len = _M_string.size();
 	    const __size_type __nlen = this->_M_out_lim
-	                               - this->_M_out_beg;
-	    if (__nlen > __len)
+                                       - this->_M_out_beg;
+	    if (__nlen)
 	      __ret = __string_type(this->_M_out_beg, 
 				    this->_M_out_beg + __nlen);
 	  }
--- streambuf.tcc.~1.36.~	2003-05-01 12:23:29.000000000 +0200
+++ streambuf.tcc	2003-05-02 00:25:55.000000000 +0200
@@ -192,8 +192,8 @@
 	  for (;;)
   	    {
 	      streamsize __xtrct;
-	      const size_t __avail = __sbin->_M_in_end
-		                     - __sbin->_M_in_cur;
+	      const ptrdiff_t __avail = __sbin->_M_in_end
+		                        - __sbin->_M_in_cur;
  	      if (__avail)
 		{
 		  __xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail);

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