aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2004-10-01 09:22:49 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2004-10-01 09:22:49 +0000
commitf67b6b7a9ec6f92aca5ee057c9472248f3f2ffcf (patch)
tree1293525332ce28fec1f31439a5df03c35b1520e3
parente6845c238200c37250282413728488871a8ffea5 (diff)
downloadgcc-f67b6b7a9ec6f92aca5ee057c9472248f3f2ffcf.zip
gcc-f67b6b7a9ec6f92aca5ee057c9472248f3f2ffcf.tar.gz
gcc-f67b6b7a9ec6f92aca5ee057c9472248f3f2ffcf.tar.bz2
sstream.tcc (seekpos): Minor rearrangement of two conditionals consistently with seekoff.
2004-10-01 Paolo Carlini <pcarlini@suse.de> * include/bits/sstream.tcc (seekpos): Minor rearrangement of two conditionals consistently with seekoff. * include/std/std_sstream.h (setbuf): Avoid a string temporary. (_M_sync): Simplify a bit, clean-up comment. From-SVN: r88389
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/bits/sstream.tcc6
-rw-r--r--libstdc++-v3/include/std/std_sstream.h15
3 files changed, 17 insertions, 11 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 2e92816..88bd3a7 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2004-10-01 Paolo Carlini <pcarlini@suse.de>
+
+ * include/bits/sstream.tcc (seekpos): Minor rearrangement of two
+ conditionals consistently with seekoff.
+ * include/std/std_sstream.h (setbuf): Avoid a string temporary.
+ (_M_sync): Simplify a bit, clean-up comment.
+
2004-09-30 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/10975 (DR 453)
diff --git a/libstdc++-v3/include/bits/sstream.tcc b/libstdc++-v3/include/bits/sstream.tcc
index 1b1232e..19a24bf 100644
--- a/libstdc++-v3/include/bits/sstream.tcc
+++ b/libstdc++-v3/include/bits/sstream.tcc
@@ -187,14 +187,14 @@ namespace std
const bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
const char_type* __beg = __testin ? this->eback() : this->pbase();
- if (__beg)
+ if (__beg && (__testin || __testout))
{
_M_update_egptr();
- off_type __pos(__sp);
+ const off_type __pos(__sp);
const bool __testpos = 0 <= __pos
&& __pos <= this->egptr() - __beg;
- if ((__testin || __testout) && __testpos)
+ if (__testpos)
{
if (__testin)
this->gbump((__beg + __pos) - this->gptr());
diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h
index 0a6738a..3420999 100644
--- a/libstdc++-v3/include/std/std_sstream.h
+++ b/libstdc++-v3/include/std/std_sstream.h
@@ -219,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);
@@ -253,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);
}
}