From ca2ac3d32102377ff62aa99810874752c46a4061 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sun, 3 Oct 2004 16:28:16 +0000 Subject: 2004-10-03 Paolo Carlini Merged to mainline at tag libstdcxx_so_7-merge-20041003. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/libstdcxx_so_7-branch@88456 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/include/std/std_sstream.h | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'libstdc++-v3/include/std') diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h index 6b5728b94ce..3420999164c 100644 --- a/libstdc++-v3/include/std/std_sstream.h +++ b/libstdc++-v3/include/std/std_sstream.h @@ -111,8 +111,8 @@ namespace std */ explicit basic_stringbuf(ios_base::openmode __mode = ios_base::in | ios_base::out) - : __streambuf_type(), _M_mode(), _M_string() - { _M_stringbuf_init(__mode); } + : __streambuf_type(), _M_mode(__mode), _M_string() + { } /** * @brief Starts with an existing string buffer. @@ -140,8 +140,7 @@ namespace std __string_type str() const { - const bool __testout = this->_M_mode & ios_base::out; - if (__testout) + if (this->pptr()) { // The current egptr() may not be the actual string end. if (this->pptr() > this->egptr()) @@ -169,7 +168,7 @@ namespace std } protected: - // Common initialization code for both ctors goes here. + // Common initialization code goes here. /** * @if maint * @doctodo @@ -220,7 +219,7 @@ namespace std // things will quickly blow up. // Step 1: Destroy the current internal array. - _M_string = __string_type(__s, __n); + _M_string.assign(__s, __n); // Step 2: Use the external array. _M_sync(__s, 0, 0); @@ -254,20 +253,19 @@ namespace std { const bool __testin = this->_M_mode & ios_base::in; const bool __testout = this->_M_mode & ios_base::out; - const __size_type __len = _M_string.size(); + char_type* __end = __base + _M_string.size(); if (__testin) - this->setg(__base, __base + __i, __base + __len); + this->setg(__base, __base + __i, __end); if (__testout) { this->setp(__base, __base + _M_string.capacity()); this->pbump(__o); - // We need a pointer to the string end anyway, even when - // !__testin: in that case, however, for the correct - // functioning of the streambuf inlines all the get area - // pointers must be identical. + // egptr() always tracks the string end. When !__testin, + // for the correct functioning of the streambuf inlines + // the other get area pointers are identical. if (!__testin) - this->setg(__base + __len, __base + __len, __base + __len); + this->setg(__end, __end, __end); } } @@ -277,9 +275,8 @@ namespace std _M_update_egptr() { const bool __testin = this->_M_mode & ios_base::in; - const bool __testout = this->_M_mode & ios_base::out; - if (__testout && this->pptr() > this->egptr()) + if (this->pptr() && this->pptr() > this->egptr()) if (__testin) this->setg(this->eback(), this->gptr(), this->pptr()); else -- cgit v1.2.3