Author: faridz
Date: Thu Oct 4 05:13:09 2007
New Revision: 581871
URL: http://svn.apache.org/viewvc?rev=581871&view=rev
Log:
2007-10-04 Farid Zaripov <[EMAIL PROTECTED]>
STDCXX-576
* sstream.cc (xsputn): If __s is a part of the
internal buffer and buffer reallocation is needed,
save the offset of the __s from pbase() anc correct
__s value after the buffer reallocation.
Modified:
incubator/stdcxx/branches/4.2.0/include/sstream.cc
Modified: incubator/stdcxx/branches/4.2.0/include/sstream.cc
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/include/sstream.cc?rev=581871&r1=581870&r2=581871&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.0/include/sstream.cc (original)
+++ incubator/stdcxx/branches/4.2.0/include/sstream.cc Thu Oct 4 05:13:09 2007
@@ -185,6 +185,15 @@
const _RWSTD_SIZE_T __bufsize =
__n + (this->pptr () - this->pbase ());
+ _RWSTD_PTRDIFF_T __off = -1;
+
+ if (this->pbase () <= __s && this->pptr () > __s) {
+ // __s is a part of the buffer
+ _RWSTD_ASSERT (this->epptr () >= __s + __n);
+ // save the offset from pbase()
+ __off = this->pbase () - __s;
+ }
+
// preserve current pptr() since str() would seek to end
const streamsize __cur = this->pptr () - this->pbase ();
@@ -196,6 +205,11 @@
this->pbump (__cur - (this->pptr () - this->pbase ()));
_RWSTD_ASSERT (__n <= this->epptr () - this->pptr ());
+
+ if (0 <= __off) {
+ // correct __s after the buffer reallocation
+ __s = this->pbase () + __off;
+ }
}
// copy the whole string