diff options
Diffstat (limited to 'contrib/libstdc++/config/locale/gnu/messages_members.h')
-rw-r--r-- | contrib/libstdc++/config/locale/gnu/messages_members.h | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/contrib/libstdc++/config/locale/gnu/messages_members.h b/contrib/libstdc++/config/locale/gnu/messages_members.h index d98d8d1..a7cd1cd 100644 --- a/contrib/libstdc++/config/locale/gnu/messages_members.h +++ b/contrib/libstdc++/config/locale/gnu/messages_members.h @@ -1,6 +1,6 @@ // std::messages implementation details, GNU version -*- C++ -*- -// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004 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 @@ -36,24 +36,19 @@ // Non-virtual member functions. template<typename _CharT> messages<_CharT>::messages(size_t __refs) - : locale::facet(__refs) - { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - _M_name_messages = _S_c_name; -#endif - _M_c_locale_messages = _S_c_locale; - } + : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), + _M_name_messages(_S_get_c_name()) + { } template<typename _CharT> - messages<_CharT>::messages(__c_locale __cloc, - const char* __s, size_t __refs) - : locale::facet(__refs) + messages<_CharT>::messages(__c_locale __cloc, const char* __s, + size_t __refs) + : facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)), + _M_name_messages(__s) { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - _M_name_messages = new char[strlen(__s) + 1]; - strcpy(_M_name_messages, __s); -#endif - _M_c_locale_messages = _S_clone_c_locale(__cloc); + char* __tmp = new char[std::strlen(__s) + 1]; + std::strcpy(__tmp, __s); + _M_name_messages = __tmp; } template<typename _CharT> @@ -69,10 +64,8 @@ template<typename _CharT> messages<_CharT>::~messages() { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - if (_S_c_name != _M_name_messages) + if (_M_name_messages != _S_get_c_name()) delete [] _M_name_messages; -#endif _S_destroy_c_locale(_M_c_locale_messages); } @@ -97,12 +90,15 @@ messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { -#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) - if (_S_c_name != _M_name_messages) - delete [] _M_name_messages; - _M_name_messages = new char[strlen(__s) + 1]; - strcpy(_M_name_messages, __s); -#endif - _S_destroy_c_locale(_M_c_locale_messages); - _S_create_c_locale(_M_c_locale_messages, __s); + if (this->_M_name_messages != locale::facet::_S_get_c_name()) + delete [] this->_M_name_messages; + char* __tmp = new char[std::strlen(__s) + 1]; + std::strcpy(__tmp, __s); + this->_M_name_messages = __tmp; + + if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0) + { + this->_S_destroy_c_locale(this->_M_c_locale_messages); + this->_S_create_c_locale(this->_M_c_locale_messages, __s); + } } |