aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2006-02-19 18:27:06 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2006-02-19 18:27:06 +0000
commit62448787ebfeba29c475b5713b97aaade1ce2243 (patch)
tree363e7e2ffa23a15ca68d5303ce41c5f2747038d7 /libstdc++-v3
parent4cf4d6a32328de2725c0ca4ca7a991b97ab5e46f (diff)
downloadgcc-62448787ebfeba29c475b5713b97aaade1ce2243.zip
gcc-62448787ebfeba29c475b5713b97aaade1ce2243.tar.gz
gcc-62448787ebfeba29c475b5713b97aaade1ce2243.tar.bz2
std_sstream.h (basic_stringbuf<>::setbuf): Simply clear the internal _M_string, adjust _M_sync call.
2006-02-19 Paolo Carlini <pcarlini@suse.de> * include/std/std_sstream.h (basic_stringbuf<>::setbuf): Simply clear the internal _M_string, adjust _M_sync call. * include/bits/sstream.tcc (basic_stringbuf<>::_M_sync): Adjust consistently for calls from setbuf. From-SVN: r111274
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/sstream.tcc28
-rw-r--r--libstdc++-v3/include/std/std_sstream.h4
3 files changed, 23 insertions, 16 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 99af081..1e1c79f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2006-02-19 Paolo Carlini <pcarlini@suse.de>
+
+ * include/std/std_sstream.h (basic_stringbuf<>::setbuf): Simply
+ clear the internal _M_string, adjust _M_sync call.
+ * include/bits/sstream.tcc (basic_stringbuf<>::_M_sync): Adjust
+ consistently for calls from setbuf.
+
2006-02-17 Paolo Carlini <pcarlini@suse.de>
Howard Hinnant <hhinnant@apple.com>
diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc
index 95d3d46..2c5be33 100644
--- a/libstdc++-v3/include/bits/sstream.tcc
+++ b/libstdc++-v3/include/bits/sstream.tcc
@@ -225,9 +225,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
return __ret;
}
- // Assumes: contents of _M_string and internal buffer match exactly.
- // __i == _M_in_cur - _M_in_beg
- // __o == _M_out_cur - _M_out_beg
template <class _CharT, class _Traits, class _Alloc>
void
basic_stringbuf<_CharT, _Traits, _Alloc>::
@@ -235,25 +232,28 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
const bool __testin = _M_mode & ios_base::in;
const bool __testout = _M_mode & ios_base::out;
- char_type* __end = __base + _M_string.size();
-
+ char_type* __endg = __base + _M_string.size();
+ char_type* __endp = __base + _M_string.capacity();
+
+ if (__base != _M_string.data())
+ {
+ // setbuf: __i == size of buffer area (_M_string.size() == 0).
+ __endg += __i;
+ __i = 0;
+ __endp = __endg;
+ }
+
if (__testin)
- this->setg(__base, __base + __i, __end);
+ this->setg(__base, __base + __i, __endg);
if (__testout)
{
- // If __base comes from setbuf we cannot trust capacity()
- // to match the size of the buffer area: in general, after
- // Step 1 in setbuf, _M_string.capacity() >= __n.
- if (__base == _M_string.data())
- this->setp(__base, __base + _M_string.capacity());
- else
- this->setp(__base, __end);
+ this->setp(__base, __endp);
this->pbump(__o);
// 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(__end, __end, __end);
+ this->setg(__endg, __endg, __endg);
}
}
diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h
index 712bf7b..f30c23b 100644
--- a/libstdc++-v3/include/std/std_sstream.h
+++ b/libstdc++-v3/include/std/std_sstream.h
@@ -211,10 +211,10 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
// things will quickly blow up.
// Step 1: Destroy the current internal array.
- _M_string.assign(__s, __n);
+ _M_string.clear();
// Step 2: Use the external array.
- _M_sync(__s, 0, 0);
+ _M_sync(__s, __n, 0);
}
return this;
}