Commit bb1b12ec by Benjamin Kosnik Committed by Benjamin Kosnik

locale_classes.h (locale::facet::_S_get_c_name): Add.


2003-10-02  Benjamin Kosnik  <bkoz@redhat.com>

	* 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.

From-SVN: r72050
parent 8dcaff28
2003-10-02 Benjamin Kosnik <bkoz@redhat.com>
* 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.
2003-10-02 Paolo Carlini <pcarlini@unitus.it> 2003-10-02 Paolo Carlini <pcarlini@unitus.it>
PR libstdc++/12232 PR libstdc++/12232
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
__timepunct<_CharT>::__timepunct(size_t __refs) __timepunct<_CharT>::__timepunct(size_t __refs)
: facet(__refs), _M_data(NULL) : facet(__refs), _M_data(NULL)
{ {
_M_name_timepunct = _S_c_name; _M_name_timepunct = _S_get_c_name();
_M_initialize_timepunct(); _M_initialize_timepunct();
} }
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
__timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
: facet(__refs), _M_data(__cache) : facet(__refs), _M_data(__cache)
{ {
_M_name_timepunct = _S_c_name; _M_name_timepunct = _S_get_c_name();
_M_initialize_timepunct(); _M_initialize_timepunct();
} }
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
template<typename _CharT> template<typename _CharT>
__timepunct<_CharT>::~__timepunct() __timepunct<_CharT>::~__timepunct()
{ {
if (_S_c_name != _M_name_timepunct) if (_M_name_timepunct != _S_get_c_name())
delete [] _M_name_timepunct; delete [] _M_name_timepunct;
delete _M_data; delete _M_data;
_S_destroy_c_locale(_M_c_locale_timepunct); _S_destroy_c_locale(_M_c_locale_timepunct);
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
: facet(__refs) : facet(__refs)
{ {
#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2))
_M_name_messages = _S_c_name; _M_name_messages = _S_get_c_name();
#endif #endif
_M_c_locale_messages = _S_get_c_locale(); _M_c_locale_messages = _S_get_c_locale();
} }
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
messages<_CharT>::~messages() messages<_CharT>::~messages()
{ {
#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) #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; delete [] _M_name_messages;
#endif #endif
_S_destroy_c_locale(_M_c_locale_messages); _S_destroy_c_locale(_M_c_locale_messages);
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
: messages<_CharT>(__refs) : messages<_CharT>(__refs)
{ {
#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2))
if (this->_S_c_name != this->_M_name_messages) if (this->_M_name_messages != locale::facet::_S_get_c_name())
delete [] this->_M_name_messages; delete [] this->_M_name_messages;
char* __tmp = new char[std::strlen(__s) + 1]; char* __tmp = new char[std::strlen(__s) + 1];
std::strcpy(__tmp, __s); std::strcpy(__tmp, __s);
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
: facet(__refs), _M_data(NULL) : facet(__refs), _M_data(NULL)
{ {
#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2))
_M_name_timepunct = _S_c_name; _M_name_timepunct = _S_get_c_name();
#endif #endif
_M_initialize_timepunct(); _M_initialize_timepunct();
} }
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
: facet(__refs), _M_data(__cache) : facet(__refs), _M_data(__cache)
{ {
#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2))
_M_name_timepunct = _S_c_name; _M_name_timepunct = _S_get_c_name();
#endif #endif
_M_initialize_timepunct(); _M_initialize_timepunct();
} }
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
__timepunct<_CharT>::~__timepunct() __timepunct<_CharT>::~__timepunct()
{ {
#if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)) #if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2))
if (_S_c_name != _M_name_timepunct) if (_M_name_timepunct != _S_get_c_name())
delete [] _M_name_timepunct; delete [] _M_name_timepunct;
#endif #endif
delete _M_data; delete _M_data;
......
...@@ -224,10 +224,14 @@ namespace std ...@@ -224,10 +224,14 @@ namespace std
static void static void
_S_destroy_c_locale(__c_locale& __cloc); _S_destroy_c_locale(__c_locale& __cloc);
// Returns data from the underlying "C" library for the classic locale. // Returns data from the underlying "C" library data for the
// classic locale.
static __c_locale static __c_locale
_S_get_c_locale(); _S_get_c_locale();
static const char*
_S_get_c_name();
private: private:
inline void inline void
_M_add_reference() const throw() _M_add_reference() const throw()
......
...@@ -486,6 +486,10 @@ namespace std ...@@ -486,6 +486,10 @@ namespace std
return _S_c_locale; 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. // Definitions for static const data members of time_base.
template<> template<>
const char* const char*
......
...@@ -258,7 +258,7 @@ namespace std ...@@ -258,7 +258,7 @@ namespace std
for (size_t __i = 0; __i < _S_categories_size; ++__i) for (size_t __i = 0; __i < _S_categories_size; ++__i)
{ {
_M_names[__i] = new (&name_c[__i]) char[2]; _M_names[__i] = new (&name_c[__i]) char[2];
std::strcpy(_M_names[__i], locale::facet::_S_c_name); std::strcpy(_M_names[__i], locale::facet::_S_get_c_name());
} }
// This is needed as presently the C++ version of "C" locales // This is needed as presently the C++ version of "C" locales
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment