2003-10-02 Benjamin Kosnik * include/bits/locale_classes.h (locale::facet::_S_get_c_name): Add. * src/locale.cc: Define. * src/localename.cc: Use it. * config/locale/generic/time_members.h: Same. * config/locale/gnu/messages_members.h: Same. * config/locale/gnu/time_members.h: Same. Index: config/locale/generic/time_members.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/generic/time_members.h,v retrieving revision 1.3 diff -c -p -r1.3 time_members.h *** config/locale/generic/time_members.h 2 Oct 2003 16:56:38 -0000 1.3 --- config/locale/generic/time_members.h 2 Oct 2003 21:12:45 -0000 *************** *** 38,44 **** __timepunct<_CharT>::__timepunct(size_t __refs) : facet(__refs), _M_data(NULL) { ! _M_name_timepunct = _S_c_name; _M_initialize_timepunct(); } --- 38,44 ---- __timepunct<_CharT>::__timepunct(size_t __refs) : facet(__refs), _M_data(NULL) { ! _M_name_timepunct = _S_get_c_name(); _M_initialize_timepunct(); } *************** *** 46,52 **** __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) : facet(__refs), _M_data(__cache) { ! _M_name_timepunct = _S_c_name; _M_initialize_timepunct(); } --- 46,52 ---- __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) : facet(__refs), _M_data(__cache) { ! _M_name_timepunct = _S_get_c_name(); _M_initialize_timepunct(); } *************** *** 64,70 **** template __timepunct<_CharT>::~__timepunct() { ! if (_S_c_name != _M_name_timepunct) delete [] _M_name_timepunct; delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); --- 64,70 ---- template __timepunct<_CharT>::~__timepunct() { ! if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); Index: config/locale/gnu/messages_members.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/gnu/messages_members.h,v retrieving revision 1.9 diff -c -p -r1.9 messages_members.h *** config/locale/gnu/messages_members.h 2 Oct 2003 16:56:38 -0000 1.9 --- config/locale/gnu/messages_members.h 2 Oct 2003 21:12:46 -0000 *************** *** 39,45 **** : facet(__refs) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! _M_name_messages = _S_c_name; #endif _M_c_locale_messages = _S_get_c_locale(); } --- 39,45 ---- : facet(__refs) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! _M_name_messages = _S_get_c_name(); #endif _M_c_locale_messages = _S_get_c_locale(); } *************** *** 72,78 **** messages<_CharT>::~messages() { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! if (_S_c_name != _M_name_messages) delete [] _M_name_messages; #endif _S_destroy_c_locale(_M_c_locale_messages); --- 72,78 ---- messages<_CharT>::~messages() { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! if (_M_name_messages != _S_get_c_name()) delete [] _M_name_messages; #endif _S_destroy_c_locale(_M_c_locale_messages); *************** *** 100,106 **** : messages<_CharT>(__refs) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! if (this->_S_c_name != this->_M_name_messages) delete [] this->_M_name_messages; char* __tmp = new char[std::strlen(__s) + 1]; std::strcpy(__tmp, __s); --- 100,106 ---- : messages<_CharT>(__refs) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! if (this->_M_name_messages != _S_get_c_name()) delete [] this->_M_name_messages; char* __tmp = new char[std::strlen(__s) + 1]; std::strcpy(__tmp, __s); Index: config/locale/gnu/time_members.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/config/locale/gnu/time_members.h,v retrieving revision 1.3 diff -c -p -r1.3 time_members.h *** config/locale/gnu/time_members.h 2 Oct 2003 16:56:38 -0000 1.3 --- config/locale/gnu/time_members.h 2 Oct 2003 21:12:46 -0000 *************** *** 39,45 **** : facet(__refs), _M_data(NULL) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! _M_name_timepunct = _S_c_name; #endif _M_initialize_timepunct(); } --- 39,45 ---- : facet(__refs), _M_data(NULL) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! _M_name_timepunct = _S_get_c_name(); #endif _M_initialize_timepunct(); } *************** *** 49,55 **** : facet(__refs), _M_data(__cache) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! _M_name_timepunct = _S_c_name; #endif _M_initialize_timepunct(); } --- 49,55 ---- : facet(__refs), _M_data(__cache) { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! _M_name_timepunct = _S_get_c_name(); #endif _M_initialize_timepunct(); } *************** *** 72,78 **** __timepunct<_CharT>::~__timepunct() { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! if (_S_c_name != _M_name_timepunct) delete [] _M_name_timepunct; #endif delete _M_data; --- 72,78 ---- __timepunct<_CharT>::~__timepunct() { #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) ! if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; #endif delete _M_data; Index: include/bits/locale_classes.h =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_classes.h,v retrieving revision 1.13 diff -c -p -r1.13 locale_classes.h *** include/bits/locale_classes.h 2 Oct 2003 16:56:39 -0000 1.13 --- include/bits/locale_classes.h 2 Oct 2003 21:12:47 -0000 *************** namespace std *** 224,232 **** static void _S_destroy_c_locale(__c_locale& __cloc); ! // Returns data from the underlying "C" library for the classic locale. static __c_locale _S_get_c_locale(); private: inline void --- 224,236 ---- static void _S_destroy_c_locale(__c_locale& __cloc); ! // Returns data from the underlying "C" library data for the ! // classic locale. static __c_locale _S_get_c_locale(); + + static const char* + _S_get_c_name(); private: inline void Index: src/locale.cc =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale.cc,v retrieving revision 1.94 diff -c -p -r1.94 locale.cc *** src/locale.cc 2 Oct 2003 19:02:58 -0000 1.94 --- src/locale.cc 2 Oct 2003 21:12:48 -0000 *************** namespace std *** 486,491 **** --- 486,495 ---- return _S_c_locale; } + const char* + locale::facet::_S_get_c_name() + { return _S_c_name; } + // Definitions for static const data members of time_base. template<> const char* Index: src/localename.cc =================================================================== RCS file: /cvs/gcc/gcc/libstdc++-v3/src/localename.cc,v retrieving revision 1.46 diff -c -p -r1.46 localename.cc *** src/localename.cc 2 Oct 2003 16:56:39 -0000 1.46 --- src/localename.cc 2 Oct 2003 21:12:48 -0000 *************** namespace std *** 258,264 **** for (size_t __i = 0; __i < _S_categories_size; ++__i) { _M_names[__i] = new (&name_c[__i]) char[2]; ! std::strcpy(_M_names[__i], locale::facet::_S_c_name); } // This is needed as presently the C++ version of "C" locales --- 258,264 ---- for (size_t __i = 0; __i < _S_categories_size; ++__i) { _M_names[__i] = new (&name_c[__i]) char[2]; ! std::strcpy(_M_names[__i], locale::facet::_S_get_c_name()); } // This is needed as presently the C++ version of "C" locales