Any idea what caused it? I've gone through the recent history
of the function and this looks like the likely change might
be this one:
http://svn.apache.org/viewvc?view=rev&revision=442675
but the test wasn't failing. Maybe because the test doesn't
cause the buffer to reallocate?
Martin
[EMAIL PROTECTED] wrote:
Author: faridz
Date: Tue Mar 25 07:33:02 2008
New Revision: 640831
URL: http://svn.apache.org/viewvc?rev=640831&view=rev
Log:
2008-03-25 Farid Zaripov <[EMAIL PROTECTED]>
STDCXX-792
* include/sstream.cc (str): Save pptr and restore is at the end if
str() is called with internal buffer to increase the capacity of
buffer (i.e. from xsputn() or overflow()).
(xsputn): Remove fix for STDCXX-515 because the pptr now is
preserved in str().
Modified:
stdcxx/trunk/include/sstream.cc
Modified: stdcxx/trunk/include/sstream.cc
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/include/sstream.cc?rev=640831&r1=640830&r2=640831&view=diff
==============================================================================
--- stdcxx/trunk/include/sstream.cc (original)
+++ stdcxx/trunk/include/sstream.cc Tue Mar 25 07:33:02 2008
@@ -82,8 +82,10 @@
_ValueAlloc __alloc;
// new buffer and size
- char_type *__buf;
- _RWSTD_SIZE_T __bufsize = __slen;
+ char_type *__buf;
+ _RWSTD_SIZE_T __bufsize = __slen;
+ // saved offset of pptr
+ _RWSTD_STREAMSIZE __off = -1;
if (__s == this->_C_buffer) {
// special case: str(_C_buffer, _C_bufsize + N) called
@@ -94,6 +96,8 @@
// set `slen' to the number of initialized characters
// in the buffer
__slen = this->egptr () - this->pbase ();
+ // save the offset of pptr
+ __off = this->pptr () - this->pbase ();
}
if (this->_C_bufsize < __bufsize) {
@@ -166,8 +170,12 @@
if (this->_C_is_out ()) {
this->setp (this->_C_buffer, this->_C_buffer + this->_C_bufsize);
- if ( __s != __buf && this->_C_state & ios_base::in
- || this->_C_state & (ios_base::app | ios_base::ate)) {
+ if (0 <= __off) {
+ // restore the pptr
+ this->pbump (__off);
+ }
+ else if ( this->_C_state & ios_base::in
+ || this->_C_state & (ios_base::app | ios_base::ate)) {
// in input or append/ate modes seek to end
// (see also lwg issue 562 for clarification)
this->pbump (__slen);
@@ -204,15 +212,9 @@
__off = this->pbase () - __s;
}
- // preserve current pptr() since str() would seek to end
- const streamsize __cur = this->pptr () - this->pbase ();
-
// grow the buffer if necessary to accommodate the whole
// string plus the contents of the buffer up to pptr()
str (this->_C_buffer, __bufsize);
-
- // restore pptr()
- this->pbump (__cur - (this->pptr () - this->pbase ()));
_RWSTD_ASSERT (__n <= this->epptr () - this->pptr ());