+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>
* configure.in (AC_CHECK_HEADERS): Check for string.h & stdlib.h.
if (!(__err & ios_base::failbit))
{
// 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;
errno = 0;
#if defined(_GLIBCPP_USE_C99)
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
+ free(__old);
}
}
if (!(__err & ios_base::failbit))
{
// 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;
errno = 0;
double __d = strtod(__s, &__sanity);
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
+ free(__old);
}
}
if (!(__err & ios_base::failbit))
{
// 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)
char* __sanity;
errno = 0;
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
+ free(__old);
}
}
_M_put(char* __s, size_t __maxlen, const char* __format,
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);
setlocale(LC_ALL, __old);
+ free(__old);
}
template<>
_M_put(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
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);
setlocale(LC_ALL, __old);
+ free(__old);
}
template<>
__uselocale(__old);
return string(__msg);
#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());
setlocale(LC_ALL, __old);
+ free(__old);
return string(__msg);
#endif
}
__uselocale(__old);
return _M_convert_from_char(__msg);
#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));
setlocale(LC_ALL, __old);
+ free(__old);
return _M_convert_from_char(__msg);
#endif
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__strftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm);
#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);
setlocale(LC_ALL, __old);
+ free(__old);
#endif
}
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
__wcsftime_l(__s, __maxlen, _M_c_locale_timepunct, __format, __tm);
#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);
setlocale(LC_ALL, __old);
+ free(__old);
#endif
}
_Tv __v, const __c_locale&, int __prec = -1)
{
int __ret;
- const char* __old = setlocale(LC_ALL, "C");
+ char* __old = strdup(setlocale(LC_ALL, NULL));
+ setlocale(LC_ALL, "C");
if (__prec >= 0)
__ret = snprintf(__out, __size, __fmt, __prec, __v);
else
__ret = snprintf(__out, __size, __fmt, __v);
setlocale(LC_ALL, __old);
+ free(__old);
return __ret;
}
#else
const __c_locale&, int __prec = -1)
{
int __ret;
- const char* __old = setlocale(LC_ALL, "C");
+ char* __old = strdup(setlocale(LC_ALL, NULL));
+ setlocale(LC_ALL, "C");
if (__prec >= 0)
__ret = sprintf(__out, __fmt, __prec, __v);
else
__ret = sprintf(__out, __fmt, __v);
setlocale(LC_ALL, __old);
+ free(__old);
return __ret;
}
#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()
{
test01();
test02();
test03();
+ test04();
return 0;
}
}
#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
int main()
test01();
test02();
test03();
+ test04();
#endif
return 0;
}