diff options
author | Paolo Carlini <pcarlini@suse.de> | 2004-01-21 15:43:45 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-01-21 15:43:45 +0000 |
commit | 3e7782b2f8f11acc3122ce20380ef91351b0d1c0 (patch) | |
tree | 568a85c377605b689708a73745aaf8f7b7c46140 | |
parent | 3f07b288984a59621d6b7a9d9db129284eac158d (diff) | |
download | gcc-3e7782b2f8f11acc3122ce20380ef91351b0d1c0.zip gcc-3e7782b2f8f11acc3122ce20380ef91351b0d1c0.tar.gz gcc-3e7782b2f8f11acc3122ce20380ef91351b0d1c0.tar.bz2 |
basic_string.tcc (append(const basic_string&)): Revert previous change.
2004-01-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.tcc (append(const basic_string&)):
Revert previous change.
(append(const basic_string&, size_type, size_type)): Revert
previous change, use _M_check and _M_limit.
From-SVN: r76282
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.tcc | 28 |
2 files changed, 28 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3c078e9..a8c0074 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2004-01-21 Paolo Carlini <pcarlini@suse.de> + * include/bits/basic_string.tcc (append(const basic_string&)): + Revert previous change. + (append(const basic_string&, size_type, size_type)): Revert + previous change, use _M_check and _M_limit. + +2004-01-21 Paolo Carlini <pcarlini@suse.de> + * include/bits/basic_string.h (_M_check): Change to return a checked __pos and take an additional const char* argument. (_M_fold): Rename to _M_limit, change to return a size_type, diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 070cd12..ac88677 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -676,16 +676,33 @@ namespace std basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: append(const basic_string& __str) - { return this->append(__str._M_data(), __str.size()); } + { + // Iff appending itself, string needs to pre-reserve the + // correct size so that _M_mutate does not clobber the + // iterators formed here. + const size_type __size = __str.size(); + const size_type __len = __size + this->size(); + if (__len > this->capacity()) + this->reserve(__len); + return _M_replace_safe(_M_iend(), _M_iend(), __str._M_ibegin(), + __str._M_iend()); + } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: append(const basic_string& __str, size_type __pos, size_type __n) { - return this->append(__str._M_data() - + __str._M_check(__pos, "basic_string::append"), - __str._M_limit(__pos, __n)); + // Iff appending itself, string needs to pre-reserve the + // correct size so that _M_mutate does not clobber the + // iterators formed here. + __pos = __str._M_check(__pos, "basic_string::append"); + __n = __str._M_limit(__pos, __n); + const size_type __len = __n + this->size(); + if (__len > this->capacity()) + this->reserve(__len); + return _M_replace_safe(_M_iend(), _M_iend(), __str._M_ibegin() + + __pos, __str._M_ibegin() + __pos + __n); } template<typename _CharT, typename _Traits, typename _Alloc> @@ -693,9 +710,6 @@ namespace std basic_string<_CharT, _Traits, _Alloc>:: append(const _CharT* __s, size_type __n) { - // Iff appending itself, string needs to pre-reserve the - // correct size so that _M_mutate does not clobber the - // iterators formed here. __glibcxx_requires_string_len(__s, __n); const size_type __len = __n + this->size(); if (__len > this->capacity()) |