From 22b9554ccd5e0f2390d058c19d142d0e2bb747bb Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Wed, 20 Sep 2000 08:19:07 +0000 Subject: localename.cc (locale::_Imp): Remove typedefs. 2000-09-19 Benjamin Kosnik * src/localename.cc (locale::_Imp) : Remove typedefs. * bits/localefwd.h (locale::locale(const locale& __other, _Facet* __f): Consistency check,, call _Imp ctor with refererence argument of 1. * bits/localefwd.h: Change _S_num_categories to _S_categories_num. Add new data member, _S_facets_num, which is the number of standard facets. From-SVN: r36550 --- libstdc++-v3/ChangeLog | 10 ++++ libstdc++-v3/bits/localefwd.h | 7 +-- libstdc++-v3/src/locale.cc | 30 ++++++------ libstdc++-v3/src/localename.cc | 104 ++++++++++++++++++++++------------------- 4 files changed, 87 insertions(+), 64 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index be501f3..73ea5e5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2000-09-19 Benjamin Kosnik + + * src/localename.cc (locale::_Imp) : Remove typedefs. + * bits/localefwd.h (locale::locale(const locale& __other, _Facet* + __f): Consistency check,, call _Imp ctor with refererence argument + of 1. + * bits/localefwd.h: Change _S_num_categories to + _S_categories_num. Add new data member, _S_facets_num, which is + the number of standard facets. + 2000-09-19 Phil Edwards * docs/21_strings/howto.html: Fix editor lossage from last commit. diff --git a/libstdc++-v3/bits/localefwd.h b/libstdc++-v3/bits/localefwd.h index 252f95d..44e8560 100644 --- a/libstdc++-v3/bits/localefwd.h +++ b/libstdc++-v3/bits/localefwd.h @@ -294,13 +294,14 @@ namespace std // The (shared) implementation _Impl* _M_impl; - // The one true C reference locale + // The "C" reference locale static _Impl* _S_classic; // Current global reference locale static _Impl* _S_global; - static const int _S_num_categories = _Count_ones::_S_count; + static const int _S_categories_num = _Count_ones::_S_count; + static const int _S_facets_num = 26; explicit locale(_Impl*) throw(); @@ -423,7 +424,7 @@ namespace std template locale::locale(const locale& __other, _Facet* __f) { - _M_impl = new _Impl(*__other._M_impl, 0); + _M_impl = new _Impl(*__other._M_impl, 1); _M_impl->_M_install_facet(&_Facet::id, __f); _M_impl->_M_has_name = false; _M_impl->_M_name = "*"; diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index de57040..64996ef 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -55,7 +55,8 @@ namespace std { locale::_Impl* locale::_S_global; locale::_Impl* locale::_S_classic; - const int locale::_S_num_categories; + const int locale::_S_categories_num; + const int locale::_S_facets_num; // Definitions for static const data members of locale::_Impl const locale::id* const @@ -552,6 +553,11 @@ namespace std { } + locale::locale(_Impl* __ip) throw() + : _M_impl(__ip) + { __ip->_M_add_reference(); } + + locale::locale(const char* __name) { if (__name) @@ -560,7 +566,7 @@ namespace std { (_M_impl = _S_classic)->_M_add_reference(); // Might throw: else - _M_impl = new _Impl(*_S_classic, __name, all, 1); + _M_impl = new _Impl(_S_facets_num, 1, true, __name); } else throw runtime_error("attempt to create named locale from NULL name"); @@ -580,17 +586,6 @@ namespace std { throw runtime_error("attempt to create locale from NULL named locale"); } - bool - locale::operator==(const locale& __rhs) const throw() - { - return((this->name() != "*" && this->name() == __rhs.name()) - || _M_impl == __rhs._M_impl); - } - - locale::locale(_Impl* __ip) throw() - : _M_impl(__ip) - { __ip->_M_add_reference(); } - locale::locale(const locale& __other, const locale& __one, category __cat) { __cat = _S_normalize_category(__cat); // might throw @@ -610,6 +605,13 @@ namespace std { _M_impl->_M_has_name = false; } + bool + locale::operator==(const locale& __rhs) const throw() + { + return((this->name() != "*" && this->name() == __rhs.name()) + || _M_impl == __rhs._M_impl); + } + const locale& locale::operator=(const locale& __other) throw() { @@ -647,7 +649,7 @@ namespace std { try { // 26 Standard facets, 2 references. // One reference for _M_classic, one for _M_global - _S_classic = new _Impl(26, 2, true, "C"); + _S_classic = new _Impl(_S_facets_num, 2, true, "C"); _S_global = _S_classic; _S_classic->_M_facet_init(new std::collate); diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc index 1b231c0..7d6f259 100644 --- a/libstdc++-v3/src/localename.cc +++ b/libstdc++-v3/src/localename.cc @@ -45,70 +45,80 @@ namespace std { delete _M_category_names; } - // This constructor is used to correctly initialize the standard, - // required facets. - locale::_Impl:: - _Impl(size_t __numfacets, size_t __refs, bool __has_name = false, - string __name = "*") - : _M_references(__refs - 1), _M_facets(0), _M_category_names(0), - _M_has_name(__has_name), _M_name(__name) - { - typedef vector > __vec_facet; - typedef vector > __vec_string; - - auto_ptr<__vec_facet> __pvf(new __vec_facet(__numfacets, (facet*)0)); - auto_ptr<__vec_string> __pcn(new __vec_string(_S_num_categories, _M_name)); - _M_facets = __pvf.release(); - _M_category_names = __pcn.release(); - } - locale::_Impl:: _Impl(const _Impl& __other, size_t __refs) : _M_references(__refs - 1), _M_facets(0), _M_category_names(0), _M_has_name(__other._M_has_name), _M_name(__other._M_name) { - typedef vector > __vec_facet; - typedef vector > __vec_string; + try + { _M_facets = new __vec_facet(*(__other._M_facets)); } + catch(...) + { + delete _M_facets; + throw; + } - auto_ptr<__vec_facet> __pvf(new __vec_facet(*(__other._M_facets))); - auto_ptr<__vec_string> - __pcn(new __vec_string(*(__other._M_category_names))); + try + { _M_category_names = new __vec_string(*(__other._M_category_names)); } + catch(...) + { + delete _M_category_names; + throw; + } - std::vector::iterator __it = __pvf->begin(); - for (; __it != __pvf->end(); ++__it) + std::vector::iterator __it = _M_facets->begin(); + for (; __it != _M_facets->end(); ++__it) (*__it)->_M_add_reference(); - - // These must be last since in the presence of an exception, the - // destructor for 'this' won't run until AFTER execution has passed - // the closing brace of the constructor. - _M_facets = __pvf.release(); - _M_category_names = __pcn.release(); } + // This constructor is used to correctly initialize named locales, + // including the standard "C" locale. + locale::_Impl:: + _Impl(size_t __numfacets, size_t __refs, bool __has_name = false, + string __name = "*") + : _M_references(__refs - 1), _M_facets(0), _M_category_names(0), + _M_has_name(__has_name), _M_name(__name) + { + try + { _M_facets = new __vec_facet(__numfacets, NULL); } + catch(...) + { + delete _M_facets; + throw; + } + + try + { _M_category_names = new __vec_string(_S_categories_num, _M_name); } + catch(...) + { + delete _M_category_names; + throw; + } + } + // Construct specific categories, leaving unselected ones alone locale::_Impl:: _Impl(const _Impl& __other, const string& __name, category __cat, size_t __refs) : _M_references(__refs - 1), _M_has_name(__other._M_name != "*") { - typedef vector > __vec_facet; - typedef vector > __vec_string; - __cat = _S_normalize_category(__cat); // might throw - try { - _M_facets = new __vec_facet(*(__other._M_facets)); - } - catch(...) { - delete _M_facets; - throw; - } - try { - _M_category_names = new __vec_string(*(__other._M_category_names)); - } - catch(...) { - delete _M_category_names; - throw; - } + + try + { _M_facets = new __vec_facet(*(__other._M_facets)); } + catch(...) + { + delete _M_facets; + throw; + } + + try + { _M_category_names = new __vec_string(*(__other._M_category_names)); } + catch(...) + { + delete _M_category_names; + throw; + } static void(_Impl::* ctors[]) (const char*) = { -- cgit v1.1