stl_algo.h: Enums as _S_.

2003-05-06  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/stl_algo.h: Enums as _S_.
	* include/bits/stl_tree.h: Same.
	* include/bits/stl_bvector.h: Same.
	* include/bits/ios_base.h: Same.
	* include/bits/stl_alloc.h: Same.
	* include/ext/stl_hashtable.h: Same.
	* src/ios.cc: And here.

	* include/std/std_sstream.h: Replace _M_really_sync to _M_sync.
	* include/bits/sstream.tcc: Same.

        * include/bits/basic_ios.h: Correct spacing for '< ctype'.

	* include/bits/locale_facets.tcc: Replace __temp to __tmp.

	* include/bits/locale_facets.h (__num_base): Remove protected.
	Use _S_[io]* names for enumerations.
	(_S_format_int): Remove.
	* include/bits/locale_facets.tcc: Same.
	* src/locale.cc: Same.

	* include/std/std_sstream.h (stringbuf::str): Tweak formatting.

From-SVN: r66552
This commit is contained in:
Benjamin Kosnik 2003-05-07 05:01:59 +00:00 committed by Benjamin Kosnik
parent 057c56df52
commit 655d78212b
14 changed files with 179 additions and 187 deletions

View File

@ -1,3 +1,28 @@
2003-05-06 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/stl_algo.h: Enums as _S_.
* include/bits/stl_tree.h: Same.
* include/bits/stl_bvector.h: Same.
* include/bits/ios_base.h: Same.
* include/bits/stl_alloc.h: Same.
* include/ext/stl_hashtable.h: Same.
* src/ios.cc: And here.
* include/std/std_sstream.h: Replace _M_really_sync to _M_sync.
* include/bits/sstream.tcc: Same.
* include/bits/basic_ios.h: Correct spacing for '< ctype'.
* include/bits/locale_facets.tcc: Replace __temp to __tmp.
* include/bits/locale_facets.h (__num_base): Remove protected.
Use _S_[io]* names for enumerations.
(_S_format_int): Remove.
* include/bits/locale_facets.tcc: Same.
* src/locale.cc: Same.
* include/std/std_sstream.h (stringbuf::str): Tweak formatting.
2003-05-06 Phil Edwards <pme@gcc.gnu.org>
* docs/html/faq/index.html (3.10): Add note about mips atomicity.h.

View File

@ -384,7 +384,7 @@ namespace std
*
* Returns the result of
* @code
* std::use_facet< ctype<char_type> >(getloc()).narrow(c,dfault)
* std::use_facet<ctype<char_type> >(getloc()).narrow(c,dfault)
* @endcode
*
* Additional l10n notes are at
@ -402,7 +402,7 @@ namespace std
*
* Returns the result of
* @code
* std::use_facet< ctype<char_type> >(getloc()).widen(c)
* std::use_facet<ctype<char_type> >(getloc()).widen(c)
* @endcode
*
* Additional l10n notes are at

View File

@ -52,7 +52,7 @@ namespace std
// as permitted (but not required) in the standard, in order to provide
// better type safety in iostream calls. A side effect is that
// expressions involving them are no longer compile-time constants.
enum _Ios_Fmtflags { _M_ios_fmtflags_end = 1L << 16 };
enum _Ios_Fmtflags { _S_ios_fmtflags_end = 1L << 16 };
inline _Ios_Fmtflags
operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
@ -83,7 +83,7 @@ namespace std
{ return _Ios_Fmtflags(~static_cast<int>(__a)); }
enum _Ios_Openmode { _M_ios_openmode_end = 1L << 16 };
enum _Ios_Openmode { _S_ios_openmode_end = 1L << 16 };
inline _Ios_Openmode
operator&(_Ios_Openmode __a, _Ios_Openmode __b)
@ -114,7 +114,7 @@ namespace std
{ return _Ios_Openmode(~static_cast<int>(__a)); }
enum _Ios_Iostate { _M_ios_iostate_end = 1L << 16 };
enum _Ios_Iostate { _S_ios_iostate_end = 1L << 16 };
inline _Ios_Iostate
operator&(_Ios_Iostate __a, _Ios_Iostate __b)
@ -144,7 +144,7 @@ namespace std
operator~(_Ios_Iostate __a)
{ return _Ios_Iostate(~static_cast<int>(__a)); }
enum _Ios_Seekdir { _M_ios_seekdir_end = 1L << 16 };
enum _Ios_Seekdir { _S_ios_seekdir_end = 1L << 16 };
class __locale_cache_base;
@ -180,8 +180,8 @@ namespace std
what() const throw();
private:
enum { _M_bufsize = 256 };
char _M_name[_M_bufsize];
enum { _S_bufsize = 256 };
char _M_name[_S_bufsize];
#endif
};

View File

@ -536,17 +536,17 @@ namespace std
// Below are the indices into _S_atoms_out.
enum
{
_S_minus,
_S_plus,
_S_x,
_S_X,
_S_digits,
_S_digits_end = _S_digits + 16,
_S_udigits = _S_digits_end,
_S_udigits_end = _S_udigits + 16,
_S_e = _S_digits + 14, // For scientific notation, 'e'
_S_E = _S_udigits + 14, // For scientific notation, 'E'
_S_end = _S_udigits_end
_S_ominus,
_S_oplus,
_S_ox,
_S_oX,
_S_odigits,
_S_odigits_end = _S_odigits + 16,
_S_oudigits = _S_odigits_end,
_S_oudigits_end = _S_oudigits + 16,
_S_oe = _S_odigits + 14, // For scientific notation, 'e'
_S_oE = _S_oudigits + 14, // For scientific notation, 'E'
_S_oend = _S_oudigits_end
};
// A list of valid numeric literals for output. This array
@ -556,27 +556,22 @@ namespace std
// "-+xX0123456789abcdef0123456789ABCDEF".
static const char* _S_atoms_out;
protected:
// String literal of acceptable (narrow) input, for num_get.
// "0123456789eEabcdfABCDF"
static const char* _S_atoms_in;
enum
{
_M_zero,
_M_e = _M_zero + 10,
_M_E = _M_zero + 11,
_M_size = 21 + 1
_S_izero,
_S_ie = _S_izero + 10,
_S_iE = _S_izero + 11,
_S_iend = 21 + 1
};
// num_put
// Construct and return valid scanf format for floating point types.
static void
_S_format_float(const ios_base& __io, char* __fptr, char __mod);
// Construct and return valid scanf format for integer types.
static void
_S_format_int(const ios_base& __io, char* __fptr, char __mod, char __modl);
};
@ -1966,7 +1961,7 @@ namespace std
// locale, this is "-+xX0123456789abcdef0123456789ABCDEF". This
// array contains the chars after having been passed through the
// current locale's ctype<_CharT>.widen().
_CharT _M_literals[__num_base::_S_end];
_CharT _M_literals[__num_base::_S_oend];
// The sign used to separate decimal values: for standard US
// locales, this would usually be: "." Abstracted from

View File

@ -113,7 +113,7 @@ namespace std
}
// Next, strip leading zeros.
const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
const char_type __zero = __ctype.widen(_S_atoms_in[_S_izero]);
bool __found_zero = false;
while (__traits_type::eq(__c, __zero) && __beg != __end)
{
@ -122,12 +122,12 @@ namespace std
}
if (__found_zero)
{
__xtrc += _S_atoms_in[_M_zero];
__xtrc += _S_atoms_in[_S_izero];
++__pos;
}
// Only need acceptable digits for floating point numbers.
const size_t __len = _M_E - _M_zero + 1;
const size_t __len = _S_iE - _S_izero + 1;
char_type __watoms[__len];
__ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
bool __found_dec = false;
@ -183,8 +183,8 @@ namespace std
__c = *(++__beg);
__found_dec = true;
}
else if ((__traits_type::eq(__c, __watoms[_M_e])
|| __traits_type::eq(__c, __watoms[_M_E]))
else if ((__traits_type::eq(__c, __watoms[_S_ie])
|| __traits_type::eq(__c, __watoms[_S_iE]))
&& !__found_sci && __pos)
{
// Scientific notation.
@ -261,7 +261,7 @@ namespace std
}
// Next, strip leading zeros and check required digits for base formats.
const char_type __zero = __ctype.widen(_S_atoms_in[_M_zero]);
const char_type __zero = __ctype.widen(_S_atoms_in[_S_izero]);
const char_type __x = __ctype.widen('x');
const char_type __X = __ctype.widen('X');
if (__base == 10)
@ -274,7 +274,7 @@ namespace std
}
if (__found_zero)
{
__xtrc += _S_atoms_in[_M_zero];
__xtrc += _S_atoms_in[_S_izero];
++__pos;
if (__basefield == 0)
{
@ -296,7 +296,7 @@ namespace std
{
if (__traits_type::eq(__c, __zero) && __beg != __end)
{
__xtrc += _S_atoms_in[_M_zero];
__xtrc += _S_atoms_in[_S_izero];
++__pos;
__c = *(++__beg);
if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X))
@ -313,12 +313,12 @@ namespace std
// base digits as valid input.
size_t __len;
if (__base == 16)
__len = _M_size;
__len = _S_iend;
else
__len = __base;
// Extract.
char_type __watoms[_M_size];
char_type __watoms[_S_iend];
__ctype.widen(_S_atoms_in, _S_atoms_in + __len, __watoms);
string __found_grouping;
const string __grouping = __np.grouping();
@ -682,19 +682,19 @@ namespace std
// Octal.
do
{
*__buf-- = __lit[(__v & 0x7) + __num_base::_S_digits];
*__buf-- = __lit[(__v & 0x7) + __num_base::_S_odigits];
__v >>= 3;
}
while (__v != 0);
if (__showbase)
*__buf-- = __lit[__num_base::_S_digits];
*__buf-- = __lit[__num_base::_S_odigits];
}
else if (__builtin_expect(__basefield == ios_base::hex, false))
{
// Hex.
const bool __uppercase = __flags & ios_base::uppercase;
int __case_offset = __uppercase
? __num_base::_S_udigits : __num_base::_S_digits;
int __case_offset = __uppercase ? __num_base::_S_oudigits
: __num_base::_S_odigits;
do
{
*__buf-- = __lit[(__v & 0xf) + __case_offset];
@ -704,9 +704,9 @@ namespace std
if (__showbase)
{
// 'x' or 'X'
*__buf-- = __lit[__num_base::_S_x + __uppercase];
*__buf-- = __lit[__num_base::_S_ox + __uppercase];
// '0'
*__buf-- = __lit[__num_base::_S_digits];
*__buf-- = __lit[__num_base::_S_odigits];
}
}
else
@ -714,14 +714,14 @@ namespace std
// Decimal.
do
{
*__buf-- = __lit[(__v % 10) + __num_base::_S_digits];
*__buf-- = __lit[(__v % 10) + __num_base::_S_odigits];
__v /= 10;
}
while (__v != 0);
if (__neg)
*__buf-- = __lit[__num_base::_S_minus];
*__buf-- = __lit[__num_base::_S_ominus];
else if (__flags & ios_base::showpos)
*__buf-- = __lit[__num_base::_S_plus];
*__buf-- = __lit[__num_base::_S_oplus];
}
int __ret = __bufend - __buf - 1;
return __ret;
@ -1128,7 +1128,7 @@ namespace std
bool __testdecfound = false;
// The tentative returned string is stored here.
string_type __temp_units;
string_type __tmp_units;
char_type __c = *__beg;
char_type __eof = static_cast<char_type>(char_traits<char_type>::eof());
@ -1223,7 +1223,7 @@ namespace std
}
else
{
__temp_units += __c;
__tmp_units += __c;
++__sep_pos;
}
__c = *(++__beg);
@ -1254,11 +1254,11 @@ namespace std
}
// Strip leading zeros.
while (__temp_units[0] == __ctype.widen('0'))
__temp_units.erase(__temp_units.begin());
while (__tmp_units[0] == __ctype.widen('0'))
__tmp_units.erase(__tmp_units.begin());
if (__sign.size() && __sign == __neg_sign)
__temp_units.insert(__temp_units.begin(), __ctype.widen('-'));
__tmp_units.insert(__tmp_units.begin(), __ctype.widen('-'));
// Test for grouping fidelity.
if (__grouping.size() && __grouping_tmp.size())
@ -1272,11 +1272,11 @@ namespace std
__err |= ios_base::eofbit;
// Iff valid sequence is not recognized.
if (!__testvalid || !__temp_units.size())
if (!__testvalid || !__tmp_units.size())
__err |= ios_base::failbit;
else
// Use the "swap trick" to copy __temp_units into __units.
__temp_units.swap(__units);
// Use the "swap trick" to copy __tmp_units into __units.
__tmp_units.swap(__units);
return __beg;
}
@ -2281,7 +2281,7 @@ namespace std
{
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
__ct.widen(__num_base::_S_atoms_out,
__num_base::_S_atoms_out + __num_base::_S_end,
__num_base::_S_atoms_out + __num_base::_S_oend,
_M_literals);
}
}

View File

@ -110,9 +110,9 @@ namespace std
_M_string.swap(__tmp);
// Just to be sure...
_M_string.reserve(__len);
_M_really_sync(const_cast<char_type*>(_M_string.data()),
this->_M_in_cur - this->_M_in_beg,
this->_M_out_cur - this->_M_out_beg);
_M_sync(const_cast<char_type*>(_M_string.data()),
this->_M_in_cur - this->_M_in_beg,
this->_M_out_cur - this->_M_out_beg);
}
return this->sputc(traits_type::to_char_type(__c));
}

View File

@ -1,6 +1,6 @@
// Algorithm implementation -*- C++ -*-
// Copyright (C) 2001, 2002 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
@ -1926,7 +1926,7 @@ __result, __binary_pred, _IterType());
* This controls some aspect of the sort routines.
* @endif
*/
enum { _M_threshold = 16 };
enum { _S_threshold = 16 };
/**
* @if maint
@ -2053,9 +2053,9 @@ __result, __binary_pred, _IterType());
void
__final_insertion_sort(_RandomAccessIter __first, _RandomAccessIter __last)
{
if (__last - __first > _M_threshold) {
__insertion_sort(__first, __first + _M_threshold);
__unguarded_insertion_sort(__first + _M_threshold, __last);
if (__last - __first > _S_threshold) {
__insertion_sort(__first, __first + _S_threshold);
__unguarded_insertion_sort(__first + _S_threshold, __last);
}
else
__insertion_sort(__first, __last);
@ -2071,9 +2071,9 @@ __result, __binary_pred, _IterType());
__final_insertion_sort(_RandomAccessIter __first, _RandomAccessIter __last,
_Compare __comp)
{
if (__last - __first > _M_threshold) {
__insertion_sort(__first, __first + _M_threshold, __comp);
__unguarded_insertion_sort(__first + _M_threshold, __last, __comp);
if (__last - __first > _S_threshold) {
__insertion_sort(__first, __first + _S_threshold, __comp);
__unguarded_insertion_sort(__first + _S_threshold, __last, __comp);
}
else
__insertion_sort(__first, __last, __comp);
@ -2105,7 +2105,7 @@ __result, __binary_pred, _IterType());
{
typedef typename iterator_traits<_RandomAccessIter>::value_type _ValueType;
while (__last - __first > _M_threshold) {
while (__last - __first > _S_threshold) {
if (__depth_limit == 0) {
partial_sort(__first, __last, __last);
return;
@ -2133,7 +2133,7 @@ __result, __binary_pred, _IterType());
{
typedef typename iterator_traits<_RandomAccessIter>::value_type _ValueType;
while (__last - __first > _M_threshold) {
while (__last - __first > _S_threshold) {
if (__depth_limit == 0) {
partial_sort(__first, __last, __last, __comp);
return;
@ -2300,7 +2300,7 @@ __result, __binary_pred, _IterType());
__comp);
}
enum { _M_chunk_size = 7 };
enum { _S_chunk_size = 7 };
template<typename _RandomAccessIter, typename _Distance>
void
@ -2336,7 +2336,7 @@ __result, __binary_pred, _IterType());
_Distance __len = __last - __first;
_Pointer __buffer_last = __buffer + __len;
_Distance __step_size = _M_chunk_size;
_Distance __step_size = _S_chunk_size;
__chunk_insertion_sort(__first, __last, __step_size);
while (__step_size < __len) {
@ -2357,7 +2357,7 @@ __result, __binary_pred, _IterType());
_Distance __len = __last - __first;
_Pointer __buffer_last = __buffer + __len;
_Distance __step_size = _M_chunk_size;
_Distance __step_size = _S_chunk_size;
__chunk_insertion_sort(__first, __last, __step_size, __comp);
while (__step_size < __len) {

View File

@ -260,7 +260,7 @@ namespace std
*
* Important implementation properties:
* 0. If globally mandated, then allocate objects from __new_alloc
* 1. If the clients request an object of size > _MAX_BYTES, the resulting
* 1. If the clients request an object of size > _S_max_bytes, the resulting
* object will be obtained directly from __new_alloc
* 2. In all other cases, we allocate an object of size exactly
* _S_round_up(requested_size). Thus the client has enough size
@ -286,9 +286,9 @@ namespace std
class __pool_alloc
{
private:
enum {_ALIGN = 8};
enum {_MAX_BYTES = 128};
enum {_NFREELISTS = _MAX_BYTES / _ALIGN};
enum {_S_align = 8};
enum {_S_max_bytes = 128};
enum {_S_freelists = _S_max_bytes / _S_align};
union _Obj
{
@ -296,7 +296,7 @@ namespace std
char _M_client_data[1]; // The client sees this.
};
static _Obj* volatile _S_free_list[_NFREELISTS];
static _Obj* volatile _S_free_list[_S_freelists];
// Chunk allocation state.
static char* _S_start_free;
@ -308,11 +308,11 @@ namespace std
static size_t
_S_round_up(size_t __bytes)
{ return (((__bytes) + (size_t) _ALIGN-1) & ~((size_t) _ALIGN - 1)); }
{ return (((__bytes) + (size_t) _S_align-1) & ~((size_t) _S_align - 1)); }
static size_t
_S_freelist_index(size_t __bytes)
{ return (((__bytes) + (size_t)_ALIGN - 1)/(size_t)_ALIGN - 1); }
{ return (((__bytes) + (size_t)_S_align - 1)/(size_t)_S_align - 1); }
// Returns an object of size __n, and optionally adds to size __n
// free list.
@ -351,7 +351,7 @@ namespace std
__atomic_add(&_S_force_new, -1);
}
if ((__n > (size_t) _MAX_BYTES) || (_S_force_new > 0))
if ((__n > (size_t) _S_max_bytes) || (_S_force_new > 0))
__ret = __new_alloc::allocate(__n);
else
{
@ -379,7 +379,7 @@ namespace std
static void
deallocate(void* __p, size_t __n)
{
if ((__n > (size_t) _MAX_BYTES) || (_S_force_new > 0))
if ((__n > (size_t) _S_max_bytes) || (_S_force_new > 0))
__new_alloc::deallocate(__p, __n);
else
{
@ -462,7 +462,7 @@ namespace std
// do not try smaller requests, since that tends to result
// in disaster on multi-process machines.
__i = __size;
for (; __i <= (size_t) _MAX_BYTES; __i += (size_t) _ALIGN)
for (; __i <= (size_t) _S_max_bytes; __i += (size_t) _S_align)
{
__my_free_list = _S_free_list + _S_freelist_index(__i);
__p = *__my_free_list;
@ -541,7 +541,7 @@ namespace std
template<bool __threads, int __inst>
typename __pool_alloc<__threads,__inst>::_Obj* volatile
__pool_alloc<__threads,__inst>::_S_free_list[_NFREELISTS];
__pool_alloc<__threads,__inst>::_S_free_list[_S_freelists];
typedef __pool_alloc<true,0> __alloc;
typedef __pool_alloc<false,0> __single_client_alloc;

View File

@ -64,7 +64,7 @@
namespace std
{
typedef unsigned long _Bit_type;
enum { _M_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) };
enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) };
struct _Bit_reference {
@ -100,24 +100,24 @@ struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool>
: _M_p(__x), _M_offset(__y) {}
void _M_bump_up() {
if (_M_offset++ == _M_word_bit - 1) {
if (_M_offset++ == _S_word_bit - 1) {
_M_offset = 0;
++_M_p;
}
}
void _M_bump_down() {
if (_M_offset-- == 0) {
_M_offset = _M_word_bit - 1;
_M_offset = _S_word_bit - 1;
--_M_p;
}
}
void _M_incr(ptrdiff_t __i) {
difference_type __n = __i + _M_offset;
_M_p += __n / _M_word_bit;
__n = __n % _M_word_bit;
_M_p += __n / _S_word_bit;
__n = __n % _S_word_bit;
if (__n < 0) {
_M_offset = (unsigned int) __n + _M_word_bit;
_M_offset = (unsigned int) __n + _S_word_bit;
--_M_p;
} else
_M_offset = (unsigned int) __n;
@ -145,7 +145,7 @@ struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool>
inline ptrdiff_t
operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
return _M_word_bit * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset;
return _S_word_bit * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset;
}
@ -277,7 +277,7 @@ public:
protected:
_Bit_type * _M_bit_alloc(size_t __n)
{ return _M_data_allocator.allocate((__n + _M_word_bit - 1)/_M_word_bit); }
{ return _M_data_allocator.allocate((__n + _S_word_bit - 1)/_S_word_bit); }
void _M_deallocate() {
if (_M_start._M_p)
_M_data_allocator.deallocate(_M_start._M_p,
@ -307,7 +307,7 @@ protected:
_Alloc_type;
_Bit_type * _M_bit_alloc(size_t __n)
{ return _Alloc_type::allocate((__n + _M_word_bit - 1)/_M_word_bit); }
{ return _Alloc_type::allocate((__n + _S_word_bit - 1)/_S_word_bit); }
void _M_deallocate() {
if (_M_start._M_p)
_Alloc_type::deallocate(_M_start._M_p,
@ -374,7 +374,7 @@ template <typename _Alloc>
protected:
void _M_initialize(size_type __n) {
_Bit_type * __q = _M_bit_alloc(__n);
this->_M_end_of_storage = __q + (__n + _M_word_bit - 1)/_M_word_bit;
this->_M_end_of_storage = __q + (__n + _S_word_bit - 1)/_S_word_bit;
this->_M_start = iterator(__q, 0);
this->_M_finish = this->_M_start + difference_type(__n);
}
@ -386,13 +386,13 @@ template <typename _Alloc>
}
else {
size_type __len = size()
? 2 * size() : static_cast<size_type>(_M_word_bit);
? 2 * size() : static_cast<size_type>(_S_word_bit);
_Bit_type * __q = _M_bit_alloc(__len);
iterator __i = copy(begin(), __position, iterator(__q, 0));
*__i++ = __x;
this->_M_finish = copy(__position, end(), __i);
_M_deallocate();
this->_M_end_of_storage = __q + (__len + _M_word_bit - 1)/_M_word_bit;
this->_M_end_of_storage = __q + (__len + _S_word_bit - 1)/_S_word_bit;
this->_M_start = iterator(__q, 0);
}
}
@ -445,7 +445,7 @@ template <typename _Alloc>
this->_M_finish = copy(__position, end(), __i);
_M_deallocate();
this->_M_end_of_storage
= __q + (__len + _M_word_bit - 1)/_M_word_bit;
= __q + (__len + _S_word_bit - 1)/_S_word_bit;
this->_M_start = iterator(__q, 0);
}
}
@ -613,7 +613,7 @@ template <typename _Alloc>
this->_M_finish = copy(begin(), end(), iterator(__q, 0));
_M_deallocate();
this->_M_start = iterator(__q, 0);
this->_M_end_of_storage = __q + (__n + _M_word_bit - 1)/_M_word_bit;
this->_M_end_of_storage = __q + (__n + _S_word_bit - 1)/_S_word_bit;
}
}
@ -687,7 +687,7 @@ template <typename _Alloc>
fill_n(__i, __n, __x);
this->_M_finish = copy(__position, end(), __i + difference_type(__n));
_M_deallocate();
this->_M_end_of_storage = __q + (__len + _M_word_bit - 1)/_M_word_bit;
this->_M_end_of_storage = __q + (__len + _S_word_bit - 1)/_S_word_bit;
this->_M_start = iterator(__q, 0);
}
}

View File

@ -90,7 +90,7 @@ iterators invalidated are those referring to the deleted node.
namespace std
{
enum _Rb_tree_color { _M_red = false, _M_black = true };
enum _Rb_tree_color { _S_red = false, _S_black = true };
struct _Rb_tree_node_base
{
@ -156,7 +156,7 @@ namespace std
void
_M_decrement()
{
if (_M_node->_M_color == _M_red
if (_M_node->_M_color == _S_red
&& _M_node->_M_parent->_M_parent == _M_node)
_M_node = _M_node->_M_right;
else if (_M_node->_M_left != 0)
@ -305,18 +305,18 @@ namespace std
inline void
_Rb_tree_rebalance(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)
{
__x->_M_color = _M_red;
__x->_M_color = _S_red;
while (__x != __root
&& __x->_M_parent->_M_color == _M_red)
&& __x->_M_parent->_M_color == _S_red)
{
if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left)
{
_Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right;
if (__y && __y->_M_color == _M_red)
if (__y && __y->_M_color == _S_red)
{
__x->_M_parent->_M_color = _M_black;
__y->_M_color = _M_black;
__x->_M_parent->_M_parent->_M_color = _M_red;
__x->_M_parent->_M_color = _S_black;
__y->_M_color = _S_black;
__x->_M_parent->_M_parent->_M_color = _S_red;
__x = __x->_M_parent->_M_parent;
}
else
@ -326,19 +326,19 @@ namespace std
__x = __x->_M_parent;
_Rb_tree_rotate_left(__x, __root);
}
__x->_M_parent->_M_color = _M_black;
__x->_M_parent->_M_parent->_M_color = _M_red;
__x->_M_parent->_M_color = _S_black;
__x->_M_parent->_M_parent->_M_color = _S_red;
_Rb_tree_rotate_right(__x->_M_parent->_M_parent, __root);
}
}
else
{
_Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left;
if (__y && __y->_M_color == _M_red)
if (__y && __y->_M_color == _S_red)
{
__x->_M_parent->_M_color = _M_black;
__y->_M_color = _M_black;
__x->_M_parent->_M_parent->_M_color = _M_red;
__x->_M_parent->_M_color = _S_black;
__y->_M_color = _S_black;
__x->_M_parent->_M_parent->_M_color = _S_red;
__x = __x->_M_parent->_M_parent;
}
else
@ -348,13 +348,13 @@ namespace std
__x = __x->_M_parent;
_Rb_tree_rotate_right(__x, __root);
}
__x->_M_parent->_M_color = _M_black;
__x->_M_parent->_M_parent->_M_color = _M_red;
__x->_M_parent->_M_color = _S_black;
__x->_M_parent->_M_parent->_M_color = _S_red;
_Rb_tree_rotate_left(__x->_M_parent->_M_parent, __root);
}
}
}
__root->_M_color = _M_black;
__root->_M_color = _S_black;
}
inline _Rb_tree_node_base*
@ -430,42 +430,42 @@ namespace std
else // __x == __z->_M_left
__rightmost = _Rb_tree_node_base::_S_maximum(__x);
}
if (__y->_M_color != _M_red)
if (__y->_M_color != _S_red)
{
while (__x != __root && (__x == 0 || __x->_M_color == _M_black))
while (__x != __root && (__x == 0 || __x->_M_color == _S_black))
if (__x == __x_parent->_M_left)
{
_Rb_tree_node_base* __w = __x_parent->_M_right;
if (__w->_M_color == _M_red)
if (__w->_M_color == _S_red)
{
__w->_M_color = _M_black;
__x_parent->_M_color = _M_red;
__w->_M_color = _S_black;
__x_parent->_M_color = _S_red;
_Rb_tree_rotate_left(__x_parent, __root);
__w = __x_parent->_M_right;
}
if ((__w->_M_left == 0 ||
__w->_M_left->_M_color == _M_black) &&
__w->_M_left->_M_color == _S_black) &&
(__w->_M_right == 0 ||
__w->_M_right->_M_color == _M_black))
__w->_M_right->_M_color == _S_black))
{
__w->_M_color = _M_red;
__w->_M_color = _S_red;
__x = __x_parent;
__x_parent = __x_parent->_M_parent;
}
else
{
if (__w->_M_right == 0
|| __w->_M_right->_M_color == _M_black)
|| __w->_M_right->_M_color == _S_black)
{
__w->_M_left->_M_color = _M_black;
__w->_M_color = _M_red;
__w->_M_left->_M_color = _S_black;
__w->_M_color = _S_red;
_Rb_tree_rotate_right(__w, __root);
__w = __x_parent->_M_right;
}
__w->_M_color = __x_parent->_M_color;
__x_parent->_M_color = _M_black;
__x_parent->_M_color = _S_black;
if (__w->_M_right)
__w->_M_right->_M_color = _M_black;
__w->_M_right->_M_color = _S_black;
_Rb_tree_rotate_left(__x_parent, __root);
break;
}
@ -474,40 +474,40 @@ namespace std
{
// same as above, with _M_right <-> _M_left.
_Rb_tree_node_base* __w = __x_parent->_M_left;
if (__w->_M_color == _M_red)
if (__w->_M_color == _S_red)
{
__w->_M_color = _M_black;
__x_parent->_M_color = _M_red;
__w->_M_color = _S_black;
__x_parent->_M_color = _S_red;
_Rb_tree_rotate_right(__x_parent, __root);
__w = __x_parent->_M_left;
}
if ((__w->_M_right == 0 ||
__w->_M_right->_M_color == _M_black) &&
__w->_M_right->_M_color == _S_black) &&
(__w->_M_left == 0 ||
__w->_M_left->_M_color == _M_black))
__w->_M_left->_M_color == _S_black))
{
__w->_M_color = _M_red;
__w->_M_color = _S_red;
__x = __x_parent;
__x_parent = __x_parent->_M_parent;
}
else
{
if (__w->_M_left == 0 || __w->_M_left->_M_color == _M_black)
if (__w->_M_left == 0 || __w->_M_left->_M_color == _S_black)
{
__w->_M_right->_M_color = _M_black;
__w->_M_color = _M_red;
__w->_M_right->_M_color = _S_black;
__w->_M_color = _S_red;
_Rb_tree_rotate_left(__w, __root);
__w = __x_parent->_M_left;
}
__w->_M_color = __x_parent->_M_color;
__x_parent->_M_color = _M_black;
__x_parent->_M_color = _S_black;
if (__w->_M_left)
__w->_M_left->_M_color = _M_black;
__w->_M_left->_M_color = _S_black;
_Rb_tree_rotate_right(__x_parent, __root);
break;
}
}
if (__x) __x->_M_color = _M_black;
if (__x) __x->_M_color = _S_black;
}
return __y;
}
@ -737,7 +737,7 @@ namespace std
_M_empty_initialize();
else
{
_S_color(this->_M_header) = _M_red;
_S_color(this->_M_header) = _S_red;
_M_root() = _M_copy(__x._M_root(), this->_M_header);
_M_leftmost() = _S_minimum(_M_root());
_M_rightmost() = _S_maximum(_M_root());
@ -753,7 +753,7 @@ namespace std
private:
void _M_empty_initialize()
{
_S_color(this->_M_header) = _M_red; // used to distinguish header from
_S_color(this->_M_header) = _S_red; // used to distinguish header from
// __root, in iterator.operator++
_M_root() = 0;
_M_leftmost() = this->_M_header;
@ -1417,7 +1417,7 @@ namespace std
int __sum = 0;
do
{
if (__node->_M_color == _M_black)
if (__node->_M_color == _S_black)
++__sum;
if (__node == __root)
break;
@ -1444,9 +1444,9 @@ namespace std
_Link_type __L = _S_left(__x);
_Link_type __R = _S_right(__x);
if (__x->_M_color == _M_red)
if ((__L && __L->_M_color == _M_red)
|| (__R && __R->_M_color == _M_red))
if (__x->_M_color == _S_red)
if ((__L && __L->_M_color == _S_red)
|| (__R && __R->_M_color == _S_red))
return false;
if (__L && _M_key_compare(_S_key(__x), _S_key(__L)))

View File

@ -1,6 +1,6 @@
// Hashtable implementation used by containers -*- C++ -*-
// Copyright (C) 2001, 2002 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
@ -180,9 +180,9 @@ struct _Hashtable_const_iterator {
};
// Note: assumes long is at least 32 bits.
enum { __stl_num_primes = 28 };
enum { _S_num_primes = 28 };
static const unsigned long __stl_prime_list[__stl_num_primes] =
static const unsigned long __stl_prime_list[_S_num_primes] =
{
53ul, 97ul, 193ul, 389ul, 769ul,
1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
@ -195,7 +195,7 @@ static const unsigned long __stl_prime_list[__stl_num_primes] =
inline unsigned long __stl_next_prime(unsigned long __n)
{
const unsigned long* __first = __stl_prime_list;
const unsigned long* __last = __stl_prime_list + (int)__stl_num_primes;
const unsigned long* __last = __stl_prime_list + (int)_S_num_primes;
const unsigned long* pos = std::lower_bound(__first, __last, __n);
return pos == __last ? *(__last - 1) : *pos;
}
@ -363,7 +363,7 @@ public:
size_type bucket_count() const { return _M_buckets.size(); }
size_type max_bucket_count() const
{ return __stl_prime_list[(int)__stl_num_primes - 1]; }
{ return __stl_prime_list[(int)_S_num_primes - 1]; }
size_type elems_in_bucket(size_type __bucket) const
{

View File

@ -133,11 +133,10 @@ namespace std
__string_type
str() const
{
const bool __testout = this->_M_mode & ios_base::out;
__string_type __ret = _M_string;
const bool __testout = this->_M_mode & ios_base::out;
if (__testout && this->_M_out_beg < this->_M_out_lim)
__ret = __string_type(this->_M_out_beg,
this->_M_out_lim);
__ret = __string_type(this->_M_out_beg, this->_M_out_lim);
return __ret;
}
@ -171,7 +170,7 @@ namespace std
__size_type __len = 0;
if (this->_M_mode & (ios_base::ate | ios_base::app))
__len = _M_string.size();
_M_really_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
_M_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
}
// Overridden virtual functions:
@ -220,7 +219,7 @@ namespace std
_M_string = __string_type(__s, __n);
// Step 2: Use the external array.
_M_really_sync(__s, 0, 0);
_M_sync(__s, 0, 0);
}
return this;
}
@ -247,7 +246,7 @@ namespace std
* @endif
*/
virtual void
_M_really_sync(char_type* __base, __size_type __i, __size_type __o)
_M_sync(char_type* __base, __size_type __i, __size_type __o)
{
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;

View File

@ -142,8 +142,8 @@ namespace std
ios_base::failure::failure(const string& __str) throw()
{
strncpy(_M_name, __str.c_str(), _M_bufsize);
_M_name[_M_bufsize - 1] = '\0';
strncpy(_M_name, __str.c_str(), _S_bufsize);
_M_name[_S_bufsize - 1] = '\0';
}
ios_base::failure::~failure() throw()

View File

@ -531,32 +531,5 @@ namespace std
*__fptr++ = (__flags & ios_base::uppercase) ? 'G' : 'g';
*__fptr = '\0';
}
void
__num_base::_S_format_int(const ios_base& __io, char* __fptr, char __mod,
char __modl)
{
ios_base::fmtflags __flags = __io.flags();
*__fptr++ = '%';
// [22.2.2.2.2] Table 60
if (__flags & ios_base::showpos)
*__fptr++ = '+';
if (__flags & ios_base::showbase)
*__fptr++ = '#';
*__fptr++ = 'l';
// For long long types.
if (__modl)
*__fptr++ = __modl;
ios_base::fmtflags __bsefield = __flags & ios_base::basefield;
if (__bsefield == ios_base::hex)
*__fptr++ = (__flags & ios_base::uppercase) ? 'X' : 'x';
else if (__bsefield == ios_base::oct)
*__fptr++ = 'o';
else
*__fptr++ = __mod;
*__fptr = '\0';
}
} // namespace std