// SGI's rope class implementation -*- C++ -*-
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
* purpose. It is provided "as is" without express or implied warranty.
*/
-/* NOTE: This is an internal header file, included by other STL headers.
- * You should not attempt to use it directly.
+/** @file ropeimpl.h
+ * This is an internal header file, included by other library headers.
+ * You should not attempt to use it directly.
*/
-#include <bits/std_cstdio.h>
-#include <bits/std_iostream.h>
+#include <cstdio>
+#include <ostream>
+#include <bits/functexcept.h>
-#ifdef __STL_USE_EXCEPTIONS
-# include <bits/std_stdexcept.h>
-#endif
+#include <ext/algorithm> // For copy_n and lexicographical_compare_3way
+#include <ext/memory> // For uninitialized_copy_n
+#include <ext/numeric> // For power
-namespace std
+namespace __gnu_cxx
{
+ using std::size_t;
+ using std::printf;
+ using std::basic_ostream;
+ using std::__throw_length_error;
+ using std::__alloc;
+ using std::_Destroy;
+ using std::uninitialized_fill_n;
// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf
// if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct.
}
break;
default:
- __stl_assert(0);
+ break;
}
}
size_t __pos = __x._M_current_pos;
unsigned char __dirns = 0; // Bit vector marking right turns in the path
- __stl_assert(__pos <= __x._M_root->_M_size);
if (__pos >= __x._M_root->_M_size) {
__x._M_buf_ptr = 0;
return;
}
for(;;) {
++__curr_depth;
- __stl_assert(__curr_depth <= _RopeRep::_S_max_rope_depth);
__path[__curr_depth] = __curr_rope;
switch(__curr_rope->_M_tag) {
case _RopeRep::_S_leaf:
unsigned char __dirns = __x._M_path_directions;
_Rope_RopeConcatenation<_CharT,_Alloc>* __c;
- __stl_assert(__x._M_current_pos <= __x._M_root->_M_size);
if (__x._M_current_pos - __node_start_pos < __len) {
/* More stuff in this leaf, we just didn't cache it. */
_S_setbuf(__x);
return;
}
- __stl_assert(__node_start_pos + __len == __x._M_current_pos);
// node_start_pos is starting position of last_node.
while (--__current_index >= 0) {
if (!(__dirns & 1) /* Path turned left */)
template <class _CharT, class _Alloc>
void _Rope_iterator<_CharT,_Alloc>::_M_check() {
- if (_M_root_rope->_M_tree_ptr != _M_root) {
+ if (_M_root_rope->_M_tree_ptr != this->_M_root) {
// _Rope was modified. Get things fixed up.
- _RopeRep::_S_unref(_M_root);
- _M_root = _M_root_rope->_M_tree_ptr;
- _RopeRep::_S_ref(_M_root);
- _M_buf_ptr = 0;
+ _RopeRep::_S_unref(this->_M_root);
+ this->_M_root = _M_root_rope->_M_tree_ptr;
+ _RopeRep::_S_ref(this->_M_root);
+ this->_M_buf_ptr = 0;
}
}
: _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos),
_M_root_rope(&__r)
{
- _RopeRep::_S_ref(_M_root);
+ _RopeRep::_S_ref(this->_M_root);
}
template <class _CharT, class _Alloc>
{
_CharT* __cstr = _M_c_string;
if (0 != __cstr) {
- size_t __size = _M_size + 1;
- destroy(__cstr, __cstr + __size);
+ size_t __size = this->_M_size + 1;
+ _Destroy(__cstr, __cstr + __size);
_Data_deallocate(__cstr, __size);
}
}
allocator_type __a)
{
if (!_S_is_basic_char_type((_CharT*)0)) {
- destroy(__s, __s + __n);
+ _Destroy(__s, __s + __n);
}
// This has to be a static member, so this gets a bit messy
__a.deallocate(
// Concatenate a C string onto a leaf rope by copying the rope data.
// Used for short ropes.
template <class _CharT, class _Alloc>
-rope<_CharT,_Alloc>::_RopeLeaf*
+typename rope<_CharT,_Alloc>::_RopeLeaf*
rope<_CharT,_Alloc>::_S_leaf_concat_char_iter
(_RopeLeaf* __r, const _CharT* __iter, size_t __len)
{
uninitialized_copy_n(__r->_M_data, __old_len, __new_data);
uninitialized_copy_n(__iter, __len, __new_data + __old_len);
_S_cond_store_eos(__new_data[__old_len + __len]);
- __STL_TRY {
+ try {
__result = _S_new_RopeLeaf(__new_data, __old_len + __len,
__r->get_allocator());
}
- __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len,
- __r->get_allocator()));
+ catch(...)
+ {
+ _RopeRep::__STL_FREE_STRING(__new_data, __old_len + __len,
+ __r->get_allocator());
+ __throw_exception_again;
+ }
return __result;
}
#ifndef __GC
// As above, but it's OK to clobber original if refcount is 1
template <class _CharT, class _Alloc>
-rope<_CharT,_Alloc>::_RopeLeaf*
+typename rope<_CharT,_Alloc>::_RopeLeaf*
rope<_CharT,_Alloc>::_S_destr_leaf_concat_char_iter
(_RopeLeaf* __r, const _CharT* __iter, size_t __len)
{
- __stl_assert(__r->_M_ref_count >= 1);
if (__r->_M_ref_count > 1)
return _S_leaf_concat_char_iter(__r, __iter, __len);
size_t __old_len = __r->_M_size;
uninitialized_copy_n(__iter, __len, __r->_M_data + __old_len);
if (_S_is_basic_char_type((_CharT*)0)) {
_S_cond_store_eos(__r->_M_data[__old_len + __len]);
- __stl_assert(__r->_M_c_string == __r->_M_data);
} else if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string) {
__r->_M_free_c_string();
__r->_M_c_string = 0;
}
__r->_M_size = __old_len + __len;
- __stl_assert(__r->_M_ref_count == 1);
__r->_M_ref_count = 2;
return __r;
} else {
_RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len);
- __stl_assert(__result->_M_ref_count == 1);
return __result;
}
}
// Does not increment (nor decrement on exception) child reference counts.
// Result has ref count 1.
template <class _CharT, class _Alloc>
-rope<_CharT,_Alloc>::_RopeRep*
+typename rope<_CharT,_Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right)
{
- _RopeConcatenation* __result =
- _S_new_RopeConcatenation(__left, __right, __left->get_allocator());
- size_t __depth = __result->_M_depth;
+ _RopeConcatenation* __result = _S_new_RopeConcatenation(__left, __right,
+ __left->get_allocator());
+ size_t __depth = __result->_M_depth;
- __stl_assert(__left->get_allocator() == __right->get_allocator());
- if (__depth > 20 && (__result->_M_size < 1000 ||
- __depth > _RopeRep::_S_max_rope_depth)) {
- _RopeRep* __balanced;
+ if (__depth > 20 && (__result->_M_size < 1000 ||
+ __depth > _RopeRep::_S_max_rope_depth))
+ {
+ _RopeRep* __balanced;
- __STL_TRY {
- __balanced = _S_balance(__result);
-# ifndef __GC
- if (__result != __balanced) {
- __stl_assert(1 == __result->_M_ref_count
- && 1 == __balanced->_M_ref_count);
- }
-# endif
- __result->_M_unref_nonnil();
+ try
+ {
+ __balanced = _S_balance(__result);
+ __result->_M_unref_nonnil();
}
- __STL_UNWIND((_C_deallocate(__result,1)));
- // In case of exception, we need to deallocate
- // otherwise dangling result node. But caller
- // still owns its children. Thus unref is
- // inappropriate.
- return __balanced;
- } else {
- return __result;
- }
+ catch(...)
+ {
+ _C_deallocate(__result,1);
+ __throw_exception_again;
+ }
+ // In case of exception, we need to deallocate
+ // otherwise dangling result node. But caller
+ // still owns its children. Thus unref is
+ // inappropriate.
+ return __balanced;
+ }
+ else
+ return __result;
}
template <class _CharT, class _Alloc>
+typename
rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter
(_RopeRep* __r, const _CharT*__s, size_t __slen)
{
if (_RopeRep::_S_leaf == __r->_M_tag &&
__r->_M_size + __slen <= _S_copy_max) {
__result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen);
-# ifndef __GC
- __stl_assert(1 == __result->_M_ref_count);
-# endif
return __result;
}
if (_RopeRep::_S_concat == __r->_M_tag
_RopeRep* __nright =
_S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen);
__left->_M_ref_nonnil();
- __STL_TRY {
+ try {
__result = _S_tree_concat(__left, __nright);
}
- __STL_UNWIND(_S_unref(__left); _S_unref(__nright));
-# ifndef __GC
- __stl_assert(1 == __result->_M_ref_count);
-# endif
+ catch(...)
+ {
+ _S_unref(__left);
+ _S_unref(__nright);
+ __throw_exception_again;
+ }
return __result;
}
}
_RopeRep* __nright =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());
- __STL_TRY {
+ try {
__r->_M_ref_nonnil();
__result = _S_tree_concat(__r, __nright);
}
- __STL_UNWIND(_S_unref(__r); _S_unref(__nright));
-# ifndef __GC
- __stl_assert(1 == __result->_M_ref_count);
-# endif
+ catch(...)
+ {
+ _S_unref(__r);
+ _S_unref(__nright);
+ __throw_exception_again;
+ }
return __result;
}
#ifndef __GC
template <class _CharT, class _Alloc>
-rope<_CharT,_Alloc>::_RopeRep*
+typename rope<_CharT,_Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_destr_concat_char_iter(
_RopeRep* __r, const _CharT* __s, size_t __slen)
{
__r->get_allocator());
size_t __count = __r->_M_ref_count;
size_t __orig_size = __r->_M_size;
- __stl_assert(__count >= 1);
if (__count > 1) return _S_concat_char_iter(__r, __s, __slen);
if (0 == __slen) {
__r->_M_ref_count = 2; // One more than before
&& __right->_M_size + __slen <= _S_copy_max) {
_RopeRep* __new_right =
_S_destr_leaf_concat_char_iter(__right, __s, __slen);
- if (__right == __new_right) {
- __stl_assert(__new_right->_M_ref_count == 2);
- __new_right->_M_ref_count = 1;
- } else {
- __stl_assert(__new_right->_M_ref_count >= 1);
- __right->_M_unref_nonnil();
- }
- __stl_assert(__r->_M_ref_count == 1);
+ if (__right == __new_right)
+ __new_right->_M_ref_count = 1;
+ else
+ __right->_M_unref_nonnil();
__r->_M_ref_count = 2; // One more than before.
((_RopeConcatenation*)__r)->_M_right = __new_right;
__r->_M_size = __orig_size + __slen;
_RopeRep* __right =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());
__r->_M_ref_nonnil();
- __STL_TRY {
+ try {
__result = _S_tree_concat(__r, __right);
}
- __STL_UNWIND(_S_unref(__r); _S_unref(__right))
- __stl_assert(1 == __result->_M_ref_count);
+ catch(...)
+ {
+ _S_unref(__r);
+ _S_unref(__right);
+ __throw_exception_again;
+ }
return __result;
}
#endif /* !__GC */
template <class _CharT, class _Alloc>
-rope<_CharT,_Alloc>::_RopeRep*
+typename rope<_CharT,_Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_concat(_RopeRep* __left, _RopeRep* __right)
{
if (0 == __left) {
((_RopeLeaf*)__right)->_M_data,
__right->_M_size);
__leftleft->_M_ref_nonnil();
- __STL_TRY {
+ try {
return(_S_tree_concat(__leftleft, __rest));
}
- __STL_UNWIND(_S_unref(__leftleft); _S_unref(__rest))
+ catch(...)
+ {
+ _S_unref(__leftleft);
+ _S_unref(__rest);
+ __throw_exception_again;
+ }
}
}
}
__left->_M_ref_nonnil();
__right->_M_ref_nonnil();
- __STL_TRY {
+ try {
return(_S_tree_concat(__left, __right));
}
- __STL_UNWIND(_S_unref(__left); _S_unref(__right));
+ catch(...)
+ {
+ _S_unref(__left);
+ _S_unref(__right);
+ __throw_exception_again;
+ }
}
template <class _CharT, class _Alloc>
-rope<_CharT,_Alloc>::_RopeRep*
+typename rope<_CharT,_Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
size_t __start, size_t __endp1)
{
_Self_destruct_ptr __right_result(
_S_substring(__right, 0, __endp1 - __left_len));
__result = _S_concat(__left_result, __right_result);
-# ifndef __GC
- __stl_assert(1 == __result->_M_ref_count);
-# endif
return __result;
}
case _RopeRep::_S_leaf:
if (__result_len > __lazy_threshold) goto lazy;
__section = (_CharT*)
_Data_allocate(_S_rounded_up_size(__result_len));
- __STL_TRY {
+ try {
(*(__f->_M_fn))(__start, __result_len, __section);
}
- __STL_UNWIND(_RopeRep::__STL_FREE_STRING(
- __section, __result_len, __base->get_allocator()));
+ catch(...)
+ {
+ _RopeRep::__STL_FREE_STRING(
+ __section, __result_len, __base->get_allocator());
+ __throw_exception_again;
+ }
_S_cond_store_eos(__section[__result_len]);
return _S_new_RopeLeaf(__section, __result_len,
__base->get_allocator());
}
}
- /*NOTREACHED*/
- __stl_assert(false);
lazy:
{
// Create substring node.
_RopeRep* __left = __conc->_M_left;
size_t __left_len = __left->_M_size;
if (__begin < __left_len) {
- size_t __left_end = min(__left_len, __end);
+ size_t __left_end = std::min(__left_len, __end);
if (!_S_apply_to_pieces(__c, __left, __begin, __left_end))
return false;
}
if (__end > __left_len) {
_RopeRep* __right = __conc->_M_right;
- size_t __right_start = max(__left_len, __begin);
+ size_t __right_start = std::max(__left_len, __begin);
if (!_S_apply_to_pieces(__c, __right,
__right_start - __left_len,
__end - __left_len)) {
size_t __len = __end - __begin;
bool __result;
_CharT* __buffer =
- (_CharT*)alloc::allocate(__len * sizeof(_CharT));
- __STL_TRY {
+ (_CharT*)__alloc::allocate(__len * sizeof(_CharT));
+ try {
(*(__f->_M_fn))(__begin, __len, __buffer);
__result = __c(__buffer, __len);
- alloc::deallocate(__buffer, __len * sizeof(_CharT));
+ __alloc::deallocate(__buffer, __len * sizeof(_CharT));
}
- __STL_UNWIND((alloc::deallocate(__buffer,
- __len * sizeof(_CharT))))
+ catch(...)
+ {
+ __alloc::deallocate(__buffer, __len * sizeof(_CharT));
+ __throw_exception_again;
+ }
return __result;
}
default:
- __stl_assert(false);
- /*NOTREACHED*/
- return false;
+ return false;
}
}
const rope<_CharT, _Alloc>& __r)
{
size_t __w = __o.width();
- bool __left = bool(__o.flags() & ios::left);
+ bool __left = bool(__o.flags() & std::ios::left);
size_t __pad_len;
size_t __rope_len = __r.size();
_Rope_insert_char_consumer<_CharT, _Traits> __c(__o);
__pad_len = 0;
}
if (!__is_simple) __o.width(__w/__rope_len);
- __STL_TRY {
+ try {
if (__is_simple && !__left && __pad_len > 0) {
_Rope_fill(__o, __pad_len);
}
if (!__is_simple)
__o.width(__w);
}
- __STL_UNWIND(if (!__is_simple) __o.width(__w))
+ catch(...)
+ {
+ if (!__is_simple)
+ __o.width(__w);
+ __throw_exception_again;
+ }
return __o;
}
rope<_CharT,_Alloc>::find(_CharT __pattern, size_t __start) const
{
_Rope_find_char_char_consumer<_CharT> __c(__pattern);
- _S_apply_to_pieces(__c, _M_tree_ptr, __start, size());
+ _S_apply_to_pieces(__c, this->_M_tree_ptr, __start, size());
size_type __result_pos = __start + __c._M_count;
# ifndef __STL_OLD_ROPE_SEMANTICS
if (__result_pos == size()) __result_pos = npos;
}
case _RopeRep::_S_function:
case _RopeRep::_S_substringfn:
- // We dont yet do anything with substring nodes.
+ // We don't yet do anything with substring nodes.
// This needs to be fixed before ropefiles will work well.
{
_RopeFunction* __f = (_RopeFunction*)__r;
return __buffer + __f->_M_size;
}
default:
- __stl_assert(false);
- /*NOTREACHED*/
return 0;
}
}
// These are Fibonacci numbers < 2**32.
template <class _CharT, class _Alloc>
-rope<_CharT,_Alloc>::_RopeRep*
+typename rope<_CharT,_Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r)
{
_RopeRep* __forest[_RopeRep::_S_max_rope_depth + 1];
for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i)
__forest[__i] = 0;
- __STL_TRY {
+ try {
_S_add_to_forest(__r, __forest);
for (__i = 0; __i <= _RopeRep::_S_max_rope_depth; ++__i)
if (0 != __forest[__i]) {
# endif
__result = _S_concat(__forest[__i], __result);
__forest[__i]->_M_unref_nonnil();
-# if !defined(__GC) && defined(__STL_USE_EXCEPTIONS)
+# if !defined(__GC) && defined(__EXCEPTIONS)
__forest[__i] = 0;
# endif
}
}
- __STL_UNWIND(for(__i = 0; __i <= _RopeRep::_S_max_rope_depth; __i++)
- _S_unref(__forest[__i]))
- if (__result->_M_depth > _RopeRep::_S_max_rope_depth) {
-# ifdef __STL_USE_EXCEPTIONS
- __STL_THROW(length_error("rope too long"));
-# else
- abort();
-# endif
- }
+ catch(...)
+ {
+ for(__i = 0; __i <= _RopeRep::_S_max_rope_depth; __i++)
+ _S_unref(__forest[__i]);
+ __throw_exception_again;
+ }
+
+ if (__result->_M_depth > _RopeRep::_S_max_rope_depth)
+ __throw_length_error("rope::_S_balance");
return(__result);
}
_S_add_leaf_to_forest(__r, __forest);
return;
}
- __stl_assert(__r->_M_tag == _RopeRep::_S_concat);
+
{
_RopeConcatenation* __c = (_RopeConcatenation*)__r;
}
// Too_tiny dead, and no longer included in refcount.
// Insertee is live and included.
- __stl_assert(_S_is_almost_balanced(__insertee));
- __stl_assert(__insertee->_M_depth <= __r->_M_depth + 1);
for (;; ++__i) {
if (0 != __forest[__i]) {
# ifndef __GC
__insertee = _S_concat_and_set_balanced(__forest[__i], __insertee);
__forest[__i]->_M_unref_nonnil();
__forest[__i] = 0;
- __stl_assert(_S_is_almost_balanced(__insertee));
}
- __stl_assert(_S_min_len[__i] <= __insertee->_M_size);
- __stl_assert(__forest[__i] == 0);
if (__i == _RopeRep::_S_max_rope_depth ||
__insertee->_M_size < _S_min_len[__i+1]) {
__forest[__i] = __insertee;
{
__GC_CONST _CharT* __cstr = __r->_M_c_string;
- __stl_assert(__i < __r->_M_size);
if (0 != __cstr) return __cstr[__i];
for(;;) {
switch(__r->_M_tag) {
_Self_destruct_ptr __result_left(
_My_rope::_S_destr_concat_char_iter(__left, &__c, 1));
-# ifndef __GC
- __stl_assert(__left == __result_left || 1 == __result_left->_M_ref_count);
-# endif
_RopeRep* __result =
_My_rope::_S_concat(__result_left, __right);
# ifndef __GC
- __stl_assert(1 <= __result->_M_ref_count);
_RopeRep::_S_unref(__old);
# endif
_M_root->_M_tree_ptr = __result;
__rest_buffer = _Data_allocate(_S_rounded_up_size(__rest));
uninitialized_fill_n(__rest_buffer, __rest, __c);
_S_cond_store_eos(__rest_buffer[__rest]);
- __STL_TRY {
+ try {
__remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a);
}
- __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a))
+ catch(...)
+ {
+ _RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a);
+ __throw_exception_again;
+ }
}
__remainder_rope._M_tree_ptr = __remainder;
if (__exponent != 0) {
rope __base_rope;
uninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c);
_S_cond_store_eos(__base_buffer[__exponentiate_threshold]);
- __STL_TRY {
+ try {
__base_leaf = _S_new_RopeLeaf(__base_buffer,
__exponentiate_threshold, __a);
}
- __STL_UNWIND(_RopeRep::__STL_FREE_STRING(__base_buffer,
- __exponentiate_threshold, __a))
+ catch(...)
+ {
+ _RopeRep::__STL_FREE_STRING(__base_buffer,
+ __exponentiate_threshold, __a);
+ __throw_exception_again;
+ }
__base_rope._M_tree_ptr = __base_leaf;
if (1 == __exponent) {
__result = __base_rope;
-# ifndef __GC
- __stl_assert(2 == __result._M_tree_ptr->_M_ref_count);
- // One each for base_rope and __result
-# endif
} else {
__result = power(__base_rope, __exponent,
_Rope_Concat_fn<_CharT,_Alloc>());
} else {
__result = __remainder_rope;
}
- _M_tree_ptr = __result._M_tree_ptr;
- _M_tree_ptr->_M_ref_nonnil();
+ this->_M_tree_ptr = __result._M_tree_ptr;
+ this->_M_tree_ptr->_M_ref_nonnil();
}
template<class _CharT, class _Alloc>
template<class _CharT, class _Alloc>
const _CharT* rope<_CharT,_Alloc>::c_str() const {
- if (0 == _M_tree_ptr) {
+ if (0 == this->_M_tree_ptr) {
_S_empty_c_str[0] = _S_eos((_CharT*)0); // Possibly redundant,
// but probably fast.
return _S_empty_c_str;
}
- __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string;
- if (0 != __old_c_string) return(__old_c_string);
- size_t __s = size();
- _CharT* __result = _Data_allocate(__s + 1);
- _S_flatten(_M_tree_ptr, __result);
- __result[__s] = _S_eos((_CharT*)0);
-# ifdef __GC
- _M_tree_ptr->_M_c_string = __result;
-# else
- if ((__old_c_string = (__GC_CONST _CharT*)
- _Atomic_swap((unsigned long *)(&(_M_tree_ptr->_M_c_string)),
- (unsigned long)__result)) != 0) {
- // It must have been added in the interim. Hence it had to have been
- // separately allocated. Deallocate the old copy, since we just
- // replaced it.
- destroy(__old_c_string, __old_c_string + __s + 1);
- _Data_deallocate(__old_c_string, __s + 1);
+ __gthread_mutex_lock (&this->_M_tree_ptr->_M_c_string_lock);
+ __GC_CONST _CharT* __result = this->_M_tree_ptr->_M_c_string;
+ if (0 == __result)
+ {
+ size_t __s = size();
+ __result = this->_Data_allocate(__s + 1);
+ _S_flatten(this->_M_tree_ptr, __result);
+ __result[__s] = _S_eos((_CharT*)0);
+ this->_M_tree_ptr->_M_c_string = __result;
}
-# endif
+ __gthread_mutex_unlock (&this->_M_tree_ptr->_M_c_string_lock);
return(__result);
}
template<class _CharT, class _Alloc>
const _CharT* rope<_CharT,_Alloc>::replace_with_c_str() {
- if (0 == _M_tree_ptr) {
+ if (0 == this->_M_tree_ptr) {
_S_empty_c_str[0] = _S_eos((_CharT*)0);
return _S_empty_c_str;
}
- __GC_CONST _CharT* __old_c_string = _M_tree_ptr->_M_c_string;
- if (_RopeRep::_S_leaf == _M_tree_ptr->_M_tag && 0 != __old_c_string) {
+ __GC_CONST _CharT* __old_c_string = this->_M_tree_ptr->_M_c_string;
+ if (_RopeRep::_S_leaf == this->_M_tree_ptr->_M_tag
+ && 0 != __old_c_string) {
return(__old_c_string);
}
size_t __s = size();
_CharT* __result = _Data_allocate(_S_rounded_up_size(__s));
- _S_flatten(_M_tree_ptr, __result);
+ _S_flatten(this->_M_tree_ptr, __result);
__result[__s] = _S_eos((_CharT*)0);
- _M_tree_ptr->_M_unref_nonnil();
- _M_tree_ptr = _S_new_RopeLeaf(__result, __s, get_allocator());
+ this->_M_tree_ptr->_M_unref_nonnil();
+ this->_M_tree_ptr = _S_new_RopeLeaf(__result, __s, this->get_allocator());
return(__result);
}
typedef typename _Rope_iterator::value_type _CharT;
typedef typename _Rope_iterator::_allocator_type _Alloc;
- __stl_assert(__first.container() == __middle.container()
- && __middle.container() == __last.container());
rope<_CharT,_Alloc>& __r(__first.container());
rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index());
rope<_CharT,_Alloc> __suffix =
}
# endif
-} // namespace std
+} // namespace __gnu_cxx
// Local Variables:
// mode:C++