Commit a6048f29 by Paolo Carlini Committed by Paolo Carlini

rope: Trivial formatting fixes.

2004-06-27  Paolo Carlini  <pcarlini@suse.de>

	* include/ext/rope: Trivial formatting fixes.
	* include/ext/ropeimpl.h: Likewise.

From-SVN: r83737
parent 60cdabab
2004-06-27 Paolo Carlini <pcarlini@suse.de>
* include/ext/rope: Trivial formatting fixes.
* include/ext/ropeimpl.h: Likewise.
2004-06-26 Paolo Carlini <pcarlini@suse.de> 2004-06-26 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/16210 PR libstdc++/16210
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -62,22 +62,23 @@ namespace __gnu_cxx ...@@ -62,22 +62,23 @@ namespace __gnu_cxx
using std::_Destroy; using std::_Destroy;
using std::uninitialized_fill_n; using std::uninitialized_fill_n;
// Set buf_start, buf_end, and buf_ptr appropriately, filling tmp_buf // 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. // if necessary. Assumes _M_path_end[leaf_index] and leaf_pos are correct.
// Results in a valid buf_ptr if the iterator can be legitimately // Results in a valid buf_ptr if the iterator can be legitimately
// dereferenced. // dereferenced.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf( void
_Rope_iterator_base<_CharT,_Alloc>& __x) _Rope_iterator_base<_CharT, _Alloc>::
{ _S_setbuf(_Rope_iterator_base<_CharT, _Alloc>& __x)
{
const _RopeRep* __leaf = __x._M_path_end[__x._M_leaf_index]; const _RopeRep* __leaf = __x._M_path_end[__x._M_leaf_index];
size_t __leaf_pos = __x._M_leaf_pos; size_t __leaf_pos = __x._M_leaf_pos;
size_t __pos = __x._M_current_pos; size_t __pos = __x._M_current_pos;
switch(__leaf->_M_tag) { switch(__leaf->_M_tag)
{
case _Rope_constants::_S_leaf: case _Rope_constants::_S_leaf:
__x._M_buf_start = __x._M_buf_start = ((_Rope_RopeLeaf<_CharT, _Alloc>*)__leaf)->_M_data;
((_Rope_RopeLeaf<_CharT,_Alloc>*)__leaf)->_M_data;
__x._M_buf_ptr = __x._M_buf_start + (__pos - __leaf_pos); __x._M_buf_ptr = __x._M_buf_start + (__pos - __leaf_pos);
__x._M_buf_end = __x._M_buf_start + __leaf->_M_size; __x._M_buf_end = __x._M_buf_start + __leaf->_M_size;
break; break;
...@@ -87,18 +88,16 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf( ...@@ -87,18 +88,16 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf(
size_t __len = _S_iterator_buf_len; size_t __len = _S_iterator_buf_len;
size_t __buf_start_pos = __leaf_pos; size_t __buf_start_pos = __leaf_pos;
size_t __leaf_end = __leaf_pos + __leaf->_M_size; size_t __leaf_end = __leaf_pos + __leaf->_M_size;
char_producer<_CharT>* __fn = char_producer<_CharT>* __fn = ((_Rope_RopeFunction<_CharT,
((_Rope_RopeFunction<_CharT,_Alloc>*)__leaf)->_M_fn; _Alloc>*)__leaf)->_M_fn;
if (__buf_start_pos + __len <= __pos)
if (__buf_start_pos + __len <= __pos) { {
__buf_start_pos = __pos - __len/4; __buf_start_pos = __pos - __len / 4;
if (__buf_start_pos + __len > __leaf_end) { if (__buf_start_pos + __len > __leaf_end)
__buf_start_pos = __leaf_end - __len; __buf_start_pos = __leaf_end - __len;
} }
} if (__buf_start_pos + __len > __leaf_end)
if (__buf_start_pos + __len > __leaf_end) {
__len = __leaf_end - __buf_start_pos; __len = __leaf_end - __buf_start_pos;
}
(*__fn)(__buf_start_pos - __leaf_pos, __len, __x._M_tmp_buf); (*__fn)(__buf_start_pos - __leaf_pos, __len, __x._M_tmp_buf);
__x._M_buf_ptr = __x._M_tmp_buf + (__pos - __buf_start_pos); __x._M_buf_ptr = __x._M_tmp_buf + (__pos - __buf_start_pos);
__x._M_buf_start = __x._M_tmp_buf; __x._M_buf_start = __x._M_tmp_buf;
...@@ -108,14 +107,15 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf( ...@@ -108,14 +107,15 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setbuf(
default: default:
break; break;
} }
} }
// Set path and buffer inside a rope iterator. We assume that // Set path and buffer inside a rope iterator. We assume that
// pos and root are already set. // pos and root are already set.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache void
(_Rope_iterator_base<_CharT,_Alloc>& __x) _Rope_iterator_base<_CharT, _Alloc>::
{ _S_setcache(_Rope_iterator_base<_CharT, _Alloc>& __x)
{
const _RopeRep* __path[_Rope_constants::_S_max_rope_depth + 1]; const _RopeRep* __path[_Rope_constants::_S_max_rope_depth + 1];
const _RopeRep* __curr_rope; const _RopeRep* __curr_rope;
int __curr_depth = -1; /* index into path */ int __curr_depth = -1; /* index into path */
...@@ -123,12 +123,14 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache ...@@ -123,12 +123,14 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache
size_t __pos = __x._M_current_pos; size_t __pos = __x._M_current_pos;
unsigned char __dirns = 0; // Bit vector marking right turns in the path unsigned char __dirns = 0; // Bit vector marking right turns in the path
if (__pos >= __x._M_root->_M_size) { if (__pos >= __x._M_root->_M_size)
{
__x._M_buf_ptr = 0; __x._M_buf_ptr = 0;
return; return;
} }
__curr_rope = __x._M_root; __curr_rope = __x._M_root;
if (0 != __curr_rope->_M_c_string) { if (0 != __curr_rope->_M_c_string)
{
/* Treat the root as a leaf. */ /* Treat the root as a leaf. */
__x._M_buf_start = __curr_rope->_M_c_string; __x._M_buf_start = __curr_rope->_M_c_string;
__x._M_buf_end = __curr_rope->_M_c_string + __curr_rope->_M_size; __x._M_buf_end = __curr_rope->_M_c_string + __curr_rope->_M_size;
...@@ -138,10 +140,12 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache ...@@ -138,10 +140,12 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache
__x._M_leaf_pos = 0; __x._M_leaf_pos = 0;
return; return;
} }
for(;;) { for(;;)
{
++__curr_depth; ++__curr_depth;
__path[__curr_depth] = __curr_rope; __path[__curr_depth] = __curr_rope;
switch(__curr_rope->_M_tag) { switch(__curr_rope->_M_tag)
{
case _Rope_constants::_S_leaf: case _Rope_constants::_S_leaf:
case _Rope_constants::_S_function: case _Rope_constants::_S_function:
case _Rope_constants::_S_substringfn: case _Rope_constants::_S_substringfn:
...@@ -149,19 +153,20 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache ...@@ -149,19 +153,20 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache
goto done; goto done;
case _Rope_constants::_S_concat: case _Rope_constants::_S_concat:
{ {
_Rope_RopeConcatenation<_CharT,_Alloc>* __c = _Rope_RopeConcatenation<_CharT, _Alloc>* __c =
(_Rope_RopeConcatenation<_CharT,_Alloc>*)__curr_rope; (_Rope_RopeConcatenation<_CharT, _Alloc>*)__curr_rope;
_RopeRep* __left = __c->_M_left; _RopeRep* __left = __c->_M_left;
size_t __left_len = __left->_M_size; size_t __left_len = __left->_M_size;
__dirns <<= 1; __dirns <<= 1;
if (__pos >= __curr_start_pos + __left_len) { if (__pos >= __curr_start_pos + __left_len)
{
__dirns |= 1; __dirns |= 1;
__curr_rope = __c->_M_right; __curr_rope = __c->_M_right;
__curr_start_pos += __left_len; __curr_start_pos += __left_len;
} else {
__curr_rope = __left;
} }
else
__curr_rope = __left;
} }
break; break;
} }
...@@ -173,51 +178,54 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache ...@@ -173,51 +178,54 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache
int __j = __curr_depth + 1 - _S_path_cache_len; int __j = __curr_depth + 1 - _S_path_cache_len;
if (__j < 0) __j = 0; if (__j < 0) __j = 0;
while (__j <= __curr_depth) { while (__j <= __curr_depth)
__x._M_path_end[++__i] = __path[__j++]; __x._M_path_end[++__i] = __path[__j++];
}
__x._M_leaf_index = __i; __x._M_leaf_index = __i;
} }
__x._M_path_directions = __dirns; __x._M_path_directions = __dirns;
_S_setbuf(__x); _S_setbuf(__x);
} }
// Specialized version of the above. Assumes that // Specialized version of the above. Assumes that
// the path cache is valid for the previous position. // the path cache is valid for the previous position.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr void
(_Rope_iterator_base<_CharT,_Alloc>& __x) _Rope_iterator_base<_CharT, _Alloc>::
{ _S_setcache_for_incr(_Rope_iterator_base<_CharT, _Alloc>& __x)
{
int __current_index = __x._M_leaf_index; int __current_index = __x._M_leaf_index;
const _RopeRep* __current_node = __x._M_path_end[__current_index]; const _RopeRep* __current_node = __x._M_path_end[__current_index];
size_t __len = __current_node->_M_size; size_t __len = __current_node->_M_size;
size_t __node_start_pos = __x._M_leaf_pos; size_t __node_start_pos = __x._M_leaf_pos;
unsigned char __dirns = __x._M_path_directions; unsigned char __dirns = __x._M_path_directions;
_Rope_RopeConcatenation<_CharT,_Alloc>* __c; _Rope_RopeConcatenation<_CharT, _Alloc>* __c;
if (__x._M_current_pos - __node_start_pos < __len) { if (__x._M_current_pos - __node_start_pos < __len)
{
/* More stuff in this leaf, we just didn't cache it. */ /* More stuff in this leaf, we just didn't cache it. */
_S_setbuf(__x); _S_setbuf(__x);
return; return;
} }
// node_start_pos is starting position of last_node. // node_start_pos is starting position of last_node.
while (--__current_index >= 0) { while (--__current_index >= 0)
{
if (!(__dirns & 1) /* Path turned left */) if (!(__dirns & 1) /* Path turned left */)
break; break;
__current_node = __x._M_path_end[__current_index]; __current_node = __x._M_path_end[__current_index];
__c = (_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node; __c = (_Rope_RopeConcatenation<_CharT, _Alloc>*)__current_node;
// Otherwise we were in the right child. Thus we should pop // Otherwise we were in the right child. Thus we should pop
// the concatenation node. // the concatenation node.
__node_start_pos -= __c->_M_left->_M_size; __node_start_pos -= __c->_M_left->_M_size;
__dirns >>= 1; __dirns >>= 1;
} }
if (__current_index < 0) { if (__current_index < 0)
{
// We underflowed the cache. Punt. // We underflowed the cache. Punt.
_S_setcache(__x); _S_setcache(__x);
return; return;
} }
__current_node = __x._M_path_end[__current_index]; __current_node = __x._M_path_end[__current_index];
__c = (_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node; __c = (_Rope_RopeConcatenation<_CharT, _Alloc>*)__current_node;
// current_node is a concatenation node. We are positioned on the first // current_node is a concatenation node. We are positioned on the first
// character in its right child. // character in its right child.
// node_start_pos is starting position of current_node. // node_start_pos is starting position of current_node.
...@@ -225,17 +233,18 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr ...@@ -225,17 +233,18 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr
__current_node = __c->_M_right; __current_node = __c->_M_right;
__x._M_path_end[++__current_index] = __current_node; __x._M_path_end[++__current_index] = __current_node;
__dirns |= 1; __dirns |= 1;
while (_Rope_constants::_S_concat == __current_node->_M_tag) { while (_Rope_constants::_S_concat == __current_node->_M_tag)
{
++__current_index; ++__current_index;
if (_S_path_cache_len == __current_index) { if (_S_path_cache_len == __current_index)
{
int __i; int __i;
for (__i = 0; __i < _S_path_cache_len-1; __i++) { for (__i = 0; __i < _S_path_cache_len-1; __i++)
__x._M_path_end[__i] = __x._M_path_end[__i+1]; __x._M_path_end[__i] = __x._M_path_end[__i+1];
}
--__current_index; --__current_index;
} }
__current_node = __current_node =
((_Rope_RopeConcatenation<_CharT,_Alloc>*)__current_node)->_M_left; ((_Rope_RopeConcatenation<_CharT, _Alloc>*)__current_node)->_M_left;
__x._M_path_end[__current_index] = __current_node; __x._M_path_end[__current_index] = __current_node;
__dirns <<= 1; __dirns <<= 1;
// node_start_pos is unchanged. // node_start_pos is unchanged.
...@@ -244,166 +253,183 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr ...@@ -244,166 +253,183 @@ void _Rope_iterator_base<_CharT,_Alloc>::_S_setcache_for_incr
__x._M_leaf_pos = __node_start_pos; __x._M_leaf_pos = __node_start_pos;
__x._M_path_directions = __dirns; __x._M_path_directions = __dirns;
_S_setbuf(__x); _S_setbuf(__x);
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void _Rope_iterator_base<_CharT,_Alloc>::_M_incr(size_t __n) { void
_Rope_iterator_base<_CharT, _Alloc>::
_M_incr(size_t __n)
{
_M_current_pos += __n; _M_current_pos += __n;
if (0 != _M_buf_ptr) { if (0 != _M_buf_ptr)
{
size_t __chars_left = _M_buf_end - _M_buf_ptr; size_t __chars_left = _M_buf_end - _M_buf_ptr;
if (__chars_left > __n) { if (__chars_left > __n)
_M_buf_ptr += __n; _M_buf_ptr += __n;
} else if (__chars_left == __n) { else if (__chars_left == __n)
{
_M_buf_ptr += __n; _M_buf_ptr += __n;
_S_setcache_for_incr(*this); _S_setcache_for_incr(*this);
} else { }
else
_M_buf_ptr = 0; _M_buf_ptr = 0;
} }
} }
}
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void _Rope_iterator_base<_CharT,_Alloc>::_M_decr(size_t __n) { void
if (0 != _M_buf_ptr) { _Rope_iterator_base<_CharT, _Alloc>::
_M_decr(size_t __n)
{
if (0 != _M_buf_ptr)
{
size_t __chars_left = _M_buf_ptr - _M_buf_start; size_t __chars_left = _M_buf_ptr - _M_buf_start;
if (__chars_left >= __n) { if (__chars_left >= __n)
_M_buf_ptr -= __n; _M_buf_ptr -= __n;
} else { else
_M_buf_ptr = 0; _M_buf_ptr = 0;
} }
}
_M_current_pos -= __n; _M_current_pos -= __n;
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void _Rope_iterator<_CharT,_Alloc>::_M_check() { void
if (_M_root_rope->_M_tree_ptr != this->_M_root) { _Rope_iterator<_CharT, _Alloc>::
_M_check()
{
if (_M_root_rope->_M_tree_ptr != this->_M_root)
{
// _Rope was modified. Get things fixed up. // _Rope was modified. Get things fixed up.
_RopeRep::_S_unref(this->_M_root); _RopeRep::_S_unref(this->_M_root);
this->_M_root = _M_root_rope->_M_tree_ptr; this->_M_root = _M_root_rope->_M_tree_ptr;
_RopeRep::_S_ref(this->_M_root); _RopeRep::_S_ref(this->_M_root);
this->_M_buf_ptr = 0; this->_M_buf_ptr = 0;
} }
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
inline inline
_Rope_const_iterator<_CharT, _Alloc>::_Rope_const_iterator( _Rope_const_iterator<_CharT, _Alloc>::
const _Rope_iterator<_CharT,_Alloc>& __x) _Rope_const_iterator(const _Rope_iterator<_CharT, _Alloc>& __x)
: _Rope_iterator_base<_CharT,_Alloc>(__x) : _Rope_iterator_base<_CharT, _Alloc>(__x)
{ } { }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
inline _Rope_iterator<_CharT,_Alloc>::_Rope_iterator( inline
rope<_CharT,_Alloc>& __r, size_t __pos) _Rope_iterator<_CharT, _Alloc>::
: _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos), _Rope_iterator(rope<_CharT, _Alloc>& __r, size_t __pos)
: _Rope_iterator_base<_CharT,_Alloc>(__r._M_tree_ptr, __pos),
_M_root_rope(&__r) _M_root_rope(&__r)
{ { _RopeRep::_S_ref(this->_M_root); }
_RopeRep::_S_ref(this->_M_root);
}
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
inline size_t inline size_t
rope<_CharT,_Alloc>::_S_char_ptr_len(const _CharT* __s) rope<_CharT, _Alloc>::
{ _S_char_ptr_len(const _CharT* __s)
{
const _CharT* __p = __s; const _CharT* __p = __s;
while (!_S_is0(*__p)) { ++__p; } while (!_S_is0(*__p))
++__p;
return (__p - __s); return (__p - __s);
} }
#ifndef __GC #ifndef __GC
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
inline void _Rope_RopeRep<_CharT,_Alloc>::_M_free_c_string() inline void
{ _Rope_RopeRep<_CharT, _Alloc>::
_M_free_c_string()
{
_CharT* __cstr = _M_c_string; _CharT* __cstr = _M_c_string;
if (0 != __cstr) { if (0 != __cstr)
{
size_t __size = this->_M_size + 1; size_t __size = this->_M_size + 1;
_Destroy(__cstr, __cstr + __size); _Destroy(__cstr, __cstr + __size);
this->_Data_deallocate(__cstr, __size); this->_Data_deallocate(__cstr, __size);
} }
}
template <class _CharT, class _Alloc>
inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string(_CharT* __s,
size_t __n,
allocator_type __a)
{
if (!_S_is_basic_char_type((_CharT*)0)) {
_Destroy(__s, __s + __n);
} }
// This has to be a static member, so this gets a bit messy
__a.deallocate(
__s, _Rope_RopeLeaf<_CharT,_Alloc>::_S_rounded_up_size(__n));
}
template <class _CharT, class _Alloc>
inline void
_Rope_RopeRep<_CharT, _Alloc>::
_S_free_string(_CharT* __s, size_t __n, allocator_type __a)
{
if (!_S_is_basic_char_type((_CharT*)0))
_Destroy(__s, __s + __n);
// There are several reasons for not doing this with virtual destructors // This has to be a static member, so this gets a bit messy
// and a class specific delete operator: __a.deallocate(__s,
// - A class specific delete operator can't easily get access to _Rope_RopeLeaf<_CharT, _Alloc>::_S_rounded_up_size(__n));
// allocator instances if we need them. }
// - Any virtual function would need a 4 or byte vtable pointer;
// this only requires a one byte tag per object. // There are several reasons for not doing this with virtual destructors
template <class _CharT, class _Alloc> // and a class specific delete operator:
void _Rope_RopeRep<_CharT,_Alloc>::_M_free_tree() // - A class specific delete operator can't easily get access to
{ // allocator instances if we need them.
switch(_M_tag) { // - Any virtual function would need a 4 or byte vtable pointer;
// this only requires a one byte tag per object.
template <class _CharT, class _Alloc>
void
_Rope_RopeRep<_CharT, _Alloc>::
_M_free_tree()
{
switch(_M_tag)
{
case _Rope_constants::_S_leaf: case _Rope_constants::_S_leaf:
{ {
_Rope_RopeLeaf<_CharT,_Alloc>* __l _Rope_RopeLeaf<_CharT, _Alloc>* __l
= (_Rope_RopeLeaf<_CharT,_Alloc>*)this; = (_Rope_RopeLeaf<_CharT, _Alloc>*)this;
__l->_Rope_RopeLeaf<_CharT,_Alloc>::~_Rope_RopeLeaf(); __l->_Rope_RopeLeaf<_CharT, _Alloc>::~_Rope_RopeLeaf();
_L_deallocate(__l, 1); _L_deallocate(__l, 1);
break; break;
} }
case _Rope_constants::_S_concat: case _Rope_constants::_S_concat:
{ {
_Rope_RopeConcatenation<_CharT,_Alloc>* __c _Rope_RopeConcatenation<_CharT,_Alloc>* __c
= (_Rope_RopeConcatenation<_CharT,_Alloc>*)this; = (_Rope_RopeConcatenation<_CharT, _Alloc>*)this;
__c->_Rope_RopeConcatenation<_CharT,_Alloc>:: __c->_Rope_RopeConcatenation<_CharT, _Alloc>::
~_Rope_RopeConcatenation(); ~_Rope_RopeConcatenation();
_C_deallocate(__c, 1); _C_deallocate(__c, 1);
break; break;
} }
case _Rope_constants::_S_function: case _Rope_constants::_S_function:
{ {
_Rope_RopeFunction<_CharT,_Alloc>* __f _Rope_RopeFunction<_CharT, _Alloc>* __f
= (_Rope_RopeFunction<_CharT,_Alloc>*)this; = (_Rope_RopeFunction<_CharT, _Alloc>*)this;
__f->_Rope_RopeFunction<_CharT,_Alloc>::~_Rope_RopeFunction(); __f->_Rope_RopeFunction<_CharT, _Alloc>::~_Rope_RopeFunction();
_F_deallocate(__f, 1); _F_deallocate(__f, 1);
break; break;
} }
case _Rope_constants::_S_substringfn: case _Rope_constants::_S_substringfn:
{ {
_Rope_RopeSubstring<_CharT,_Alloc>* __ss = _Rope_RopeSubstring<_CharT, _Alloc>* __ss =
(_Rope_RopeSubstring<_CharT,_Alloc>*)this; (_Rope_RopeSubstring<_CharT, _Alloc>*)this;
__ss->_Rope_RopeSubstring<_CharT,_Alloc>:: __ss->_Rope_RopeSubstring<_CharT, _Alloc>::
~_Rope_RopeSubstring(); ~_Rope_RopeSubstring();
_S_deallocate(__ss, 1); _S_deallocate(__ss, 1);
break; break;
} }
} }
} }
#else #else
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
inline void _Rope_RopeRep<_CharT,_Alloc>::_S_free_string inline void
(const _CharT*, size_t, allocator_type) _Rope_RopeRep<_CharT, _Alloc>::
{} _S_free_string(const _CharT*, size_t, allocator_type)
{ }
#endif #endif
// Concatenate a C string onto a leaf rope by copying the rope data.
// Concatenate a C string onto a leaf rope by copying the rope data. // Used for short ropes.
// Used for short ropes. template <class _CharT, class _Alloc>
template <class _CharT, class _Alloc> typename rope<_CharT, _Alloc>::_RopeLeaf*
typename rope<_CharT,_Alloc>::_RopeLeaf* rope<_CharT, _Alloc>::
rope<_CharT,_Alloc>::_S_leaf_concat_char_iter _S_leaf_concat_char_iter(_RopeLeaf* __r, const _CharT* __iter, size_t __len)
(_RopeLeaf* __r, const _CharT* __iter, size_t __len) {
{
size_t __old_len = __r->_M_size; size_t __old_len = __r->_M_size;
_CharT* __new_data = (_CharT*) _CharT* __new_data = (_CharT*)
_Data_allocate(_S_rounded_up_size(__old_len + __len)); _Data_allocate(_S_rounded_up_size(__old_len + __len));
...@@ -412,7 +438,8 @@ rope<_CharT,_Alloc>::_S_leaf_concat_char_iter ...@@ -412,7 +438,8 @@ rope<_CharT,_Alloc>::_S_leaf_concat_char_iter
uninitialized_copy_n(__r->_M_data, __old_len, __new_data); uninitialized_copy_n(__r->_M_data, __old_len, __new_data);
uninitialized_copy_n(__iter, __len, __new_data + __old_len); uninitialized_copy_n(__iter, __len, __new_data + __old_len);
_S_cond_store_eos(__new_data[__old_len + __len]); _S_cond_store_eos(__new_data[__old_len + __len]);
try { try
{
__result = _S_new_RopeLeaf(__new_data, __old_len + __len, __result = _S_new_RopeLeaf(__new_data, __old_len + __len,
__r->get_allocator()); __r->get_allocator());
} }
...@@ -423,51 +450,58 @@ rope<_CharT,_Alloc>::_S_leaf_concat_char_iter ...@@ -423,51 +450,58 @@ rope<_CharT,_Alloc>::_S_leaf_concat_char_iter
__throw_exception_again; __throw_exception_again;
} }
return __result; return __result;
} }
#ifndef __GC #ifndef __GC
// As above, but it's OK to clobber original if refcount is 1 // As above, but it's OK to clobber original if refcount is 1
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeLeaf* typename rope<_CharT,_Alloc>::_RopeLeaf*
rope<_CharT,_Alloc>::_S_destr_leaf_concat_char_iter rope<_CharT, _Alloc>::
(_RopeLeaf* __r, const _CharT* __iter, size_t __len) _S_destr_leaf_concat_char_iter(_RopeLeaf* __r, const _CharT* __iter,
{ size_t __len)
{
if (__r->_M_ref_count > 1) if (__r->_M_ref_count > 1)
return _S_leaf_concat_char_iter(__r, __iter, __len); return _S_leaf_concat_char_iter(__r, __iter, __len);
size_t __old_len = __r->_M_size; size_t __old_len = __r->_M_size;
if (_S_allocated_capacity(__old_len) >= __old_len + __len) { if (_S_allocated_capacity(__old_len) >= __old_len + __len)
{
// The space has been partially initialized for the standard // The space has been partially initialized for the standard
// character types. But that doesn't matter for those types. // character types. But that doesn't matter for those types.
uninitialized_copy_n(__iter, __len, __r->_M_data + __old_len); uninitialized_copy_n(__iter, __len, __r->_M_data + __old_len);
if (_S_is_basic_char_type((_CharT*)0)) { if (_S_is_basic_char_type((_CharT*)0))
_S_cond_store_eos(__r->_M_data[__old_len + __len]); _S_cond_store_eos(__r->_M_data[__old_len + __len]);
} else if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string) { else if (__r->_M_c_string != __r->_M_data && 0 != __r->_M_c_string)
{
__r->_M_free_c_string(); __r->_M_free_c_string();
__r->_M_c_string = 0; __r->_M_c_string = 0;
} }
__r->_M_size = __old_len + __len; __r->_M_size = __old_len + __len;
__r->_M_ref_count = 2; __r->_M_ref_count = 2;
return __r; return __r;
} else { }
else
{
_RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len); _RopeLeaf* __result = _S_leaf_concat_char_iter(__r, __iter, __len);
return __result; return __result;
} }
} }
#endif #endif
// Assumes left and right are not 0. // Assumes left and right are not 0.
// Does not increment (nor decrement on exception) child reference counts. // Does not increment (nor decrement on exception) child reference counts.
// Result has ref count 1. // Result has ref count 1.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeRep* typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right) rope<_CharT, _Alloc>::
{ _S_tree_concat(_RopeRep* __left, _RopeRep* __right)
{
_RopeConcatenation* __result = _S_new_RopeConcatenation(__left, __right, _RopeConcatenation* __result = _S_new_RopeConcatenation(__left, __right,
__left->get_allocator()); __left->
get_allocator());
size_t __depth = __result->_M_depth; size_t __depth = __result->_M_depth;
if (__depth > 20 && (__result->_M_size < 1000 || if (__depth > 20 && (__result->_M_size < 1000
__depth > _Rope_constants::_S_max_rope_depth)) || __depth > _Rope_constants::_S_max_rope_depth))
{ {
_RopeRep* __balanced; _RopeRep* __balanced;
...@@ -489,38 +523,42 @@ rope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right) ...@@ -489,38 +523,42 @@ rope<_CharT,_Alloc>::_S_tree_concat (_RopeRep* __left, _RopeRep* __right)
} }
else else
return __result; return __result;
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
typename typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter rope<_CharT, _Alloc>::
(_RopeRep* __r, const _CharT*__s, size_t __slen) _S_concat_char_iter(_RopeRep* __r, const _CharT*__s, size_t __slen)
{ {
_RopeRep* __result; _RopeRep* __result;
if (0 == __slen) { if (0 == __slen)
{
_S_ref(__r); _S_ref(__r);
return __r; return __r;
} }
if (0 == __r) if (0 == __r)
return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen,
__r->get_allocator()); __r->get_allocator());
if (_Rope_constants::_S_leaf == __r->_M_tag && if (_Rope_constants::_S_leaf == __r->_M_tag
__r->_M_size + __slen <= _S_copy_max) { && __r->_M_size + __slen <= _S_copy_max)
{
__result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen); __result = _S_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen);
return __result; return __result;
} }
if (_Rope_constants::_S_concat == __r->_M_tag if (_Rope_constants::_S_concat == __r->_M_tag
&& _Rope_constants::_S_leaf == ((_RopeConcatenation*)__r)->_M_right->_M_tag) { && _Rope_constants::_S_leaf == ((_RopeConcatenation*)
__r)->_M_right->_M_tag)
{
_RopeLeaf* __right = _RopeLeaf* __right =
(_RopeLeaf* )(((_RopeConcatenation* )__r)->_M_right); (_RopeLeaf* )(((_RopeConcatenation* )__r)->_M_right);
if (__right->_M_size + __slen <= _S_copy_max) { if (__right->_M_size + __slen <= _S_copy_max)
{
_RopeRep* __left = ((_RopeConcatenation*)__r)->_M_left; _RopeRep* __left = ((_RopeConcatenation*)__r)->_M_left;
_RopeRep* __nright = _RopeRep* __nright =
_S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen); _S_leaf_concat_char_iter((_RopeLeaf*)__right, __s, __slen);
__left->_M_ref_nonnil(); __left->_M_ref_nonnil();
try { try
__result = _S_tree_concat(__left, __nright); { __result = _S_tree_concat(__left, __nright); }
}
catch(...) catch(...)
{ {
_S_unref(__left); _S_unref(__left);
...@@ -532,7 +570,8 @@ rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter ...@@ -532,7 +570,8 @@ rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter
} }
_RopeRep* __nright = _RopeRep* __nright =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator()); __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());
try { try
{
__r->_M_ref_nonnil(); __r->_M_ref_nonnil();
__result = _S_tree_concat(__r, __nright); __result = _S_tree_concat(__r, __nright);
} }
...@@ -543,34 +582,41 @@ rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter ...@@ -543,34 +582,41 @@ rope<_CharT,_Alloc>::_RopeRep* rope<_CharT,_Alloc>::_S_concat_char_iter
__throw_exception_again; __throw_exception_again;
} }
return __result; return __result;
} }
#ifndef __GC #ifndef __GC
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeRep* typename rope<_CharT,_Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_destr_concat_char_iter( rope<_CharT,_Alloc>::
_RopeRep* __r, const _CharT* __s, size_t __slen) _S_destr_concat_char_iter(_RopeRep* __r, const _CharT* __s, size_t __slen)
{ {
_RopeRep* __result; _RopeRep* __result;
if (0 == __r) if (0 == __r)
return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, return __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen,
__r->get_allocator()); __r->get_allocator());
size_t __count = __r->_M_ref_count; size_t __count = __r->_M_ref_count;
size_t __orig_size = __r->_M_size; size_t __orig_size = __r->_M_size;
if (__count > 1) return _S_concat_char_iter(__r, __s, __slen); if (__count > 1)
if (0 == __slen) { return _S_concat_char_iter(__r, __s, __slen);
if (0 == __slen)
{
__r->_M_ref_count = 2; // One more than before __r->_M_ref_count = 2; // One more than before
return __r; return __r;
} }
if (__orig_size + __slen <= _S_copy_max && if (__orig_size + __slen <= _S_copy_max
_Rope_constants::_S_leaf == __r->_M_tag) { && _Rope_constants::_S_leaf == __r->_M_tag)
__result = _S_destr_leaf_concat_char_iter((_RopeLeaf*)__r, __s, __slen); {
__result = _S_destr_leaf_concat_char_iter((_RopeLeaf*)__r, __s,
__slen);
return __result; return __result;
} }
if (_Rope_constants::_S_concat == __r->_M_tag) { if (_Rope_constants::_S_concat == __r->_M_tag)
_RopeLeaf* __right = (_RopeLeaf*)(((_RopeConcatenation*)__r)->_M_right); {
_RopeLeaf* __right = (_RopeLeaf*)(((_RopeConcatenation*)
__r)->_M_right);
if (_Rope_constants::_S_leaf == __right->_M_tag if (_Rope_constants::_S_leaf == __right->_M_tag
&& __right->_M_size + __slen <= _S_copy_max) { && __right->_M_size + __slen <= _S_copy_max)
{
_RopeRep* __new_right = _RopeRep* __new_right =
_S_destr_leaf_concat_char_iter(__right, __s, __slen); _S_destr_leaf_concat_char_iter(__right, __s, __slen);
if (__right == __new_right) if (__right == __new_right)
...@@ -580,7 +626,8 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter( ...@@ -580,7 +626,8 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter(
__r->_M_ref_count = 2; // One more than before. __r->_M_ref_count = 2; // One more than before.
((_RopeConcatenation*)__r)->_M_right = __new_right; ((_RopeConcatenation*)__r)->_M_right = __new_right;
__r->_M_size = __orig_size + __slen; __r->_M_size = __orig_size + __slen;
if (0 != __r->_M_c_string) { if (0 != __r->_M_c_string)
{
__r->_M_free_c_string(); __r->_M_free_c_string();
__r->_M_c_string = 0; __r->_M_c_string = 0;
} }
...@@ -590,9 +637,8 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter( ...@@ -590,9 +637,8 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter(
_RopeRep* __right = _RopeRep* __right =
__STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator()); __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__s, __slen, __r->get_allocator());
__r->_M_ref_nonnil(); __r->_M_ref_nonnil();
try { try
__result = _S_tree_concat(__r, __right); { __result = _S_tree_concat(__r, __right); }
}
catch(...) catch(...)
{ {
_S_unref(__r); _S_unref(__r);
...@@ -600,42 +646,50 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter( ...@@ -600,42 +646,50 @@ rope<_CharT,_Alloc>::_S_destr_concat_char_iter(
__throw_exception_again; __throw_exception_again;
} }
return __result; return __result;
} }
#endif /* !__GC */ #endif /* !__GC */
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeRep* typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_concat(_RopeRep* __left, _RopeRep* __right) rope<_CharT, _Alloc>::
{ _S_concat(_RopeRep* __left, _RopeRep* __right)
if (0 == __left) { {
if (0 == __left)
{
_S_ref(__right); _S_ref(__right);
return __right; return __right;
} }
if (0 == __right) { if (0 == __right)
{
__left->_M_ref_nonnil(); __left->_M_ref_nonnil();
return __left; return __left;
} }
if (_Rope_constants::_S_leaf == __right->_M_tag) { if (_Rope_constants::_S_leaf == __right->_M_tag)
if (_Rope_constants::_S_leaf == __left->_M_tag) { {
if (__right->_M_size + __left->_M_size <= _S_copy_max) { if (_Rope_constants::_S_leaf == __left->_M_tag)
{
if (__right->_M_size + __left->_M_size <= _S_copy_max)
return _S_leaf_concat_char_iter((_RopeLeaf*)__left, return _S_leaf_concat_char_iter((_RopeLeaf*)__left,
((_RopeLeaf*)__right)->_M_data, ((_RopeLeaf*)__right)->_M_data,
__right->_M_size); __right->_M_size);
} }
} else if (_Rope_constants::_S_concat == __left->_M_tag else if (_Rope_constants::_S_concat == __left->_M_tag
&& _Rope_constants::_S_leaf == && _Rope_constants::_S_leaf == ((_RopeConcatenation*)
((_RopeConcatenation*)__left)->_M_right->_M_tag) { __left)->_M_right->_M_tag)
{
_RopeLeaf* __leftright = _RopeLeaf* __leftright =
(_RopeLeaf*)(((_RopeConcatenation*)__left)->_M_right); (_RopeLeaf*)(((_RopeConcatenation*)__left)->_M_right);
if (__leftright->_M_size + __right->_M_size <= _S_copy_max) { if (__leftright->_M_size + __right->_M_size <= _S_copy_max)
{
_RopeRep* __leftleft = ((_RopeConcatenation*)__left)->_M_left; _RopeRep* __leftleft = ((_RopeConcatenation*)__left)->_M_left;
_RopeRep* __rest = _S_leaf_concat_char_iter(__leftright, _RopeRep* __rest = _S_leaf_concat_char_iter(__leftright,
((_RopeLeaf*)__right)->_M_data, ((_RopeLeaf*)
__right)->
_M_data,
__right->_M_size); __right->_M_size);
__leftleft->_M_ref_nonnil(); __leftleft->_M_ref_nonnil();
try { try
return(_S_tree_concat(__leftleft, __rest)); { return(_S_tree_concat(__leftleft, __rest)); }
}
catch(...) catch(...)
{ {
_S_unref(__leftleft); _S_unref(__leftleft);
...@@ -647,38 +701,43 @@ rope<_CharT,_Alloc>::_S_concat(_RopeRep* __left, _RopeRep* __right) ...@@ -647,38 +701,43 @@ rope<_CharT,_Alloc>::_S_concat(_RopeRep* __left, _RopeRep* __right)
} }
__left->_M_ref_nonnil(); __left->_M_ref_nonnil();
__right->_M_ref_nonnil(); __right->_M_ref_nonnil();
try { try
return(_S_tree_concat(__left, __right)); { return(_S_tree_concat(__left, __right)); }
}
catch(...) catch(...)
{ {
_S_unref(__left); _S_unref(__left);
_S_unref(__right); _S_unref(__right);
__throw_exception_again; __throw_exception_again;
} }
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeRep* typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, rope<_CharT, _Alloc>::
size_t __start, size_t __endp1) _S_substring(_RopeRep* __base, size_t __start, size_t __endp1)
{ {
if (0 == __base) return 0; if (0 == __base)
return 0;
size_t __len = __base->_M_size; size_t __len = __base->_M_size;
size_t __adj_endp1; size_t __adj_endp1;
const size_t __lazy_threshold = 128; const size_t __lazy_threshold = 128;
if (__endp1 >= __len) { if (__endp1 >= __len)
if (0 == __start) { {
if (0 == __start)
{
__base->_M_ref_nonnil(); __base->_M_ref_nonnil();
return __base; return __base;
} else { }
else
__adj_endp1 = __len; __adj_endp1 = __len;
} }
} else { else
__adj_endp1 = __endp1; __adj_endp1 = __endp1;
}
switch(__base->_M_tag) { switch(__base->_M_tag)
{
case _Rope_constants::_S_concat: case _Rope_constants::_S_concat:
{ {
_RopeConcatenation* __c = (_RopeConcatenation*)__base; _RopeConcatenation* __c = (_RopeConcatenation*)__base;
...@@ -687,16 +746,17 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, ...@@ -687,16 +746,17 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
size_t __left_len = __left->_M_size; size_t __left_len = __left->_M_size;
_RopeRep* __result; _RopeRep* __result;
if (__adj_endp1 <= __left_len) { if (__adj_endp1 <= __left_len)
return _S_substring(__left, __start, __endp1); return _S_substring(__left, __start, __endp1);
} else if (__start >= __left_len) { else if (__start >= __left_len)
return _S_substring(__right, __start - __left_len, return _S_substring(__right, __start - __left_len,
__adj_endp1 - __left_len); __adj_endp1 - __left_len);
} _Self_destruct_ptr __left_result(_S_substring(__left,
_Self_destruct_ptr __left_result( __start,
_S_substring(__left, __start, __left_len)); __left_len));
_Self_destruct_ptr __right_result( _Self_destruct_ptr __right_result(_S_substring(__right, 0,
_S_substring(__right, 0, __endp1 - __left_len)); __endp1
- __left_len));
__result = _S_concat(__left_result, __right_result); __result = _S_concat(__left_result, __right_result);
return __result; return __result;
} }
...@@ -705,20 +765,23 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, ...@@ -705,20 +765,23 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
_RopeLeaf* __l = (_RopeLeaf*)__base; _RopeLeaf* __l = (_RopeLeaf*)__base;
_RopeLeaf* __result; _RopeLeaf* __result;
size_t __result_len; size_t __result_len;
if (__start >= __adj_endp1) return 0; if (__start >= __adj_endp1)
return 0;
__result_len = __adj_endp1 - __start; __result_len = __adj_endp1 - __start;
if (__result_len > __lazy_threshold) goto lazy; if (__result_len > __lazy_threshold)
# ifdef __GC goto lazy;
#ifdef __GC
const _CharT* __section = __l->_M_data + __start; const _CharT* __section = __l->_M_data + __start;
__result = _S_new_RopeLeaf(__section, __result_len, __result = _S_new_RopeLeaf(__section, __result_len,
__base->get_allocator()); __base->get_allocator());
__result->_M_c_string = 0; // Not eos terminated. __result->_M_c_string = 0; // Not eos terminated.
# else #else
// We should sometimes create substring node instead. // We should sometimes create substring node instead.
__result = __STL_ROPE_FROM_UNOWNED_CHAR_PTR( __result = __STL_ROPE_FROM_UNOWNED_CHAR_PTR(__l->_M_data + __start,
__l->_M_data + __start, __result_len, __result_len,
__base->get_allocator()); __base->
# endif get_allocator());
#endif
return __result; return __result;
} }
case _Rope_constants::_S_substringfn: case _Rope_constants::_S_substringfn:
...@@ -726,9 +789,11 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, ...@@ -726,9 +789,11 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
{ {
_RopeSubstring* __old = (_RopeSubstring*)__base; _RopeSubstring* __old = (_RopeSubstring*)__base;
size_t __result_len; size_t __result_len;
if (__start >= __adj_endp1) return 0; if (__start >= __adj_endp1)
return 0;
__result_len = __adj_endp1 - __start; __result_len = __adj_endp1 - __start;
if (__result_len > __lazy_threshold) { if (__result_len > __lazy_threshold)
{
_RopeSubstring* __result = _RopeSubstring* __result =
_S_new_RopeSubstring(__old->_M_base, _S_new_RopeSubstring(__old->_M_base,
__start + __old->_M_start, __start + __old->_M_start,
...@@ -743,19 +808,20 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, ...@@ -743,19 +808,20 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
_RopeFunction* __f = (_RopeFunction*)__base; _RopeFunction* __f = (_RopeFunction*)__base;
_CharT* __section; _CharT* __section;
size_t __result_len; size_t __result_len;
if (__start >= __adj_endp1) return 0; if (__start >= __adj_endp1)
return 0;
__result_len = __adj_endp1 - __start; __result_len = __adj_endp1 - __start;
if (__result_len > __lazy_threshold) goto lazy; if (__result_len > __lazy_threshold)
goto lazy;
__section = (_CharT*) __section = (_CharT*)
_Data_allocate(_S_rounded_up_size(__result_len)); _Data_allocate(_S_rounded_up_size(__result_len));
try { try
(*(__f->_M_fn))(__start, __result_len, __section); { (*(__f->_M_fn))(__start, __result_len, __section); }
}
catch(...) catch(...)
{ {
_RopeRep::__STL_FREE_STRING( _RopeRep::__STL_FREE_STRING(__section, __result_len,
__section, __result_len, __base->get_allocator()); __base->get_allocator());
__throw_exception_again; __throw_exception_again;
} }
_S_cond_store_eos(__section[__result_len]); _S_cond_store_eos(__section[__result_len]);
...@@ -769,48 +835,65 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base, ...@@ -769,48 +835,65 @@ rope<_CharT,_Alloc>::_S_substring(_RopeRep* __base,
return _S_new_RopeSubstring(__base, __start, __adj_endp1 - __start, return _S_new_RopeSubstring(__base, __start, __adj_endp1 - __start,
__base->get_allocator()); __base->get_allocator());
} }
} }
template<class _CharT> template<class _CharT>
class _Rope_flatten_char_consumer : public _Rope_char_consumer<_CharT> { class _Rope_flatten_char_consumer
: public _Rope_char_consumer<_CharT>
{
private: private:
_CharT* _M_buf_ptr; _CharT* _M_buf_ptr;
public: public:
_Rope_flatten_char_consumer(_CharT* __buffer) { _Rope_flatten_char_consumer(_CharT* __buffer)
_M_buf_ptr = __buffer; { _M_buf_ptr = __buffer; };
};
~_Rope_flatten_char_consumer() {} ~_Rope_flatten_char_consumer() {}
bool operator() (const _CharT* __leaf, size_t __n) {
bool
operator()(const _CharT* __leaf, size_t __n)
{
uninitialized_copy_n(__leaf, __n, _M_buf_ptr); uninitialized_copy_n(__leaf, __n, _M_buf_ptr);
_M_buf_ptr += __n; _M_buf_ptr += __n;
return true; return true;
} }
}; };
template<class _CharT> template<class _CharT>
class _Rope_find_char_char_consumer : public _Rope_char_consumer<_CharT> { class _Rope_find_char_char_consumer
: public _Rope_char_consumer<_CharT>
{
private: private:
_CharT _M_pattern; _CharT _M_pattern;
public: public:
size_t _M_count; // Number of nonmatching characters size_t _M_count; // Number of nonmatching characters
_Rope_find_char_char_consumer(_CharT __p) _Rope_find_char_char_consumer(_CharT __p)
: _M_pattern(__p), _M_count(0) {} : _M_pattern(__p), _M_count(0) {}
~_Rope_find_char_char_consumer() {} ~_Rope_find_char_char_consumer() {}
bool operator() (const _CharT* __leaf, size_t __n) {
bool
operator()(const _CharT* __leaf, size_t __n)
{
size_t __i; size_t __i;
for (__i = 0; __i < __n; __i++) { for (__i = 0; __i < __n; __i++)
if (__leaf[__i] == _M_pattern) { {
_M_count += __i; return false; if (__leaf[__i] == _M_pattern)
{
_M_count += __i;
return false;
} }
} }
_M_count += __n; return true; _M_count += __n; return true;
} }
}; };
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
// Here _CharT is both the stream and rope character type. // Here _CharT is both the stream and rope character type.
class _Rope_insert_char_consumer : public _Rope_char_consumer<_CharT> { class _Rope_insert_char_consumer
: public _Rope_char_consumer<_CharT>
{
private: private:
typedef basic_ostream<_CharT,_Traits> _Insert_ostream; typedef basic_ostream<_CharT,_Traits> _Insert_ostream;
_Insert_ostream& _M_o; _Insert_ostream& _M_o;
...@@ -821,46 +904,51 @@ class _Rope_insert_char_consumer : public _Rope_char_consumer<_CharT> { ...@@ -821,46 +904,51 @@ class _Rope_insert_char_consumer : public _Rope_char_consumer<_CharT> {
// Caller is presumed to own the ostream // Caller is presumed to own the ostream
bool operator() (const _CharT* __leaf, size_t __n); bool operator() (const _CharT* __leaf, size_t __n);
// Returns true to continue traversal. // Returns true to continue traversal.
}; };
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
bool _Rope_insert_char_consumer<_CharT, _Traits>::operator() bool
(const _CharT* __leaf, size_t __n) _Rope_insert_char_consumer<_CharT, _Traits>::
{ operator()(const _CharT* __leaf, size_t __n)
{
size_t __i; size_t __i;
// We assume that formatting is set up correctly for each element. // We assume that formatting is set up correctly for each element.
for (__i = 0; __i < __n; __i++) _M_o.put(__leaf[__i]); for (__i = 0; __i < __n; __i++)
_M_o.put(__leaf[__i]);
return true; return true;
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
bool rope<_CharT, _Alloc>::_S_apply_to_pieces( bool
_Rope_char_consumer<_CharT>& __c, rope<_CharT, _Alloc>::
const _RopeRep* __r, _S_apply_to_pieces(_Rope_char_consumer<_CharT>& __c,
size_t __begin, size_t __end) const _RopeRep* __r, size_t __begin, size_t __end)
{ {
if (0 == __r) return true; if (0 == __r)
switch(__r->_M_tag) { return true;
switch(__r->_M_tag)
{
case _Rope_constants::_S_concat: case _Rope_constants::_S_concat:
{ {
_RopeConcatenation* __conc = (_RopeConcatenation*)__r; _RopeConcatenation* __conc = (_RopeConcatenation*)__r;
_RopeRep* __left = __conc->_M_left; _RopeRep* __left = __conc->_M_left;
size_t __left_len = __left->_M_size; size_t __left_len = __left->_M_size;
if (__begin < __left_len) { if (__begin < __left_len)
{
size_t __left_end = std::min(__left_len, __end); size_t __left_end = std::min(__left_len, __end);
if (!_S_apply_to_pieces(__c, __left, __begin, __left_end)) if (!_S_apply_to_pieces(__c, __left, __begin, __left_end))
return false; return false;
} }
if (__end > __left_len) { if (__end > __left_len)
{
_RopeRep* __right = __conc->_M_right; _RopeRep* __right = __conc->_M_right;
size_t __right_start = std::max(__left_len, __begin); size_t __right_start = std::max(__left_len, __begin);
if (!_S_apply_to_pieces(__c, __right, if (!_S_apply_to_pieces(__c, __right,
__right_start - __left_len, __right_start - __left_len,
__end - __left_len)) { __end - __left_len))
return false; return false;
} }
} }
}
return true; return true;
case _Rope_constants::_S_leaf: case _Rope_constants::_S_leaf:
{ {
...@@ -875,7 +963,8 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces( ...@@ -875,7 +963,8 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces(
bool __result; bool __result;
_CharT* __buffer = _CharT* __buffer =
(_CharT*)_Alloc().allocate(__len * sizeof(_CharT)); (_CharT*)_Alloc().allocate(__len * sizeof(_CharT));
try { try
{
(*(__f->_M_fn))(__begin, __len, __buffer); (*(__f->_M_fn))(__begin, __len, __buffer);
__result = __c(__buffer, __len); __result = __c(__buffer, __len);
_Alloc().deallocate(__buffer, __len * sizeof(_CharT)); _Alloc().deallocate(__buffer, __len * sizeof(_CharT));
...@@ -890,26 +979,38 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces( ...@@ -890,26 +979,38 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces(
default: default:
return false; return false;
} }
} }
template<class _CharT, class _Traits> template<class _CharT, class _Traits>
inline void _Rope_fill(basic_ostream<_CharT, _Traits>& __o, size_t __n) inline void
{ _Rope_fill(basic_ostream<_CharT, _Traits>& __o, size_t __n)
{
char __f = __o.fill(); char __f = __o.fill();
size_t __i; size_t __i;
for (__i = 0; __i < __n; __i++) __o.put(__f); for (__i = 0; __i < __n; __i++)
} __o.put(__f);
}
template <class _CharT>
inline bool
_Rope_is_simple(_CharT*)
{ return false; }
inline bool
_Rope_is_simple(char*)
{ return true; }
template <class _CharT> inline bool _Rope_is_simple(_CharT*) { return false; } inline bool
inline bool _Rope_is_simple(char*) { return true; } _Rope_is_simple(wchar_t*)
inline bool _Rope_is_simple(wchar_t*) { return true; } { return true; }
template<class _CharT, class _Traits, class _Alloc> template<class _CharT, class _Traits, class _Alloc>
basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o, basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __o,
const rope<_CharT, _Alloc>& __r) const rope<_CharT, _Alloc>& __r)
{ {
size_t __w = __o.width(); size_t __w = __o.width();
bool __left = bool(__o.flags() & std::ios::left); bool __left = bool(__o.flags() & std::ios::left);
size_t __pad_len; size_t __pad_len;
...@@ -917,20 +1018,20 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o, ...@@ -917,20 +1018,20 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o,
_Rope_insert_char_consumer<_CharT, _Traits> __c(__o); _Rope_insert_char_consumer<_CharT, _Traits> __c(__o);
bool __is_simple = _Rope_is_simple((_CharT*)0); bool __is_simple = _Rope_is_simple((_CharT*)0);
if (__rope_len < __w) { if (__rope_len < __w)
__pad_len = __w - __rope_len; __pad_len = __w - __rope_len;
} else { else
__pad_len = 0; __pad_len = 0;
}
if (!__is_simple) __o.width(__w/__rope_len); if (!__is_simple)
try { __o.width(__w / __rope_len);
if (__is_simple && !__left && __pad_len > 0) { try
{
if (__is_simple && !__left && __pad_len > 0)
_Rope_fill(__o, __pad_len); _Rope_fill(__o, __pad_len);
}
__r.apply_to_pieces(0, __r.size(), __c); __r.apply_to_pieces(0, __r.size(), __c);
if (__is_simple && __left && __pad_len > 0) { if (__is_simple && __left && __pad_len > 0)
_Rope_fill(__o, __pad_len); _Rope_fill(__o, __pad_len);
}
if (!__is_simple) if (!__is_simple)
__o.width(__w); __o.width(__w);
} }
...@@ -941,38 +1042,43 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o, ...@@ -941,38 +1042,43 @@ basic_ostream<_CharT, _Traits>& operator<< (basic_ostream<_CharT, _Traits>& __o,
__throw_exception_again; __throw_exception_again;
} }
return __o; return __o;
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
_CharT* _CharT*
rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, rope<_CharT, _Alloc>::
size_t __start, size_t __len, _S_flatten(_RopeRep* __r, size_t __start, size_t __len,
_CharT* __buffer) _CharT* __buffer)
{ {
_Rope_flatten_char_consumer<_CharT> __c(__buffer); _Rope_flatten_char_consumer<_CharT> __c(__buffer);
_S_apply_to_pieces(__c, __r, __start, __start + __len); _S_apply_to_pieces(__c, __r, __start, __start + __len);
return(__buffer + __len); return(__buffer + __len);
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
size_t size_t
rope<_CharT,_Alloc>::find(_CharT __pattern, size_t __start) const rope<_CharT, _Alloc>::
{ find(_CharT __pattern, size_t __start) const
{
_Rope_find_char_char_consumer<_CharT> __c(__pattern); _Rope_find_char_char_consumer<_CharT> __c(__pattern);
_S_apply_to_pieces(__c, this->_M_tree_ptr, __start, size()); _S_apply_to_pieces(__c, this->_M_tree_ptr, __start, size());
size_type __result_pos = __start + __c._M_count; size_type __result_pos = __start + __c._M_count;
# ifndef __STL_OLD_ROPE_SEMANTICS #ifndef __STL_OLD_ROPE_SEMANTICS
if (__result_pos == size()) __result_pos = npos; if (__result_pos == size())
# endif __result_pos = npos;
#endif
return __result_pos; return __result_pos;
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
_CharT* _CharT*
rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer) rope<_CharT, _Alloc>::
{ _S_flatten(_RopeRep* __r, _CharT* __buffer)
if (0 == __r) return __buffer; {
switch(__r->_M_tag) { if (0 == __r)
return __buffer;
switch(__r->_M_tag)
{
case _Rope_constants::_S_concat: case _Rope_constants::_S_concat:
{ {
_RopeConcatenation* __c = (_RopeConcatenation*)__r; _RopeConcatenation* __c = (_RopeConcatenation*)__r;
...@@ -998,39 +1104,47 @@ rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer) ...@@ -998,39 +1104,47 @@ rope<_CharT,_Alloc>::_S_flatten(_RopeRep* __r, _CharT* __buffer)
default: default:
return 0; return 0;
} }
} }
// This needs work for _CharT != char // This needs work for _CharT != char
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void void
rope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent) rope<_CharT, _Alloc>::
{ _S_dump(_RopeRep* __r, int __indent)
for (int __i = 0; __i < __indent; __i++) putchar(' '); {
if (0 == __r) { for (int __i = 0; __i < __indent; __i++)
printf("NULL\n"); return; putchar(' ');
if (0 == __r)
{
printf("NULL\n");
return;
} }
if (_Rope_constants::_S_concat == __r->_M_tag) { if (_Rope_constants::_S_concat == __r->_M_tag)
{
_RopeConcatenation* __c = (_RopeConcatenation*)__r; _RopeConcatenation* __c = (_RopeConcatenation*)__r;
_RopeRep* __left = __c->_M_left; _RopeRep* __left = __c->_M_left;
_RopeRep* __right = __c->_M_right; _RopeRep* __right = __c->_M_right;
# ifdef __GC #ifdef __GC
printf("Concatenation %p (depth = %d, len = %ld, %s balanced)\n", printf("Concatenation %p (depth = %d, len = %ld, %s balanced)\n",
__r, __r->_M_depth, __r->_M_size, __r->_M_is_balanced? "" : "not"); __r, __r->_M_depth, __r->_M_size,
# else __r->_M_is_balanced? "" : "not");
#else
printf("Concatenation %p (rc = %ld, depth = %d, " printf("Concatenation %p (rc = %ld, depth = %d, "
"len = %ld, %s balanced)\n", "len = %ld, %s balanced)\n",
__r, __r->_M_ref_count, __r->_M_depth, __r->_M_size, __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size,
__r->_M_is_balanced? "" : "not"); __r->_M_is_balanced? "" : "not");
# endif #endif
_S_dump(__left, __indent + 2); _S_dump(__left, __indent + 2);
_S_dump(__right, __indent + 2); _S_dump(__right, __indent + 2);
return; return;
} else { }
else
{
char* __kind; char* __kind;
switch (__r->_M_tag) { switch (__r->_M_tag)
{
case _Rope_constants::_S_leaf: case _Rope_constants::_S_leaf:
__kind = "Leaf"; __kind = "Leaf";
break; break;
...@@ -1043,14 +1157,15 @@ rope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent) ...@@ -1043,14 +1157,15 @@ rope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent)
default: default:
__kind = "(corrupted kind field!)"; __kind = "(corrupted kind field!)";
} }
# ifdef __GC #ifdef __GC
printf("%s %p (depth = %d, len = %ld) ", printf("%s %p (depth = %d, len = %ld) ",
__kind, __r, __r->_M_depth, __r->_M_size); __kind, __r, __r->_M_depth, __r->_M_size);
# else #else
printf("%s %p (rc = %ld, depth = %d, len = %ld) ", printf("%s %p (rc = %ld, depth = %d, len = %ld) ",
__kind, __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size); __kind, __r, __r->_M_ref_count, __r->_M_depth, __r->_M_size);
# endif #endif
if (_S_is_one_byte_char_type((_CharT*)0)) { if (_S_is_one_byte_char_type((_CharT*)0))
{
const int __max_len = 40; const int __max_len = 40;
_Self_destruct_ptr __prefix(_S_substring(__r, 0, __max_len)); _Self_destruct_ptr __prefix(_S_substring(__r, 0, __max_len));
_CharT __buffer[__max_len + 1]; _CharT __buffer[__max_len + 1];
...@@ -1058,34 +1173,36 @@ rope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent) ...@@ -1058,34 +1173,36 @@ rope<_CharT,_Alloc>::_S_dump(_RopeRep* __r, int __indent)
_S_flatten(__prefix, __buffer); _S_flatten(__prefix, __buffer);
__buffer[__prefix->_M_size] = _S_eos((_CharT*)0); __buffer[__prefix->_M_size] = _S_eos((_CharT*)0);
printf("%s%s\n", printf("%s%s\n", (char*)__buffer,
(char*)__buffer, __too_big? "...\n" : "\n"); __too_big? "...\n" : "\n");
} else { }
else
printf("\n"); printf("\n");
} }
} }
}
template <class _CharT, class _Alloc>
template <class _CharT, class _Alloc> const unsigned long
const unsigned long rope<_CharT, _Alloc>::
rope<_CharT,_Alloc>::_S_min_len[_Rope_constants::_S_max_rope_depth + 1] = { _S_min_len[_Rope_constants::_S_max_rope_depth + 1] = {
/* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21, /* 0 */1, /* 1 */2, /* 2 */3, /* 3 */5, /* 4 */8, /* 5 */13, /* 6 */21,
/* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377, /* 7 */34, /* 8 */55, /* 9 */89, /* 10 */144, /* 11 */233, /* 12 */377,
/* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181, /* 13 */610, /* 14 */987, /* 15 */1597, /* 16 */2584, /* 17 */4181,
/* 18 */6765, /* 19 */10946, /* 20 */17711, /* 21 */28657, /* 22 */46368, /* 18 */6765, /* 19 */10946, /* 20 */17711, /* 21 */28657, /* 22 */46368,
/* 23 */75025, /* 24 */121393, /* 25 */196418, /* 26 */317811, /* 23 */75025, /* 24 */121393, /* 25 */196418, /* 26 */317811,
/* 27 */514229, /* 28 */832040, /* 29 */1346269, /* 30 */2178309, /* 27 */514229, /* 28 */832040, /* 29 */1346269, /* 30 */2178309,
/* 31 */3524578, /* 32 */5702887, /* 33 */9227465, /* 34 */14930352, /* 31 */3524578, /* 32 */5702887, /* 33 */9227465, /* 34 */14930352,
/* 35 */24157817, /* 36 */39088169, /* 37 */63245986, /* 38 */102334155, /* 35 */24157817, /* 36 */39088169, /* 37 */63245986, /* 38 */102334155,
/* 39 */165580141, /* 40 */267914296, /* 41 */433494437, /* 39 */165580141, /* 40 */267914296, /* 41 */433494437,
/* 42 */701408733, /* 43 */1134903170, /* 44 */1836311903, /* 42 */701408733, /* 43 */1134903170, /* 44 */1836311903,
/* 45 */2971215073u }; /* 45 */2971215073u };
// These are Fibonacci numbers < 2**32. // These are Fibonacci numbers < 2**32.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
typename rope<_CharT,_Alloc>::_RopeRep* typename rope<_CharT, _Alloc>::_RopeRep*
rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r) rope<_CharT, _Alloc>::
{ _S_balance(_RopeRep* __r)
{
_RopeRep* __forest[_Rope_constants::_S_max_rope_depth + 1]; _RopeRep* __forest[_Rope_constants::_S_max_rope_depth + 1];
_RopeRep* __result = 0; _RopeRep* __result = 0;
int __i; int __i;
...@@ -1097,18 +1214,20 @@ rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r) ...@@ -1097,18 +1214,20 @@ rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r)
for (__i = 0; __i <= _Rope_constants::_S_max_rope_depth; ++__i) for (__i = 0; __i <= _Rope_constants::_S_max_rope_depth; ++__i)
__forest[__i] = 0; __forest[__i] = 0;
try { try
{
_S_add_to_forest(__r, __forest); _S_add_to_forest(__r, __forest);
for (__i = 0; __i <= _Rope_constants::_S_max_rope_depth; ++__i) for (__i = 0; __i <= _Rope_constants::_S_max_rope_depth; ++__i)
if (0 != __forest[__i]) { if (0 != __forest[__i])
# ifndef __GC {
#ifndef __GC
_Self_destruct_ptr __old(__result); _Self_destruct_ptr __old(__result);
# endif #endif
__result = _S_concat(__forest[__i], __result); __result = _S_concat(__forest[__i], __result);
__forest[__i]->_M_unref_nonnil(); __forest[__i]->_M_unref_nonnil();
# if !defined(__GC) && defined(__EXCEPTIONS) #if !defined(__GC) && defined(__EXCEPTIONS)
__forest[__i] = 0; __forest[__i] = 0;
# endif #endif
} }
} }
catch(...) catch(...)
...@@ -1121,14 +1240,15 @@ rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r) ...@@ -1121,14 +1240,15 @@ rope<_CharT,_Alloc>::_S_balance(_RopeRep* __r)
if (__result->_M_depth > _Rope_constants::_S_max_rope_depth) if (__result->_M_depth > _Rope_constants::_S_max_rope_depth)
__throw_length_error(__N("rope::_S_balance")); __throw_length_error(__N("rope::_S_balance"));
return(__result); return(__result);
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void void
rope<_CharT,_Alloc>::_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest) rope<_CharT, _Alloc>::
{ _S_add_to_forest(_RopeRep* __r, _RopeRep** __forest)
if (__r->_M_is_balanced) { {
if (__r->_M_is_balanced)
{
_S_add_leaf_to_forest(__r, __forest); _S_add_leaf_to_forest(__r, __forest);
return; return;
} }
...@@ -1139,75 +1259,88 @@ rope<_CharT,_Alloc>::_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest) ...@@ -1139,75 +1259,88 @@ rope<_CharT,_Alloc>::_S_add_to_forest(_RopeRep* __r, _RopeRep** __forest)
_S_add_to_forest(__c->_M_left, __forest); _S_add_to_forest(__c->_M_left, __forest);
_S_add_to_forest(__c->_M_right, __forest); _S_add_to_forest(__c->_M_right, __forest);
} }
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
void void
rope<_CharT,_Alloc>::_S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest) rope<_CharT, _Alloc>::
{ _S_add_leaf_to_forest(_RopeRep* __r, _RopeRep** __forest)
{
_RopeRep* __insertee; // included in refcount _RopeRep* __insertee; // included in refcount
_RopeRep* __too_tiny = 0; // included in refcount _RopeRep* __too_tiny = 0; // included in refcount
int __i; // forest[0..__i-1] is empty int __i; // forest[0..__i-1] is empty
size_t __s = __r->_M_size; size_t __s = __r->_M_size;
for (__i = 0; __s >= _S_min_len[__i+1]/* not this bucket */; ++__i) { for (__i = 0; __s >= _S_min_len[__i+1]/* not this bucket */; ++__i)
if (0 != __forest[__i]) { {
# ifndef __GC if (0 != __forest[__i])
{
#ifndef __GC
_Self_destruct_ptr __old(__too_tiny); _Self_destruct_ptr __old(__too_tiny);
# endif #endif
__too_tiny = _S_concat_and_set_balanced(__forest[__i], __too_tiny); __too_tiny = _S_concat_and_set_balanced(__forest[__i],
__too_tiny);
__forest[__i]->_M_unref_nonnil(); __forest[__i]->_M_unref_nonnil();
__forest[__i] = 0; __forest[__i] = 0;
} }
} }
{ {
# ifndef __GC #ifndef __GC
_Self_destruct_ptr __old(__too_tiny); _Self_destruct_ptr __old(__too_tiny);
# endif #endif
__insertee = _S_concat_and_set_balanced(__too_tiny, __r); __insertee = _S_concat_and_set_balanced(__too_tiny, __r);
} }
// Too_tiny dead, and no longer included in refcount. // Too_tiny dead, and no longer included in refcount.
// Insertee is live and included. // Insertee is live and included.
for (;; ++__i) { for (;; ++__i)
if (0 != __forest[__i]) { {
# ifndef __GC if (0 != __forest[__i])
{
#ifndef __GC
_Self_destruct_ptr __old(__insertee); _Self_destruct_ptr __old(__insertee);
# endif #endif
__insertee = _S_concat_and_set_balanced(__forest[__i], __insertee); __insertee = _S_concat_and_set_balanced(__forest[__i],
__insertee);
__forest[__i]->_M_unref_nonnil(); __forest[__i]->_M_unref_nonnil();
__forest[__i] = 0; __forest[__i] = 0;
} }
if (__i == _Rope_constants::_S_max_rope_depth || if (__i == _Rope_constants::_S_max_rope_depth
__insertee->_M_size < _S_min_len[__i+1]) { || __insertee->_M_size < _S_min_len[__i+1])
{
__forest[__i] = __insertee; __forest[__i] = __insertee;
// refcount is OK since __insertee is now dead. // refcount is OK since __insertee is now dead.
return; return;
} }
} }
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
_CharT _CharT
rope<_CharT,_Alloc>::_S_fetch(_RopeRep* __r, size_type __i) rope<_CharT, _Alloc>::
{ _S_fetch(_RopeRep* __r, size_type __i)
{
__GC_CONST _CharT* __cstr = __r->_M_c_string; __GC_CONST _CharT* __cstr = __r->_M_c_string;
if (0 != __cstr) return __cstr[__i]; if (0 != __cstr)
for(;;) { return __cstr[__i];
switch(__r->_M_tag) { for(;;)
{
switch(__r->_M_tag)
{
case _Rope_constants::_S_concat: case _Rope_constants::_S_concat:
{ {
_RopeConcatenation* __c = (_RopeConcatenation*)__r; _RopeConcatenation* __c = (_RopeConcatenation*)__r;
_RopeRep* __left = __c->_M_left; _RopeRep* __left = __c->_M_left;
size_t __left_len = __left->_M_size; size_t __left_len = __left->_M_size;
if (__i >= __left_len) { if (__i >= __left_len)
{
__i -= __left_len; __i -= __left_len;
__r = __c->_M_right; __r = __c->_M_right;
} else {
__r = __left;
} }
else
__r = __left;
} }
break; break;
case _Rope_constants::_S_leaf: case _Rope_constants::_S_leaf:
...@@ -1226,34 +1359,40 @@ rope<_CharT,_Alloc>::_S_fetch(_RopeRep* __r, size_type __i) ...@@ -1226,34 +1359,40 @@ rope<_CharT,_Alloc>::_S_fetch(_RopeRep* __r, size_type __i)
} }
} }
} }
} }
# ifndef __GC #ifndef __GC
// Return a uniquely referenced character slot for the given // Return a uniquely referenced character slot for the given
// position, or 0 if that's not possible. // position, or 0 if that's not possible.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
_CharT* _CharT*
rope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i) rope<_CharT, _Alloc>::
{ _S_fetch_ptr(_RopeRep* __r, size_type __i)
{
_RopeRep* __clrstack[_Rope_constants::_S_max_rope_depth]; _RopeRep* __clrstack[_Rope_constants::_S_max_rope_depth];
size_t __csptr = 0; size_t __csptr = 0;
for(;;) { for(;;)
if (__r->_M_ref_count > 1) return 0; {
switch(__r->_M_tag) { if (__r->_M_ref_count > 1)
return 0;
switch(__r->_M_tag)
{
case _Rope_constants::_S_concat: case _Rope_constants::_S_concat:
{ {
_RopeConcatenation* __c = (_RopeConcatenation*)__r; _RopeConcatenation* __c = (_RopeConcatenation*)__r;
_RopeRep* __left = __c->_M_left; _RopeRep* __left = __c->_M_left;
size_t __left_len = __left->_M_size; size_t __left_len = __left->_M_size;
if (__c->_M_c_string != 0) __clrstack[__csptr++] = __c; if (__c->_M_c_string != 0)
if (__i >= __left_len) { __clrstack[__csptr++] = __c;
if (__i >= __left_len)
{
__i -= __left_len; __i -= __left_len;
__r = __c->_M_right; __r = __c->_M_right;
} else {
__r = __left;
} }
else
__r = __left;
} }
break; break;
case _Rope_constants::_S_leaf: case _Rope_constants::_S_leaf:
...@@ -1261,7 +1400,8 @@ rope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i) ...@@ -1261,7 +1400,8 @@ rope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i)
_RopeLeaf* __l = (_RopeLeaf*)__r; _RopeLeaf* __l = (_RopeLeaf*)__r;
if (__l->_M_c_string != __l->_M_data && __l->_M_c_string != 0) if (__l->_M_c_string != __l->_M_data && __l->_M_c_string != 0)
__clrstack[__csptr++] = __l; __clrstack[__csptr++] = __l;
while (__csptr > 0) { while (__csptr > 0)
{
-- __csptr; -- __csptr;
_RopeRep* __d = __clrstack[__csptr]; _RopeRep* __d = __clrstack[__csptr];
__d->_M_free_c_string(); __d->_M_free_c_string();
...@@ -1274,129 +1414,143 @@ rope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i) ...@@ -1274,129 +1414,143 @@ rope<_CharT,_Alloc>::_S_fetch_ptr(_RopeRep* __r, size_type __i)
return 0; return 0;
} }
} }
} }
# endif /* __GC */ #endif /* __GC */
// The following could be implemented trivially using // The following could be implemented trivially using
// lexicographical_compare_3way. // lexicographical_compare_3way.
// We do a little more work to avoid dealing with rope iterators for // We do a little more work to avoid dealing with rope iterators for
// flat strings. // flat strings.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
int int
rope<_CharT,_Alloc>::_S_compare (const _RopeRep* __left, rope<_CharT, _Alloc>::
const _RopeRep* __right) _S_compare (const _RopeRep* __left, const _RopeRep* __right)
{ {
size_t __left_len; size_t __left_len;
size_t __right_len; size_t __right_len;
if (0 == __right) return 0 != __left; if (0 == __right)
if (0 == __left) return -1; return 0 != __left;
if (0 == __left)
return -1;
__left_len = __left->_M_size; __left_len = __left->_M_size;
__right_len = __right->_M_size; __right_len = __right->_M_size;
if (_Rope_constants::_S_leaf == __left->_M_tag) { if (_Rope_constants::_S_leaf == __left->_M_tag)
{
_RopeLeaf* __l = (_RopeLeaf*) __left; _RopeLeaf* __l = (_RopeLeaf*) __left;
if (_RopeRep::_S_leaf == __right->_M_tag) { if (_RopeRep::_S_leaf == __right->_M_tag)
{
_RopeLeaf* __r = (_RopeLeaf*) __right; _RopeLeaf* __r = (_RopeLeaf*) __right;
return lexicographical_compare_3way( return lexicographical_compare_3way(__l->_M_data,
__l->_M_data, __l->_M_data + __left_len, __l->_M_data + __left_len,
__r->_M_data, __r->_M_data + __right_len); __r->_M_data, __r->_M_data
} else { + __right_len);
}
else
{
const_iterator __rstart(__right, 0); const_iterator __rstart(__right, 0);
const_iterator __rend(__right, __right_len); const_iterator __rend(__right, __right_len);
return lexicographical_compare_3way( return lexicographical_compare_3way(__l->_M_data, __l->_M_data
__l->_M_data, __l->_M_data + __left_len, + __left_len,
__rstart, __rend); __rstart, __rend);
} }
} else { }
else
{
const_iterator __lstart(__left, 0); const_iterator __lstart(__left, 0);
const_iterator __lend(__left, __left_len); const_iterator __lend(__left, __left_len);
if (_Rope_constants::_S_leaf == __right->_M_tag) { if (_Rope_constants::_S_leaf == __right->_M_tag)
{
_RopeLeaf* __r = (_RopeLeaf*) __right; _RopeLeaf* __r = (_RopeLeaf*) __right;
return lexicographical_compare_3way( return lexicographical_compare_3way(__lstart, __lend,
__lstart, __lend, __r->_M_data, __r->_M_data
__r->_M_data, __r->_M_data + __right_len); + __right_len);
} else { }
else
{
const_iterator __rstart(__right, 0); const_iterator __rstart(__right, 0);
const_iterator __rend(__right, __right_len); const_iterator __rend(__right, __right_len);
return lexicographical_compare_3way( return lexicographical_compare_3way(__lstart, __lend,
__lstart, __lend,
__rstart, __rend); __rstart, __rend);
} }
} }
} }
// Assignment to reference proxies. // Assignment to reference proxies.
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
_Rope_char_ref_proxy<_CharT, _Alloc>& _Rope_char_ref_proxy<_CharT, _Alloc>&
_Rope_char_ref_proxy<_CharT, _Alloc>::operator= (_CharT __c) { _Rope_char_ref_proxy<_CharT, _Alloc>::
operator=(_CharT __c)
{
_RopeRep* __old = _M_root->_M_tree_ptr; _RopeRep* __old = _M_root->_M_tree_ptr;
# ifndef __GC #ifndef __GC
// First check for the case in which everything is uniquely // First check for the case in which everything is uniquely
// referenced. In that case we can do this destructively. // referenced. In that case we can do this destructively.
_CharT* __ptr = _My_rope::_S_fetch_ptr(__old, _M_pos); _CharT* __ptr = _My_rope::_S_fetch_ptr(__old, _M_pos);
if (0 != __ptr) { if (0 != __ptr)
{
*__ptr = __c; *__ptr = __c;
return *this; return *this;
} }
# endif #endif
_Self_destruct_ptr __left( _Self_destruct_ptr __left(_My_rope::_S_substring(__old, 0, _M_pos));
_My_rope::_S_substring(__old, 0, _M_pos)); _Self_destruct_ptr __right(_My_rope::_S_substring(__old, _M_pos + 1,
_Self_destruct_ptr __right( __old->_M_size));
_My_rope::_S_substring(__old, _M_pos+1, __old->_M_size)); _Self_destruct_ptr __result_left(_My_rope::
_Self_destruct_ptr __result_left( _S_destr_concat_char_iter(__left,
_My_rope::_S_destr_concat_char_iter(__left, &__c, 1)); &__c, 1));
_RopeRep* __result = _RopeRep* __result = _My_rope::_S_concat(__result_left, __right);
_My_rope::_S_concat(__result_left, __right); #ifndef __GC
# ifndef __GC
_RopeRep::_S_unref(__old); _RopeRep::_S_unref(__old);
# endif #endif
_M_root->_M_tree_ptr = __result; _M_root->_M_tree_ptr = __result;
return *this; return *this;
} }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
inline _Rope_char_ref_proxy<_CharT, _Alloc>::operator _CharT () const inline _Rope_char_ref_proxy<_CharT, _Alloc>::
{ operator _CharT() const
if (_M_current_valid) { {
if (_M_current_valid)
return _M_current; return _M_current;
} else { else
return _My_rope::_S_fetch(_M_root->_M_tree_ptr, _M_pos); return _My_rope::_S_fetch(_M_root->_M_tree_ptr, _M_pos);
} }
}
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
_Rope_char_ptr_proxy<_CharT, _Alloc> _Rope_char_ptr_proxy<_CharT, _Alloc>
_Rope_char_ref_proxy<_CharT, _Alloc>::operator& () const { _Rope_char_ref_proxy<_CharT, _Alloc>::
return _Rope_char_ptr_proxy<_CharT, _Alloc>(*this); operator&() const
} { return _Rope_char_ptr_proxy<_CharT, _Alloc>(*this); }
template <class _CharT, class _Alloc> template <class _CharT, class _Alloc>
rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c, rope<_CharT, _Alloc>::
const allocator_type& __a) rope(size_t __n, _CharT __c, const allocator_type& __a)
: _Base(__a) : _Base(__a)
{ {
rope<_CharT,_Alloc> __result; rope<_CharT,_Alloc> __result;
const size_t __exponentiate_threshold = 32; const size_t __exponentiate_threshold = 32;
size_t __exponent; size_t __exponent;
size_t __rest; size_t __rest;
_CharT* __rest_buffer; _CharT* __rest_buffer;
_RopeRep* __remainder; _RopeRep* __remainder;
rope<_CharT,_Alloc> __remainder_rope; rope<_CharT, _Alloc> __remainder_rope;
if (0 == __n) if (0 == __n)
return; return;
__exponent = __n / __exponentiate_threshold; __exponent = __n / __exponentiate_threshold;
__rest = __n % __exponentiate_threshold; __rest = __n % __exponentiate_threshold;
if (0 == __rest) { if (0 == __rest)
__remainder = 0; __remainder = 0;
} else { else
{
__rest_buffer = this->_Data_allocate(_S_rounded_up_size(__rest)); __rest_buffer = this->_Data_allocate(_S_rounded_up_size(__rest));
uninitialized_fill_n(__rest_buffer, __rest, __c); uninitialized_fill_n(__rest_buffer, __rest, __c);
_S_cond_store_eos(__rest_buffer[__rest]); _S_cond_store_eos(__rest_buffer[__rest]);
try { try
__remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a); { __remainder = _S_new_RopeLeaf(__rest_buffer, __rest, __a); }
}
catch(...) catch(...)
{ {
_RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a); _RopeRep::__STL_FREE_STRING(__rest_buffer, __rest, __a);
...@@ -1404,14 +1558,16 @@ rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c, ...@@ -1404,14 +1558,16 @@ rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,
} }
} }
__remainder_rope._M_tree_ptr = __remainder; __remainder_rope._M_tree_ptr = __remainder;
if (__exponent != 0) { if (__exponent != 0)
{
_CharT* __base_buffer = _CharT* __base_buffer =
this->_Data_allocate(_S_rounded_up_size(__exponentiate_threshold)); this->_Data_allocate(_S_rounded_up_size(__exponentiate_threshold));
_RopeLeaf* __base_leaf; _RopeLeaf* __base_leaf;
rope __base_rope; rope __base_rope;
uninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c); uninitialized_fill_n(__base_buffer, __exponentiate_threshold, __c);
_S_cond_store_eos(__base_buffer[__exponentiate_threshold]); _S_cond_store_eos(__base_buffer[__exponentiate_threshold]);
try { try
{
__base_leaf = _S_new_RopeLeaf(__base_buffer, __base_leaf = _S_new_RopeLeaf(__base_buffer,
__exponentiate_threshold, __a); __exponentiate_threshold, __a);
} }
...@@ -1422,28 +1578,33 @@ rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c, ...@@ -1422,28 +1578,33 @@ rope<_CharT, _Alloc>::rope(size_t __n, _CharT __c,
__throw_exception_again; __throw_exception_again;
} }
__base_rope._M_tree_ptr = __base_leaf; __base_rope._M_tree_ptr = __base_leaf;
if (1 == __exponent) { if (1 == __exponent)
__result = __base_rope; __result = __base_rope;
} else { else
__result = power(__base_rope, __exponent, __result = power(__base_rope, __exponent,
_Rope_Concat_fn<_CharT,_Alloc>()); _Rope_Concat_fn<_CharT, _Alloc>());
}
if (0 != __remainder) { if (0 != __remainder)
__result += __remainder_rope; __result += __remainder_rope;
} }
} else { else
__result = __remainder_rope; __result = __remainder_rope;
}
this->_M_tree_ptr = __result._M_tree_ptr; this->_M_tree_ptr = __result._M_tree_ptr;
this->_M_tree_ptr->_M_ref_nonnil(); this->_M_tree_ptr->_M_ref_nonnil();
} }
template<class _CharT, class _Alloc> template<class _CharT, class _Alloc>
_CharT rope<_CharT,_Alloc>::_S_empty_c_str[1]; _CharT
rope<_CharT, _Alloc>::_S_empty_c_str[1];
template<class _CharT, class _Alloc> template<class _CharT, class _Alloc>
const _CharT* rope<_CharT,_Alloc>::c_str() const { const _CharT*
if (0 == this->_M_tree_ptr) { rope<_CharT, _Alloc>::
c_str() const
{
if (0 == this->_M_tree_ptr)
{
_S_empty_c_str[0] = _S_eos((_CharT*)0); // Possibly redundant, _S_empty_c_str[0] = _S_eos((_CharT*)0); // Possibly redundant,
// but probably fast. // but probably fast.
return _S_empty_c_str; return _S_empty_c_str;
...@@ -1460,76 +1621,78 @@ const _CharT* rope<_CharT,_Alloc>::c_str() const { ...@@ -1460,76 +1621,78 @@ const _CharT* rope<_CharT,_Alloc>::c_str() const {
} }
__gthread_mutex_unlock (&this->_M_tree_ptr->_M_c_string_lock); __gthread_mutex_unlock (&this->_M_tree_ptr->_M_c_string_lock);
return(__result); return(__result);
} }
template<class _CharT, class _Alloc> template<class _CharT, class _Alloc>
const _CharT* rope<_CharT,_Alloc>::replace_with_c_str() { const _CharT* rope<_CharT, _Alloc>::
if (0 == this->_M_tree_ptr) { replace_with_c_str()
{
if (0 == this->_M_tree_ptr)
{
_S_empty_c_str[0] = _S_eos((_CharT*)0); _S_empty_c_str[0] = _S_eos((_CharT*)0);
return _S_empty_c_str; return _S_empty_c_str;
} }
__GC_CONST _CharT* __old_c_string = this->_M_tree_ptr->_M_c_string; __GC_CONST _CharT* __old_c_string = this->_M_tree_ptr->_M_c_string;
if (_Rope_constants::_S_leaf == this->_M_tree_ptr->_M_tag if (_Rope_constants::_S_leaf == this->_M_tree_ptr->_M_tag
&& 0 != __old_c_string) { && 0 != __old_c_string)
return(__old_c_string); return(__old_c_string);
}
size_t __s = size(); size_t __s = size();
_CharT* __result = this->_Data_allocate(_S_rounded_up_size(__s)); _CharT* __result = this->_Data_allocate(_S_rounded_up_size(__s));
_S_flatten(this->_M_tree_ptr, __result); _S_flatten(this->_M_tree_ptr, __result);
__result[__s] = _S_eos((_CharT*)0); __result[__s] = _S_eos((_CharT*)0);
this->_M_tree_ptr->_M_unref_nonnil(); this->_M_tree_ptr->_M_unref_nonnil();
this->_M_tree_ptr = _S_new_RopeLeaf(__result, __s, this->get_allocator()); this->_M_tree_ptr = _S_new_RopeLeaf(__result, __s,
this->get_allocator());
return(__result); return(__result);
} }
// Algorithm specializations. More should be added. // Algorithm specializations. More should be added.
template<class _Rope_iterator> // was templated on CharT and Alloc template<class _Rope_iterator> // was templated on CharT and Alloc
void // VC++ workaround void // VC++ workaround
_Rope_rotate(_Rope_iterator __first, _Rope_rotate(_Rope_iterator __first,
_Rope_iterator __middle, _Rope_iterator __middle,
_Rope_iterator __last) _Rope_iterator __last)
{ {
typedef typename _Rope_iterator::value_type _CharT; typedef typename _Rope_iterator::value_type _CharT;
typedef typename _Rope_iterator::_allocator_type _Alloc; typedef typename _Rope_iterator::_allocator_type _Alloc;
rope<_CharT,_Alloc>& __r(__first.container()); rope<_CharT, _Alloc>& __r(__first.container());
rope<_CharT,_Alloc> __prefix = __r.substr(0, __first.index()); rope<_CharT, _Alloc> __prefix = __r.substr(0, __first.index());
rope<_CharT,_Alloc> __suffix = rope<_CharT, _Alloc> __suffix =
__r.substr(__last.index(), __r.size() - __last.index()); __r.substr(__last.index(), __r.size() - __last.index());
rope<_CharT,_Alloc> __part1 = rope<_CharT, _Alloc> __part1 =
__r.substr(__middle.index(), __last.index() - __middle.index()); __r.substr(__middle.index(), __last.index() - __middle.index());
rope<_CharT,_Alloc> __part2 = rope<_CharT, _Alloc> __part2 =
__r.substr(__first.index(), __middle.index() - __first.index()); __r.substr(__first.index(), __middle.index() - __first.index());
__r = __prefix; __r = __prefix;
__r += __part1; __r += __part1;
__r += __part2; __r += __part2;
__r += __suffix; __r += __suffix;
} }
#if !defined(__GNUC__) #if !defined(__GNUC__)
// Appears to confuse g++ // Appears to confuse g++
inline void rotate(_Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __first, inline void
_Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __middle, rotate(_Rope_iterator<char, __STL_DEFAULT_ALLOCATOR(char)> __first,
_Rope_iterator<char,__STL_DEFAULT_ALLOCATOR(char)> __last) { _Rope_iterator<char, __STL_DEFAULT_ALLOCATOR(char)> __middle,
_Rope_rotate(__first, __middle, __last); _Rope_iterator<char, __STL_DEFAULT_ALLOCATOR(char)> __last)
} { _Rope_rotate(__first, __middle, __last); }
#endif #endif
# if 0 # if 0
// Probably not useful for several reasons: // Probably not useful for several reasons:
// - for SGIs 7.1 compiler and probably some others, // - for SGIs 7.1 compiler and probably some others,
// this forces lots of rope<wchar_t, ...> instantiations, creating a // this forces lots of rope<wchar_t, ...> instantiations, creating a
// code bloat and compile time problem. (Fixed in 7.2.) // code bloat and compile time problem. (Fixed in 7.2.)
// - wchar_t is 4 bytes wide on most UNIX platforms, making it unattractive // - wchar_t is 4 bytes wide on most UNIX platforms, making it
// for unicode strings. Unsigned short may be a better character // unattractive for unicode strings. Unsigned short may be a better
// type. // character type.
inline void rotate( inline void
_Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __first, rotate(_Rope_iterator<wchar_t, __STL_DEFAULT_ALLOCATOR(char)> __first,
_Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __middle, _Rope_iterator<wchar_t, __STL_DEFAULT_ALLOCATOR(char)> __middle,
_Rope_iterator<wchar_t,__STL_DEFAULT_ALLOCATOR(char)> __last) { _Rope_iterator<wchar_t, __STL_DEFAULT_ALLOCATOR(char)> __last)
_Rope_rotate(__first, __middle, __last); { _Rope_rotate(__first, __middle, __last); }
}
# endif # endif
} // namespace __gnu_cxx } // namespace __gnu_cxx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment