Author: faridz
Date: Thu Oct 4 05:16:24 2007
New Revision: 581872
URL: http://svn.apache.org/viewvc?rev=581872&view=rev
Log:
2007-10-04 Farid Zaripov <[EMAIL PROTECTED]>
* Merged the head of branches/4.2.0
Modified:
incubator/stdcxx/trunk/include/sstream.cc
Modified: incubator/stdcxx/trunk/include/sstream.cc
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/include/sstream.cc?rev=581872&r1=581871&r2=581872&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/sstream.cc (original)
+++ incubator/stdcxx/trunk/include/sstream.cc Thu Oct 4 05:16:24 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