diff options
Diffstat (limited to 'libstdc++-v3/include/bits/basic_ios.tcc')
-rw-r--r-- | libstdc++-v3/include/bits/basic_ios.tcc | 119 |
1 files changed, 73 insertions, 46 deletions
diff --git a/libstdc++-v3/include/bits/basic_ios.tcc b/libstdc++-v3/include/bits/basic_ios.tcc index 7ee8015e29f..bbff2f5ca24 100644 --- a/libstdc++-v3/include/bits/basic_ios.tcc +++ b/libstdc++-v3/include/bits/basic_ios.tcc @@ -1,6 +1,6 @@ // basic_ios locale and locale-related member functions -*- C++ -*- -// Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 1999, 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 @@ -60,45 +60,56 @@ namespace std basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) { - // Per 27.1.1.1, do not call imbue, yet must trash all caches - // associated with imbue() - - // Alloc any new word array first, so if it fails we have "rollback". - _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ? - _M_local_word : new _Words[__rhs._M_word_size]; - - // Bump refs before doing callbacks, for safety. - _Callback_list* __cb = __rhs._M_callbacks; - if (__cb) - __cb->_M_add_reference(); - _M_call_callbacks(erase_event); - if (_M_word != _M_local_word) + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 292. effects of a.copyfmt (a) + if (this != &__rhs) { - delete [] _M_word; - _M_word = 0; + // Per 27.1.1.1, do not call imbue, yet must trash all caches + // associated with imbue() + + // Alloc any new word array first, so if it fails we have "rollback". + _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ? + _M_local_word : new _Words[__rhs._M_word_size]; + + // Bump refs before doing callbacks, for safety. + _Callback_list* __cb = __rhs._M_callbacks; + if (__cb) + __cb->_M_add_reference(); + _M_call_callbacks(erase_event); + if (_M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } + _M_dispose_callbacks(); + + _M_callbacks = __cb; // NB: Don't want any added during above. + for (int __i = 0; __i < __rhs._M_word_size; ++__i) + __words[__i] = __rhs._M_word[__i]; + if (_M_word != _M_local_word) + { + delete [] _M_word; + _M_word = 0; + } + _M_word = __words; + _M_word_size = __rhs._M_word_size; + + this->flags(__rhs.flags()); + this->width(__rhs.width()); + this->precision(__rhs.precision()); + this->tie(__rhs.tie()); + this->fill(__rhs.fill()); + _M_ios_locale = __rhs.getloc(); + + // This removes the link to __rhs locale cache + _M_call_callbacks(copyfmt_event); + + _M_cache_locale(_M_ios_locale); + + + // The next is required to be the last assignment. + this->exceptions(__rhs.exceptions()); } - _M_dispose_callbacks(); - - _M_callbacks = __cb; // NB: Don't want any added during above. - for (int __i = 0; __i < __rhs._M_word_size; ++__i) - __words[__i] = __rhs._M_word[__i]; - if (_M_word != _M_local_word) - { - delete [] _M_word; - _M_word = 0; - } - _M_word = __words; - _M_word_size = __rhs._M_word_size; - - this->flags(__rhs.flags()); - this->width(__rhs.width()); - this->precision(__rhs.precision()); - this->tie(__rhs.tie()); - this->fill(__rhs.fill()); - // The next is required to be the last assignment. - this->exceptions(__rhs.exceptions()); - - _M_call_callbacks(copyfmt_event); return *this; } @@ -129,7 +140,7 @@ namespace std { locale __old(this->getloc()); ios_base::imbue(__loc); - _M_cache_facets(__loc); + _M_cache_locale(__loc); if (this->rdbuf() != 0) this->rdbuf()->pubimbue(__loc); return __old; @@ -141,7 +152,7 @@ namespace std { // NB: This may be called more than once on the same object. ios_base::_M_init(); - _M_cache_facets(_M_ios_locale); + _M_cache_locale(_M_ios_locale); _M_tie = 0; // NB: The 27.4.4.1 Postconditions Table specifies requirements @@ -166,31 +177,47 @@ namespace std template<typename _CharT, typename _Traits> void - basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc) + basic_ios<_CharT, _Traits>::_M_cache_locale(const locale& __loc) { - if (has_facet<__ctype_type>(__loc)) + if (__builtin_expect(has_facet<__ctype_type>(__loc), true)) _M_fctype = &use_facet<__ctype_type>(__loc); else _M_fctype = 0; - // Should be filled in by ostream and istream, respectively. - if (has_facet<__numput_type>(__loc)) + if (__builtin_expect(has_facet<__numput_type>(__loc), true)) _M_fnumput = &use_facet<__numput_type>(__loc); else _M_fnumput = 0; - if (has_facet<__numget_type>(__loc)) - _M_fnumget = &use_facet<__numget_type>(__loc); + if (__builtin_expect(has_facet<__numget_type>(__loc), true)) + _M_fnumget = &use_facet<__numget_type>(__loc); else _M_fnumget = 0; } +#if 1 + // XXX GLIBCXX_ABI Deprecated, compatibility only. + template<typename _CharT, typename _Traits> + void + basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc) + { + if (__builtin_expect(has_facet<__ctype_type>(__loc), true)) + _M_fctype = &use_facet<__ctype_type>(__loc); + if (__builtin_expect(has_facet<__numput_type>(__loc), true)) + _M_fnumput = &use_facet<__numput_type>(__loc); + if (__builtin_expect(has_facet<__numget_type>(__loc), true)) + _M_fnumget = &use_facet<__numget_type>(__loc); + } +#endif + // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. // NB: This syntax is a GNU extension. +#if _GLIBCPP_EXTERN_TEMPLATE extern template class basic_ios<char>; #ifdef _GLIBCPP_USE_WCHAR_T extern template class basic_ios<wchar_t>; #endif +#endif } // namespace std #endif |