402N/A--- stdcxx-4.2.1/include/string.cc 2008-04-24 20:23:57.000000000 -0400
402N/A+++ stdcxx-4.2.1/include/string.cc 2011-02-10 15:40:53.807995775 -0500
402N/A@@ -34,6 +34,7 @@
402N/A # pragma warning (disable: 4345)
402N/A #endif // _MSC_VER
402N/A
402N/A+#include <rw/_typetraits.h>
402N/A
402N/A _RWSTD_NAMESPACE (std) {
402N/A
402N/A@@ -256,6 +257,12 @@
402N/A
402N/A const size_type __rlen = _C_min (__str.size () - __pos, __n);
402N/A
402N/A+ _RWSTD_REQUIRES (size () < max_size () - __rlen,
402N/A+ (_RWSTD_ERROR_LENGTH_ERROR,
402N/A+ _RWSTD_FUNC ("basic_string::assign (const "
402N/A+ "basic_string&, size_type, size_type)"),
402N/A+ size (), max_size () - __rlen));
402N/A+
402N/A return replace (size_type (), size (), __str, __pos, __rlen);
402N/A }
402N/A
402N/A@@ -274,7 +281,7 @@
402N/A
402N/A const size_type __rlen = _C_min (__str.size () - __pos2, __n);
402N/A
402N/A- _RWSTD_REQUIRES (size () <= max_size () - __rlen,
402N/A+ _RWSTD_REQUIRES (size () < max_size () - __rlen,
402N/A (_RWSTD_ERROR_LENGTH_ERROR,
402N/A _RWSTD_FUNC ("basic_string::insert (size_type, const "
402N/A "basic_string&, size_type, size_type)"),
402N/A@@ -295,7 +302,7 @@
402N/A "basic_string&)"),
402N/A __pos1, size ()));
402N/A
402N/A- _RWSTD_REQUIRES (size () <= max_size () - __str.size (),
402N/A+ _RWSTD_REQUIRES (size () < max_size () - __str.size (),
402N/A (_RWSTD_ERROR_LENGTH_ERROR,
402N/A _RWSTD_FUNC ("basic_string::insert (size_type, "
402N/A "const basic_string&)"),
402N/A@@ -312,9 +319,6 @@
402N/A {
402N/A const size_type __size0 = size ();
402N/A
402N/A- if (npos == __n2)
402N/A- __n2 = traits_type::length (__s);
402N/A-
402N/A _RWSTD_REQUIRES (__pos1 <= __size0,
402N/A (_RWSTD_ERROR_OUT_OF_RANGE,
402N/A _RWSTD_FUNC ("basic_string::replace (size_type, size_type"
402N/A@@ -324,13 +328,13 @@
402N/A // number of characters to delete
402N/A const size_type __xlen = _C_min (__n1, __size0 - __pos1);
402N/A
402N/A- _RWSTD_REQUIRES (__n2 <= max_size (),
402N/A+ _RWSTD_REQUIRES (__n2 < max_size (),
402N/A (_RWSTD_ERROR_LENGTH_ERROR,
402N/A _RWSTD_FUNC ("basic_string::replace (size_type, size_type"
402N/A ", const_pointer, size_type)"),
402N/A __n2, max_size ()));
402N/A
402N/A- _RWSTD_REQUIRES (__size0 - __xlen <= max_size () - __n2,
402N/A+ _RWSTD_REQUIRES (__size0 - __xlen < max_size () - __n2,
402N/A (_RWSTD_ERROR_LENGTH_ERROR,
402N/A _RWSTD_FUNC ("basic_string::replace (size_type, size_type"
402N/A ", const_pointer, size_type)"),
402N/A@@ -405,7 +409,7 @@
402N/A
402N/A const size_type __xlen = _C_min (__size0 - __pos, __len);
402N/A
402N/A- _RWSTD_REQUIRES (__size0 - __xlen <= max_size () - __count,
402N/A+ _RWSTD_REQUIRES (__size0 - __xlen < max_size () - __count,
402N/A (_RWSTD_ERROR_LENGTH_ERROR,
402N/A _RWSTD_FUNC ("basic_string::replace (size_type, "
402N/A "size_type, size_type, value_type)"),
402N/A@@ -477,6 +481,8 @@
402N/A typedef _TYPENAME traits_type::char_type value_type;
402N/A typedef _Alloc allocator_type;
402N/A typedef _TYPENAME allocator_type::size_type size_type;
402N/A+ typedef _TYPENAME allocator_type::pointer pointer;
402N/A+ typedef _TYPENAME allocator_type::const_pointer const_pointer;
402N/A
402N/A typedef _STD::basic_string<_CharT, _Traits, _Alloc> _C_string_type;
402N/A
402N/A@@ -513,10 +519,33 @@
402N/A return __s.replace (__pos, __n, size_type (), value_type ());
402N/A }
402N/A
402N/A+ if (_RW::__rw_is_pointer<_InputIter>::_C_val) {
402N/A+ const const_pointer __beg1 = __s.data ();
402N/A+ const const_pointer __end1 = __s.data () + __s.size ();
402N/A+
402N/A+ const const_pointer __beg2 =
402N/A+ _RWSTD_REINTERPRET_CAST (const_pointer,
402N/A+ __s.get_allocator().address (*__first2));
402N/A+
402N/A+ const const_pointer __end2 =
402N/A+ _RWSTD_REINTERPRET_CAST (const_pointer,
402N/A+ __s.get_allocator().address (*__last2));
402N/A+
402N/A+ // ranges don't overlap, do simple replace
402N/A+ if (__end1 < __beg2 || __end2 < __beg1)
402N/A+ return __s.__replace_aux (__first1, __last1, __first2, __last2);
402N/A+
402N/A+ // otherwise fall through and make a copy first
402N/A+ }
402N/A+
402N/A // use a (probably) faster algorithm if possible
402N/A if (_STD::__is_bidirectional_iterator (_RWSTD_ITERATOR_CATEGORY(_InputIter,
402N/A- __last2)))
402N/A- return __s.__replace_aux (__first1, __last1, __first2, __last2);
402N/A+ __last2))) {
402N/A+ _C_string_type __s3;
402N/A+ __s3.__replace_aux (__s3.begin (), __s3.begin (), __first2, __last2);
402N/A+
402N/A+ return __s.__replace_aux (__first1, __last1, __s3.begin (), __s3.end ());
402N/A+ }
402N/A
402N/A _C_string_type __s3;
402N/A _TYPENAME _C_string_type::iterator __first3 = __s3.begin ();
402N/A@@ -583,6 +612,9 @@
402N/A typedef _RW::__string_ref<value_type, traits_type, allocator_type>
402N/A _C_string_ref_type;
402N/A
402N/A+ typedef _RWSTD_ALLOC_TYPE (allocator_type, value_type)
402N/A+ _C_value_alloc_type;
402N/A+
402N/A # else // if !defined (_RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES)
402N/A
402N/A template<class _CharT, class _Traits, class _Allocator>
402N/A@@ -596,6 +628,8 @@
402N/A
402N/A # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
402N/A
402N/A+ // assumes that the two ranges do not overlap
402N/A+
402N/A _RWSTD_ASSERT_RANGE (__first1, __s._C_make_iter (__s._C_data
402N/A + __s.size ()));
402N/A _RWSTD_ASSERT_RANGE (__first1, __last1);
402N/A@@ -615,7 +649,7 @@
402N/A size_type __slen = __ssize - __pos;
402N/A size_type __xlen = __n < __slen ? __n : __slen;
402N/A
402N/A- _RWSTD_REQUIRES (__ssize - __xlen <= __s.max_size () - __n2,
402N/A+ _RWSTD_REQUIRES (__ssize - __xlen < __s.max_size () - __n2,
402N/A (_RWSTD_ERROR_LENGTH_ERROR,
402N/A _RWSTD_FUNC ("basic_string::__replace_aux (iterator, "
402N/A "iterator, InputIterator, InputIterator)"),
402N/A@@ -650,15 +684,37 @@
402N/A __s._C_unlink (__temp->data ());
402N/A }
402N/A else {
402N/A+ pointer __tmp = 0;
402N/A+
402N/A+ if (__n2) {
402N/A+ const_reference __ref =
402N/A+ _RWSTD_REINTERPRET_CAST (const_reference, *__first2);
402N/A+
402N/A+ const const_pointer __ptr = __s.get_allocator().address (__ref);
402N/A+
402N/A+ if (__s.data () <= __ptr && __s.data () + __ssize > __ptr) {
402N/A+ __tmp = __s.get_allocator().allocate (__n2);
402N/A+
402N/A+ for (__d = 0; __d < __n2; __d++)
402N/A+ traits_type::assign (*(__tmp + __d), *__first2++);
402N/A+ }
402N/A+ }
402N/A+
402N/A // Current reference has enough room.
402N/A if (__rem)
402N/A traits_type::move (__s._C_data + __pos + __n2,
402N/A __s._C_data + __pos + __n,
402N/A __rem);
402N/A
402N/A+ if (__tmp) {
402N/A+ traits_type::copy (__s._C_data + __pos, __tmp, __n2);
402N/A+ __s.get_allocator().deallocate (__tmp, __n2);
402N/A+ }
402N/A+ else {
402N/A for (__d = 0; __d < __n2; __d++)
402N/A traits_type::assign (*(__s._C_data + __pos + __d),
402N/A *__first2++);
402N/A+ }
402N/A
402N/A __s._C_pref ()->_C_size._C_size = __len;
402N/A traits_type::assign (__s._C_data [__len], value_type ());