[multiple changes]

2002-05-04  Benjamin Kosnik  <bkoz@redhat.com>
	    Paolo Carlini  <pcarlini@unitus.it>

	* testsuite/22_locale/num_put_members_char.cc: Add test04(),
	testing for the locale_facets.tcc entry of the previous commit.
	* testsuite/22_locale/num_put_members_wchar_t.cc: Likewise.

2002-05-04  Takeshi Kobayakawa  <tskoba@mte.biglobe.ne.jp>

	* config/locale/generic/c_locale.cc
	(__convert_to_v(float, double, long double)):
	Fix the temporary switch to the "C" locale, saving and
	restoring in the proper way the current locale.
	* config/locale/generic/time_members.cc
	(__timepunct<char, wchar_t>::_M_put): Likewise.
	* config/locale/gnu/messages_members.cc
	(messages<char>::do_get): Likewise.
	* config/locale/gnu/messages_members.h
	(messages<_CharT>::do_get): Likewise.
	* config/locale/gnu/time_members.cc
	(__timepunct<char, wchar_t>::_M_put): Likewise.
	* include/bits/locale_facets.tcc (__convert_from_v): Likewise.

From-SVN: r53167
This commit is contained in:
Paolo Carlini 2002-05-04 21:33:19 +00:00
parent 7e90efc403
commit 6d030676cc
9 changed files with 80 additions and 11 deletions

View File

@ -1,3 +1,26 @@
2002-05-04 Benjamin Kosnik <bkoz@redhat.com>
Paolo Carlini <pcarlini@unitus.it>
* testsuite/22_locale/num_put_members_char.cc: Add test04(),
testing for the locale_facets.tcc entry of the previous commit.
* testsuite/22_locale/num_put_members_wchar_t.cc: Likewise.
2002-05-04 Takeshi Kobayakawa <tskoba@mte.biglobe.ne.jp>
* config/locale/generic/c_locale.cc
(__convert_to_v(float, double, long double)):
Fix the temporary switch to the "C" locale, saving and
restoring in the proper way the current locale.
* config/locale/generic/time_members.cc
(__timepunct<char, wchar_t>::_M_put): Likewise.
* config/locale/gnu/messages_members.cc
(messages<char>::do_get): Likewise.
* config/locale/gnu/messages_members.h
(messages<_CharT>::do_get): Likewise.
* config/locale/gnu/time_members.cc
(__timepunct<char, wchar_t>::_M_put): Likewise.
* include/bits/locale_facets.tcc (__convert_from_v): Likewise.
2002-05-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2002-05-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* configure.in (AC_CHECK_HEADERS): Check for string.h & stdlib.h. * configure.in (AC_CHECK_HEADERS): Check for string.h & stdlib.h.

View File

@ -120,7 +120,8 @@ namespace std
if (!(__err & ios_base::failbit)) if (!(__err & ios_base::failbit))
{ {
// Assumes __s formatted for "C" locale. // Assumes __s formatted for "C" locale.
const char* __old = setlocale(LC_ALL, "C"); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
char* __sanity; char* __sanity;
errno = 0; errno = 0;
#if defined(_GLIBCPP_USE_C99) #if defined(_GLIBCPP_USE_C99)
@ -147,6 +148,7 @@ namespace std
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
} }
} }
@ -158,7 +160,8 @@ namespace std
if (!(__err & ios_base::failbit)) if (!(__err & ios_base::failbit))
{ {
// Assumes __s formatted for "C" locale. // Assumes __s formatted for "C" locale.
const char* __old = setlocale(LC_ALL, "C"); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
char* __sanity; char* __sanity;
errno = 0; errno = 0;
double __d = strtod(__s, &__sanity); double __d = strtod(__s, &__sanity);
@ -167,6 +170,7 @@ namespace std
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
} }
} }
@ -178,7 +182,8 @@ namespace std
if (!(__err & ios_base::failbit)) if (!(__err & ios_base::failbit))
{ {
// Assumes __s formatted for "C" locale. // Assumes __s formatted for "C" locale.
const char* __old = setlocale(LC_ALL, "C"); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
#if defined(_GLIBCPP_USE_C99) #if defined(_GLIBCPP_USE_C99)
char* __sanity; char* __sanity;
errno = 0; errno = 0;
@ -202,6 +207,7 @@ namespace std
else else
__err |= ios_base::failbit; __err |= ios_base::failbit;
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
} }
} }

View File

@ -51,9 +51,11 @@ namespace std
_M_put(char* __s, size_t __maxlen, const char* __format, _M_put(char* __s, size_t __maxlen, const char* __format,
const tm* __tm) const const tm* __tm) const
{ {
const char* __old = setlocale(LC_ALL, _M_name_timepunct); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_timepunct);
strftime(__s, __maxlen, __format, __tm); strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
} }
template<> template<>
@ -132,9 +134,11 @@ namespace std
_M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format, _M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
const tm* __tm) const const tm* __tm) const
{ {
const char* __old = setlocale(LC_ALL, _M_name_timepunct); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_timepunct);
wcsftime(__s, __maxlen, __format, __tm); wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
} }
template<> template<>

View File

@ -48,9 +48,11 @@ namespace std
__uselocale(__old); __uselocale(__old);
return string(__msg); return string(__msg);
#else #else
const char* __old = setlocale(LC_ALL, _M_name_messages); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_messages);
const char* __msg = gettext(__dfault.c_str()); const char* __msg = gettext(__dfault.c_str());
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
return string(__msg); return string(__msg);
#endif #endif
} }

View File

@ -65,9 +65,11 @@
__uselocale(__old); __uselocale(__old);
return _M_convert_from_char(__msg); return _M_convert_from_char(__msg);
#else #else
const char* __old = setlocale(LC_ALL, _M_name_messages); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_messages);
char* __msg = gettext(_M_convert_to_char(__dfault)); char* __msg = gettext(_M_convert_to_char(__dfault));
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
return _M_convert_from_char(__msg); return _M_convert_from_char(__msg);
#endif #endif
} }

View File

@ -54,9 +54,11 @@ namespace std
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__strftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm); __strftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm);
#else #else
const char* __old = setlocale(LC_ALL, _M_name_timepunct); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_timepunct);
strftime(__s, __maxlen, __format, __tm); strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
#endif #endif
} }
@ -202,9 +204,11 @@ namespace std
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__wcsftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm); __wcsftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm);
#else #else
const char* __old = setlocale(LC_ALL, _M_name_timepunct); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, _M_name_timepunct);
wcsftime(__s, __maxlen, __format, __tm); wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
#endif #endif
} }

View File

@ -1959,12 +1959,14 @@ namespace std
_Tv __v, const __c_locale&, int __prec = -1) _Tv __v, const __c_locale&, int __prec = -1)
{ {
int __ret; int __ret;
const char* __old = setlocale(LC_ALL, "C"); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
if (__prec >= 0) if (__prec >= 0)
__ret = snprintf(__out, __size, __fmt, __prec, __v); __ret = snprintf(__out, __size, __fmt, __prec, __v);
else else
__ret = snprintf(__out, __size, __fmt, __v); __ret = snprintf(__out, __size, __fmt, __v);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
return __ret; return __ret;
} }
#else #else
@ -1974,12 +1976,14 @@ namespace std
const __c_locale&, int __prec = -1) const __c_locale&, int __prec = -1)
{ {
int __ret; int __ret;
const char* __old = setlocale(LC_ALL, "C"); char* __old = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
if (__prec >= 0) if (__prec >= 0)
__ret = sprintf(__out, __fmt, __prec, __v); __ret = sprintf(__out, __fmt, __prec, __v);
else else
__ret = sprintf(__out, __fmt, __v); __ret = sprintf(__out, __fmt, __v);
setlocale(LC_ALL, __old); setlocale(LC_ALL, __old);
free(__old);
return __ret; return __ret;
} }
#endif #endif

View File

@ -310,11 +310,23 @@ void test03()
#endif #endif
} }
void test04()
{
bool test = true;
std::string loc1 = setlocale(LC_ALL, "ja_JP.eucjp");
test01();
test02();
std::string loc2 = setlocale(LC_ALL, NULL);
VERIFY( loc1 == loc2 );
}
int main() int main()
{ {
test01(); test01();
test02(); test02();
test03(); test03();
test04();
return 0; return 0;
} }

View File

@ -309,6 +309,17 @@ void test03()
} }
#endif #endif
} }
void test04()
{
bool test = true;
std::string loc1 = setlocale(LC_ALL, "ja_JP.eucjp");
test01();
test02();
std::string loc2 = setlocale(LC_ALL, NULL);
VERIFY( loc1 == loc2 );
}
#endif #endif
int main() int main()
@ -317,6 +328,7 @@ int main()
test01(); test01();
test02(); test02();
test03(); test03();
test04();
#endif #endif
return 0; return 0;
} }