diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0595fddf706..8e8b6f827bc 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,8 +1,15 @@ 2000-06-02 Benjamin Kosnik + * bits/locale_facets.h: Tweak. + * src/locale.cc (codecvt): Tweak. + * bits/locale_facets.h (_Format_cache): _S_ecks -> _S_x. * bits/locale_facets.tcc (num_get::_M_extract): Fix for hex. + * bits/basic_string.h: Move data member up. + * src/string-inst.cc: Fix instantiations. + * bits/string.tcc: Fix types. + 2000-06-02 Anthony Williams * testsuite/21_strings/replace.cc (test01): Qualify find with std::. diff --git a/libstdc++-v3/bits/basic_string.h b/libstdc++-v3/bits/basic_string.h index b7d73cab623..99401e6053f 100644 --- a/libstdc++-v3/bits/basic_string.h +++ b/libstdc++-v3/bits/basic_string.h @@ -97,11 +97,6 @@ namespace std { typedef reverse_iterator const_reverse_iterator; typedef reverse_iterator reverse_iterator; - // Data Members: - // NB: This is an unsigned type, and thus represents the maximum - // size that the allocator can hold. - static const size_type npos = static_cast(-1); - private: // _Rep: string representation // Invariants: @@ -222,8 +217,20 @@ namespace std { _CharT* _M_p; // The actual data. }; + public: + // Data Members (public): + // NB: This is an unsigned type, and thus represents the maximum + // size that the allocator can hold. + static const size_type npos = static_cast(-1); + + private: + // Data Members (private): mutable _Alloc_hider _M_dataplus; + // The following storage is init'd to 0 by the linker, resulting + // (carefully) in an empty string with one reference. + static size_type _S_empty_rep_storage[(sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)]; + _CharT* _M_data() const { return _M_dataplus._M_p; } @@ -299,14 +306,9 @@ namespace std { void _M_leak_hard(); - // The following storage is init'd to 0 by the linker, resulting - // (carefully) in an empty string with one reference. - static size_type _S_empty_rep_storage[ - (sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type)-1)/sizeof(size_type)]; - static _Rep& _S_empty_rep() - { return *reinterpret_cast<_Rep*> (&_S_empty_rep_storage); } + { return *reinterpret_cast<_Rep*>(&_S_empty_rep_storage); } public: // Construct/copy/destroy: @@ -840,7 +842,7 @@ namespace std { private: static const _CharT* - _S_find (const _CharT* __beg, const _CharT* __end, _CharT __c); + _S_find(const _CharT* __beg, const _CharT* __end, _CharT __c); }; diff --git a/libstdc++-v3/bits/locale_facets.h b/libstdc++-v3/bits/locale_facets.h index 3c1cca2bbc5..2568585f82b 100644 --- a/libstdc++-v3/bits/locale_facets.h +++ b/libstdc++-v3/bits/locale_facets.h @@ -597,7 +597,7 @@ namespace std // Types: typedef _InternT intern_type; typedef _ExternT extern_type; - typedef _StateT state_type; + typedef _StateT state_type; // Data Members: static locale::id id; @@ -618,8 +618,8 @@ namespace std { public: // Types: - typedef char intern_type; - typedef char extern_type; + typedef char intern_type; + typedef char extern_type; typedef mbstate_t state_type; explicit codecvt (size_t __refs = 0); @@ -657,8 +657,8 @@ namespace std { public: // Types: - typedef wchar_t intern_type; - typedef char extern_type; + typedef wchar_t intern_type; + typedef char extern_type; typedef mbstate_t state_type; explicit codecvt(size_t __refs = 0); @@ -774,7 +774,7 @@ namespace std // A list of valid numeric literals: for the standard "C" locale, // this would usually be: "-+xX0123456789abcdef0123456789ABCDEF" - static const char _S_literals[]; + static const char _S_literals[]; // NB: Code depends on the order of definitions of the names // these are indices into _S_literals, above. diff --git a/libstdc++-v3/bits/string.tcc b/libstdc++-v3/bits/string.tcc index 63c0301776a..73b4d98a9a5 100644 --- a/libstdc++-v3/bits/string.tcc +++ b/libstdc++-v3/bits/string.tcc @@ -399,7 +399,7 @@ namespace std // Linker sets _S_empty_rep_storage to all 0s (one reference, empty string) // at static init time (before static ctors are run). template - typename _Alloc::size_type + basic_string<_CharT, _Traits, _Alloc>::size_type basic_string<_CharT, _Traits, _Alloc>::_S_empty_rep_storage[ (sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)]; diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index a70c6723ece..3327ea2d6ec 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -41,7 +41,8 @@ namespace std { // locale::_Impl - locale::_Impl::~_Impl() throw () + locale::_Impl:: + ~_Impl() throw() { std::vector::iterator it = _M_facets->begin(); for (; it != _M_facets->end(); ++it) @@ -50,7 +51,8 @@ namespace std { delete _M_category_names; } - locale::_Impl::_Impl(size_t __numfacets, size_t __refs) + locale::_Impl:: + _Impl(size_t __numfacets, size_t __refs) : _M_num_references(__refs - 1) , _M_facets(0) , _M_category_names(0) @@ -68,7 +70,8 @@ namespace std { _M_category_names = __pcn.release(); } - locale::_Impl::_Impl(const _Impl& __other, size_t __refs) + locale::_Impl:: + _Impl(const _Impl& __other, size_t __refs) : _M_num_references(__refs) , _M_facets(0) , _M_category_names(0) @@ -95,7 +98,8 @@ namespace std { } void - locale::_Impl::_M_replace_categories(const _Impl* __other, category __cats) + locale::_Impl:: + _M_replace_categories(const _Impl* __other, category __cats) { assert((__cats & locale::all) && !(__cats & ~locale::all)); @@ -111,16 +115,16 @@ namespace std { } void - locale::_Impl::_M_replace_category(const _Impl* __other, - const locale::id* const* __idpp) + locale::_Impl:: + _M_replace_category(const _Impl* __other, const locale::id* const* __idpp) { for (; *__idpp; ++__idpp) _M_replace_facet(__other, *__idpp); } void - locale::_Impl::_M_replace_facet(const _Impl* __other, - const locale::id* __idp) + locale::_Impl:: + _M_replace_facet(const _Impl* __other, const locale::id* __idp) { size_t __index = __idp->_M_index; if (__index == 0 @@ -132,7 +136,8 @@ namespace std { } void - locale::_Impl::_M_install_facet(const locale::id* __idp, facet* __fp) + locale::_Impl:: + _M_install_facet(const locale::id* __idp, facet* __fp) { if (__fp == 0) return; @@ -260,11 +265,13 @@ namespace std { locale::_Impl* locale::_S_global; // init'd to 0 before static ctors run locale::_Impl* locale::_S_classic; // init'd to 0 before static ctors run - locale::locale(_Impl* __ip) throw () + locale:: + locale(_Impl* __ip) throw() : _M_impl(__ip) { __ip->_M_add_reference(); } - locale::locale(const locale& __other, const locale& __one, category __cats) + locale:: + locale(const locale& __other, const locale& __one, category __cats) { __cats = _S_normalize_category(__cats); // might throw _M_impl = new _Impl(*__other._M_impl, 1); // might throw @@ -283,7 +290,8 @@ namespace std { } const locale& - locale::operator=(const locale& __other) throw () + locale:: + operator=(const locale& __other) throw() { __other._M_impl->_M_add_reference(); _M_impl->_M_remove_reference(); @@ -292,7 +300,8 @@ namespace std { } locale - locale::global(const locale& __other) + locale:: + global(const locale& __other) { // XXX MT _S_initialize(); @@ -306,14 +315,16 @@ namespace std { } string - locale::name() const + locale:: + name() const { // XXX not done return "*"; } locale const& - locale::classic() + locale:: + classic() { static locale* __classic_locale; // XXX MT @@ -321,7 +332,7 @@ namespace std { { try { _S_classic = _S_global = new _Impl(26u, 2u); - // one reference for _M_classic, one for _M_global + // One reference for _M_classic, one for _M_global // (constructor for (*the_classic_locale) adds a third) // collate category @@ -329,22 +340,22 @@ namespace std { // ctype category _S_classic->_M_init_facet(new std::ctype); - _S_classic->_M_init_facet(new std::codecvt); + _S_classic->_M_init_facet(new codecvt); // monetary category - _S_classic->_M_init_facet(new std::moneypunct); - _S_classic->_M_init_facet(new std::moneypunct); - _S_classic->_M_init_facet(new std::money_get); - _S_classic->_M_init_facet(new std::money_put); + _S_classic->_M_init_facet(new moneypunct); + _S_classic->_M_init_facet(new moneypunct); + _S_classic->_M_init_facet(new money_get); + _S_classic->_M_init_facet(new money_put); // numeric category - _S_classic->_M_init_facet(new std::numpunct); - _S_classic->_M_init_facet(new std::num_get); - _S_classic->_M_init_facet(new std::num_put); + _S_classic->_M_init_facet(new numpunct); + _S_classic->_M_init_facet(new num_get); + _S_classic->_M_init_facet(new num_put); // time category - _S_classic->_M_init_facet(new std::time_get); - _S_classic->_M_init_facet(new std::time_put); + _S_classic->_M_init_facet(new time_get); + _S_classic->_M_init_facet(new time_put); // messages category _S_classic->_M_init_facet(new std::messages); @@ -352,16 +363,16 @@ namespace std { #ifdef _GLIBCPP_USE_WCHAR_T _S_classic->_M_init_facet(new std::collate); _S_classic->_M_init_facet(new std::ctype); - _S_classic->_M_init_facet(new std::codecvt); - _S_classic->_M_init_facet(new std::moneypunct); - _S_classic->_M_init_facet(new std::moneypunct); - _S_classic->_M_init_facet(new std::money_get); - _S_classic->_M_init_facet(new std::money_put); - _S_classic->_M_init_facet(new std::numpunct); - _S_classic->_M_init_facet(new std::num_get); - _S_classic->_M_init_facet(new std::num_put); - _S_classic->_M_init_facet(new std::time_get); - _S_classic->_M_init_facet(new std::time_put); + _S_classic->_M_init_facet(new codecvt); + _S_classic->_M_init_facet(new moneypunct); + _S_classic->_M_init_facet(new moneypunct); + _S_classic->_M_init_facet(new money_get); + _S_classic->_M_init_facet(new money_put); + _S_classic->_M_init_facet(new numpunct); + _S_classic->_M_init_facet(new num_get); + _S_classic->_M_init_facet(new num_put); + _S_classic->_M_init_facet(new time_get); + _S_classic->_M_init_facet(new time_put); _S_classic->_M_init_facet(new std::messages); #endif @@ -384,7 +395,8 @@ namespace std { } int - locale::_S_normalize_category(int __cats) + locale:: + _S_normalize_category(int __cats) { if ((__cats & all) && !(__cats & ~all)) return __cats; @@ -408,19 +420,22 @@ namespace std { /* NOTREACHED */ } - locale::facet::facet(size_t __refs) throw () + locale::facet:: + facet(size_t __refs) throw() : _M_num_references(__refs - 1) { } void - locale::facet::_M_add_reference() throw () + locale::facet:: + _M_add_reference() throw() { if (this) ++_M_num_references; } // XXX MT void - locale::facet::_M_remove_reference() throw () + locale::facet:: + _M_remove_reference() throw() { if (this && _M_num_references-- == 0) { @@ -433,10 +448,12 @@ namespace std { } char const* - _Bad_use_facet::what() const throw() + _Bad_use_facet:: + what() const throw() { return "bad_cast thrown from use_facet"; } - _Bad_use_facet::~_Bad_use_facet() throw() {} + _Bad_use_facet:: + ~_Bad_use_facet() throw() { } size_t locale::id::_S_highwater; // init'd to 0 by linker @@ -446,11 +463,13 @@ namespace std { locale::id ctype::id; - ctype::~ctype() + ctype:: + ~ctype() { if (_M_del) delete[] table(); } char - ctype::do_widen(char __c) const + ctype:: + do_widen(char __c) const { return __c; } const char* @@ -462,7 +481,8 @@ namespace std { } char - ctype::do_narrow(char __c, char /*__dfault*/) const + ctype:: + do_narrow(char __c, char /*__dfault*/) const { return __c; } const char* @@ -474,17 +494,20 @@ namespace std { return __high; } - ctype_byname::ctype_byname(const char* /*__s*/, size_t __refs) - : ctype (new mask[table_size], true, __refs) + ctype_byname:: + ctype_byname(const char* /*__s*/, size_t __refs) + : ctype(new mask[table_size], true, __refs) { } locale::id codecvt::id; - codecvt::codecvt(size_t __refs) - : _Codecvt (__refs) + codecvt:: + codecvt(size_t __refs) + : _Codecvt(__refs) { } - codecvt::~codecvt() { } + codecvt:: + ~codecvt() { } codecvt_base::result codecvt:: @@ -505,8 +528,7 @@ namespace std { codecvt_base::result codecvt:: do_unshift(state_type& /*__state*/, extern_type* __to, - extern_type* /*__to_limit*/, - extern_type*& __to_next) const + extern_type* /*__to_limit*/, extern_type*& __to_next) const { __to_next = __to; return noconv; @@ -530,12 +552,12 @@ namespace std { int - codecvt::do_encoding() const throw () - { return 1; } + codecvt:: + do_encoding() const throw() { return 1; } bool - codecvt::do_always_noconv() const throw () - { return true; } + codecvt:: + do_always_noconv() const throw() { return true; } int codecvt:: @@ -544,27 +566,27 @@ namespace std { { return (__max < size_t(__end - __from)) ? __max : __end - __from; } int - codecvt::do_max_length() const throw () - { return 1; } + codecvt:: + do_max_length() const throw() { return 1; } codecvt_byname:: codecvt_byname(const char* /*__s*/, size_t __refs) - : codecvt(__refs) - { } + : codecvt(__refs) { } - codecvt_byname::~codecvt_byname() { } + codecvt_byname:: + ~codecvt_byname() { } locale::id collate::id; collate::collate(size_t __refs) - : _Collate (__refs) - { } + : _Collate(__refs) { } collate::~collate() { } int - collate::do_compare(const char* __lo1, const char* __hi1, - const char* __lo2, const char* __hi2) const + collate:: + do_compare(const char* __lo1, const char* __hi1, + const char* __lo2, const char* __hi2) const { for (; __lo1 < __hi1 && __lo2 < __hi2; ++__lo1, ++__lo2) if (*__lo1 != *__lo2) @@ -578,11 +600,13 @@ namespace std { } string - collate::do_transform(const char* __lo, const char* __hi) const + collate:: + do_transform(const char* __lo, const char* __hi) const { return string(__lo, __hi - __lo); } long - collate::do_hash(const char* __lo, const char* __hi) const + collate:: + do_hash(const char* __lo, const char* __hi) const { unsigned long __val = 0xdeadbeef; for (; __lo < __hi; ++__lo) @@ -591,43 +615,43 @@ namespace std { return __val; } - collate_byname::collate_byname(const char* /*__s*/, size_t __refs) - : collate (__refs) - { } + collate_byname:: + collate_byname(const char* /*__s*/, size_t __refs) + : collate(__refs) { } - numpunct_byname::numpunct_byname(const char* /*__s*/, size_t __refs) - : numpunct (__refs) - { } + numpunct_byname:: + numpunct_byname(const char* /*__s*/, size_t __refs) + : numpunct(__refs) { } moneypunct_byname:: moneypunct_byname(const char* /*__s*/, size_t __refs) - : moneypunct (__refs) - { } + : moneypunct(__refs) { } moneypunct_byname:: moneypunct_byname(const char* /*__s*/, size_t __refs) - : moneypunct (__refs) - { } + : moneypunct(__refs) { } - messages_byname::messages_byname(const char* /*__s*/, size_t __refs) - : messages (__refs) - { } + messages_byname:: + messages_byname(const char* /*__s*/, size_t __refs) + : messages(__refs) { } #ifdef _GLIBCPP_USE_WCHAR_T locale::id ctype::id; - ctype::~ctype() { } + ctype:: + ~ctype() { } bool - ctype::do_is(mask __m, char_type __c) const + ctype:: + do_is(mask __m, char_type __c) const { return ((static_cast<__table_type>(__c) < _S_table_size) && (_M_ctable[__c] & __m)); } const wchar_t* - ctype::do_is(const wchar_t* __low, const wchar_t* __high, - mask* __vec) const + ctype:: + do_is(const wchar_t* __low, const wchar_t* __high, mask* __vec) const { for (; __low < __high; ++__low, ++__vec) *__vec = ((static_cast<__table_type>(*__low) < _S_table_size) @@ -636,8 +660,8 @@ namespace std { } const wchar_t* - ctype::do_scan_is(mask __m, const wchar_t* __low, - const wchar_t* __high) const + ctype:: + do_scan_is(mask __m, const wchar_t* __low, const wchar_t* __high) const { while (__low < __high && (_S_table_size < static_cast<__table_type>(*__low) @@ -647,8 +671,8 @@ namespace std { } const wchar_t* - ctype::do_scan_not(mask __m, const char_type* __low, - const char_type* __high) const + ctype:: + do_scan_not(mask __m, const char_type* __low, const char_type* __high) const { while (__low < __high && static_cast<__table_type>(*__low) < _S_table_size @@ -658,12 +682,13 @@ namespace std { } wchar_t - ctype::do_widen(char __c) const + ctype:: + do_widen(char __c) const { return static_cast((unsigned char)__c); } const char* - ctype::do_widen(const char* __low, const char* __high, - wchar_t* __dest) const + ctype:: + do_widen(const char* __low, const char* __high, wchar_t* __dest) const { while (__low < __high) *__dest++ = static_cast((unsigned char)*__low++); @@ -671,15 +696,17 @@ namespace std { } char - ctype::do_narrow(wchar_t __c, char __dfault) const + ctype:: + do_narrow(wchar_t __c, char __dfault) const { return ((static_cast<__table_type>(__c) < _S_table_size) ? static_cast(__c) : __dfault); } const wchar_t* - ctype::do_narrow(const wchar_t* __low, const wchar_t* __high, - char __dfault, char* __dest) const + ctype:: + do_narrow(const wchar_t* __low, const wchar_t* __high, + char __dfault, char* __dest) const { for (; __low < __high; ++__dest, ++__low) *__dest = (static_cast<__table_type>(*__low) < _S_table_size) @@ -687,17 +714,18 @@ namespace std { return __high; } - ctype_byname::ctype_byname(const char* /*__s*/, size_t __refs) - : ctype (__refs) - { } + ctype_byname:: + ctype_byname(const char* /*__s*/, size_t __refs) + : ctype(__refs) { } locale::id codecvt::id; - codecvt::codecvt (size_t __refs) - : _Codecvt (__refs) - { } + codecvt:: + codecvt(size_t __refs) + : _Codecvt(__refs) { } - codecvt::~codecvt() { } + codecvt:: + ~codecvt() { } codecvt_base::result codecvt:: @@ -715,8 +743,7 @@ namespace std { codecvt_base::result codecvt:: do_unshift (state_type& /*__state*/, extern_type* __to, - extern_type* /*__to_limit*/, - extern_type*& __to_next) const + extern_type* /*__to_limit*/, extern_type*& __to_next) const { __to_next = __to; return noconv; @@ -736,11 +763,14 @@ namespace std { return __from == __from_end ? ok : partial; } - int codecvt::do_encoding() const throw () + int + codecvt:: + do_encoding() const throw() { return 1; } bool - codecvt::do_always_noconv() const throw () + codecvt:: + do_always_noconv() const throw() { return false; } int @@ -750,33 +780,35 @@ namespace std { { return (__max < size_t(__end - __from)) ? __max : __end - __from; } int - codecvt::do_max_length() const throw () + codecvt::do_max_length() const throw() { return 1; } codecvt_byname:: codecvt_byname(const char* /*__s*/, size_t __refs) - : codecvt (__refs) - { } + : codecvt (__refs) { } - codecvt_byname::~codecvt_byname() {} + codecvt_byname:: + ~codecvt_byname() { } locale::id collate::id; - collate::collate(size_t __refs) - : _Collate (__refs) - { } + collate:: + collate(size_t __refs) + : _Collate (__refs) { } - collate::~collate() { } + collate:: + ~collate() { } - int collate:: + int + collate:: do_compare(const wchar_t* /*__lo1*/, const wchar_t* /*__hi1*/, const wchar_t* /*__lo2*/, const wchar_t* /*__hi2*/) const { return 0; // XXX not done } - wstring collate::do_transform(const wchar_t* /*__lo*/, - const wchar_t* /*__hi*/) const + wstring collate:: + do_transform(const wchar_t* /*__lo*/, const wchar_t* /*__hi*/) const { return wstring(); // XXX not done } @@ -787,27 +819,25 @@ namespace std { return 0; // XXX not done } - numpunct_byname::numpunct_byname(const char* /*__s*/, size_t __refs) - : numpunct (__refs) - { } + numpunct_byname:: + numpunct_byname(const char* /*__s*/, size_t __refs) + : numpunct (__refs) { } - collate_byname::collate_byname(const char* /*__s*/, size_t __refs) - : collate (__refs) - { } + collate_byname:: + collate_byname(const char* /*__s*/, size_t __refs) + : collate (__refs) { } moneypunct_byname:: moneypunct_byname(const char* /*__s*/, size_t __refs) - : moneypunct (__refs) - { } + : moneypunct (__refs) { } moneypunct_byname:: moneypunct_byname(const char* /*__s*/, size_t __refs) - : moneypunct (__refs) - { } + : moneypunct (__refs) { } - messages_byname::messages_byname(const char* /*__s*/, size_t __refs) - : messages (__refs) - { } + messages_byname:: + messages_byname(const char* /*__s*/, size_t __refs) + : messages (__refs) { } #endif // _GLIBCPP_USE_WCHAR_T } // namespace std diff --git a/libstdc++-v3/src/string-inst.cc b/libstdc++-v3/src/string-inst.cc index d50b1137e49..428d7baa62c 100644 --- a/libstdc++-v3/src/string-inst.cc +++ b/libstdc++-v3/src/string-inst.cc @@ -57,9 +57,9 @@ namespace std #ifdef MAIN template C S::_Rep::_S_terminal; - // XXX Fix me: 2000-04-18 g++ ICE. -// template S::size_type S::_S_max_size; -// template S::allocator_type::size_type S::S_empty_rep_storage[]; + template S::size_type S::_Rep::_S_max_size; + template S::size_type S::_S_empty_rep_storage[]; + template S::basic_string(S const&); template S::_Rep* S::_Rep::_S_create(size_t, S::allocator_type const&); template void S::_Rep::_M_destroy(S::allocator_type const&) throw();