Commit 4b9aaf63 by Benjamin Kosnik Committed by Benjamin Kosnik

Audit for LANG independence.


2002-01-22  Benjamin Kosnik  <bkoz@redhat.com>

	Audit for LANG independence.
	* include/bits/localefwd.h: Tweaks.
	* include/bits/locale_facets.tcc (money_get::do_get(long double)):
	Use __convert_to_v.
	(time_get::do_get_year): Same.
	(__convert_from_v): Add.
	(num_put::_M_convert_float): Use.
	(num_put::_M_convert_int): Same.
	(money_put::do_put): Same.

	* src/locale-inst.cc: Add instantiations for __convert_from_v.
	* config/locale/time_members_gnu.cc: Cleanup setlocale usage.
	* config/locale/time_members_generic.cc:
	* config/locale/messages_members_gnu.cc: Same.
	* config/locale/messages_members_gnu.h: Same.

	* testsuite/22_locale/codecvt_members_wchar_t_char.cc (test02): New.
	* testsuite/22_locale/codecvt_members_char_char.cc (test02): New.
	* testsuite/22_locale/collate_members_wchar_t.cc (test02): New.
	* testsuite/22_locale/collate_members_char.cc (test02): New.
	* testsuite/22_locale/ctype_members_wchar_t.cc (test03): New.
	* testsuite/22_locale/ctype_members_char.cc (test03): New.
	* testsuite/22_locale/messages_members_char.cc (test02): New.
	* testsuite/22_locale/moneypunct_members_wchar_t.cc (test02): New.
	* testsuite/22_locale/moneypunct_members_char.cc (test02): New.
	* testsuite/22_locale/money_get_members_wchar_t.cc (test04): New.
	* testsuite/22_locale/money_get_members_char.cc (test04): New.
	* testsuite/22_locale/money_put_members_wchar_t.cc (test04): New.
	* testsuite/22_locale/money_put_members_char.cc (test04): New.
	* testsuite/22_locale/numpunct_members_wchar_t.cc (test02): New.
	* testsuite/22_locale/numpunct_members_char.cc (test02): New.
	* testsuite/22_locale/time_put_members_wchar_t.cc (test03): New.
	* testsuite/22_locale/time_put_members_char.cc (test03): New.
	* testsuite/22_locale/time_get_members_wchar_t.cc (test07): New.
	* testsuite/22_locale/time_get_members_char.cc (test07): New.
	* testsuite/22_locale/num_get_members_wchar_t.cc (test03): New.
	* testsuite/22_locale/num_get_members_char.cc (test03): New.
	* testsuite/22_locale/num_put_members_wchar_t.cc (test03): New.
	* testsuite/22_locale/num_put_members_char.cc (test03): New.

	* testsuite/22_locale/time_get_members_char.cc: Fixups for global
	locale issues.
	* testsuite/22_locale/time_get_members_char.cc: Same.

2002-01-22  Benjamin Kosnik  <bkoz@redhat.com>

	libstdc++/5280
	* include/bits/localefwd.h: Tweak comments.
	* include/bits/locale_facets.h (__convert_to_v): Add.
	* include/bits/locale_facets.tcc (num_get::do_get(double)): Use it.
	(num_get::do_get(float)): Same.
	(num_get::do_get(long double)): Same.
	(num_get::do_get(bool)): Same.
	(num_get::do_get(long)): Same.
	(num_get::do_get(long long)): Same.
	(num_get::do_get(unsigned int)): Same.
	(num_get::do_get(unsigned short)): Same.
	(num_get::do_get(unsigned long)): Same.
	(num_get::do_get(unsigned long long)): Same.
	* config/locale/c_locale_gnu.cc (__convert_to_v): Specialize.
	* config/locale/c_locale_generic.cc: Same.

From-SVN: r49108
parent 98c3a44f
2002-01-22 Benjamin Kosnik <bkoz@redhat.com>
Audit for LANG independence.
* include/bits/localefwd.h: Tweaks.
* include/bits/locale_facets.tcc (money_get::do_get(long double)):
Use __convert_to_v.
(time_get::do_get_year): Same.
(__convert_from_v): Add.
(num_put::_M_convert_float): Use.
(num_put::_M_convert_int): Same.
(money_put::do_put): Same.
* src/locale-inst.cc: Add instantiations for __convert_from_v.
* config/locale/time_members_gnu.cc: Cleanup setlocale usage.
* config/locale/time_members_generic.cc:
* config/locale/messages_members_gnu.cc: Same.
* config/locale/messages_members_gnu.h: Same.
* testsuite/22_locale/codecvt_members_wchar_t_char.cc (test02): New.
* testsuite/22_locale/codecvt_members_char_char.cc (test02): New.
* testsuite/22_locale/collate_members_wchar_t.cc (test02): New.
* testsuite/22_locale/collate_members_char.cc (test02): New.
* testsuite/22_locale/ctype_members_wchar_t.cc (test03): New.
* testsuite/22_locale/ctype_members_char.cc (test03): New.
* testsuite/22_locale/messages_members_char.cc (test02): New.
* testsuite/22_locale/moneypunct_members_wchar_t.cc (test02): New.
* testsuite/22_locale/moneypunct_members_char.cc (test02): New.
* testsuite/22_locale/money_get_members_wchar_t.cc (test04): New.
* testsuite/22_locale/money_get_members_char.cc (test04): New.
* testsuite/22_locale/money_put_members_wchar_t.cc (test04): New.
* testsuite/22_locale/money_put_members_char.cc (test04): New.
* testsuite/22_locale/numpunct_members_wchar_t.cc (test02): New.
* testsuite/22_locale/numpunct_members_char.cc (test02): New.
* testsuite/22_locale/time_put_members_wchar_t.cc (test03): New.
* testsuite/22_locale/time_put_members_char.cc (test03): New.
* testsuite/22_locale/time_get_members_wchar_t.cc (test07): New.
* testsuite/22_locale/time_get_members_char.cc (test07): New.
* testsuite/22_locale/num_get_members_wchar_t.cc (test03): New.
* testsuite/22_locale/num_get_members_char.cc (test03): New.
* testsuite/22_locale/num_put_members_wchar_t.cc (test03): New.
* testsuite/22_locale/num_put_members_char.cc (test03): New.
* testsuite/22_locale/time_get_members_char.cc: Fixups for global
locale issues.
* testsuite/22_locale/time_get_members_char.cc: Same.
2002-01-22 Benjamin Kosnik <bkoz@redhat.com>
libstdc++/5280
* include/bits/localefwd.h: Tweak comments.
* include/bits/locale_facets.h (__convert_to_v): Add.
* include/bits/locale_facets.tcc (num_get::do_get(double)): Use it.
(num_get::do_get(float)): Same.
(num_get::do_get(long double)): Same.
(num_get::do_get(bool)): Same.
(num_get::do_get(long)): Same.
(num_get::do_get(long long)): Same.
(num_get::do_get(unsigned int)): Same.
(num_get::do_get(unsigned short)): Same.
(num_get::do_get(unsigned long)): Same.
(num_get::do_get(unsigned long long)): Same.
* config/locale/c_locale_gnu.cc (__convert_to_v): Specialize.
* config/locale/c_locale_generic.cc: Same.
2002-01-22 Loren Rittle <ljrittle@acm.org> 2002-01-22 Loren Rittle <ljrittle@acm.org>
* include/Makefile.am (c_base_builddir): Remove redundant slash. * include/Makefile.am (c_base_builddir): Remove redundant slash.
......
// Wrapper for underlying C-language localization -*- C++ -*- // Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -37,6 +37,149 @@ ...@@ -37,6 +37,149 @@
namespace std namespace std
{ {
// Specializations for all types used in num_get.
template<>
void
__convert_to_v(const char* __s, long& __v, ios_base::iostate& __err,
const __c_locale&, int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
long __l = strtol(__s, &__sanity, __base);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __l;
else
__err |= ios_base::failbit;
}
}
template<>
void
__convert_to_v(const char* __s, unsigned long& __v,
ios_base::iostate& __err, const __c_locale&, int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
unsigned long __ul = strtoul(__s, &__sanity, __base);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ul;
else
__err |= ios_base::failbit;
}
}
#ifdef _GLIBCPP_USE_LONG_LONG
template<>
void
__convert_to_v(const char* __s, long long& __v, ios_base::iostate& __err,
const __c_locale&, int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
long long __ll = strtoll(__s, &__sanity, __base);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ll;
else
__err |= ios_base::failbit;
}
}
template<>
void
__convert_to_v(const char* __s, unsigned long long& __v,
ios_base::iostate& __err, const __c_locale&, int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
unsigned long long __ull = strtoull(__s, &__sanity, __base);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ull;
else
__err |= ios_base::failbit;
}
}
#endif
template<>
void
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale&, int)
{
if (!(__err & ios_base::failbit))
{
// Assumes __s formatted for "C" locale.
const char* __old = setlocale(LC_ALL, "C");
char* __sanity;
errno = 0;
#ifdef _GLIBCPP_USE_C99
float __f = strtof(__s, &__sanity);
#else
float __f = static_cast<float>(strtod(__s, &__sanity));
#endif
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __f;
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
}
}
template<>
void
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale&, int)
{
if (!(__err & ios_base::failbit))
{
// Assumes __s formatted for "C" locale.
const char* __old = setlocale(LC_ALL, "C");
char* __sanity;
errno = 0;
double __d = strtod(__s, &__sanity);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __d;
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
}
}
template<>
void
__convert_to_v(const char* __s, long double& __v,
ios_base::iostate& __err, const __c_locale&, int)
{
if (!(__err & ios_base::failbit))
{
// Assumes __s formatted for "C" locale.
const char* __old = setlocale(LC_ALL, "C");
#if defined(_GLIBCPP_USE_C99) && !defined(__hpux)
char* __sanity;
errno = 0;
long double __ld = strtold(__s, &__sanity);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ld;
#else
typedef typename char_traits<_CharT>::int_type int_type;
long double __ld;
int __p = sscanf(__s, "%Lf", &__ld);
if (__p && static_cast<int_type>(__p) != char_traits<_CharT>::eof())
__v = __ld;
#endif
else
__err |= ios_base::failbit;
setlocale(LC_ALL, __old);
}
}
void void
locale::facet::_S_create_c_locale(__c_locale& __cloc, const char*) locale::facet::_S_create_c_locale(__c_locale& __cloc, const char*)
{ __cloc = NULL; } { __cloc = NULL; }
......
// Wrapper for underlying C-language localization -*- C++ -*- // Wrapper for underlying C-language localization -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -39,6 +39,130 @@ ...@@ -39,6 +39,130 @@
namespace std namespace std
{ {
template<>
void
__convert_to_v(const char* __s, long& __v, ios_base::iostate& __err,
const __c_locale& __cloc, int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
long __l = __strtol_l(__s, &__sanity, __base, __cloc);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __l;
else
__err |= ios_base::failbit;
}
}
template<>
void
__convert_to_v(const char* __s, unsigned long& __v,
ios_base::iostate& __err, const __c_locale& __cloc,
int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
unsigned long __ul = __strtoul_l(__s, &__sanity, __base, __cloc);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ul;
else
__err |= ios_base::failbit;
}
}
#ifdef _GLIBCPP_USE_LONG_LONG
template<>
void
__convert_to_v(const char* __s, long long& __v, ios_base::iostate& __err,
const __c_locale& __cloc, int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
long long __ll = __strtoll_l(__s, &__sanity, __base, __cloc);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ll;
else
__err |= ios_base::failbit;
}
}
template<>
void
__convert_to_v(const char* __s, unsigned long long& __v,
ios_base::iostate& __err, const __c_locale& __cloc,
int __base)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
unsigned long long __ull = __strtoull_l(__s, &__sanity, __base,
__cloc);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ull;
else
__err |= ios_base::failbit;
}
}
#endif
template<>
void
__convert_to_v(const char* __s, float& __v, ios_base::iostate& __err,
const __c_locale& __cloc, int)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
float __f = __strtof_l(__s, &__sanity, __cloc);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __f;
else
__err |= ios_base::failbit;
}
}
template<>
void
__convert_to_v(const char* __s, double& __v, ios_base::iostate& __err,
const __c_locale& __cloc, int)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
double __d = __strtod_l(__s, &__sanity, __cloc);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __d;
else
__err |= ios_base::failbit;
}
}
template<>
void
__convert_to_v(const char* __s, long double& __v, ios_base::iostate& __err,
const __c_locale& __cloc, int)
{
if (!(__err & ios_base::failbit))
{
char* __sanity;
errno = 0;
long double __ld = __strtold_l(__s, &__sanity, __cloc);
if (__sanity != __s && *__sanity == '\0' && errno == 0)
__v = __ld;
else
__err |= ios_base::failbit;
}
}
void void
locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s) locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s)
{ {
......
// std::messages implementation details, GNU version -*- C++ -*- // std::messages implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -49,8 +49,9 @@ namespace std ...@@ -49,8 +49,9 @@ namespace std
uselocale(__old); uselocale(__old);
return string(__msg); return string(__msg);
#else #else
setlocale(LC_ALL, _M_name_messages); const char* __old = setlocale(LC_ALL, _M_name_messages);
const char* __msg = gettext(__dfault.c_str()); const char* __msg = gettext(__dfault.c_str());
setlocale(LC_ALL, __old);
return string(__msg); return string(__msg);
#endif #endif
} }
......
// std::messages implementation details, GNU version -*- C++ -*- // std::messages implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -66,8 +66,9 @@ ...@@ -66,8 +66,9 @@
uselocale(__old); uselocale(__old);
return _M_convert_from_char(__msg); return _M_convert_from_char(__msg);
#else #else
setlocale(LC_ALL, _M_name_messages); const char* __old = 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);
return _M_convert_from_char(__msg); return _M_convert_from_char(__msg);
#endif #endif
} }
......
// std::numpunct implementation details, generic version -*- C++ -*- // std::numpunct implementation details, generic version -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
......
// std::numpunct implementation details, GNU version -*- C++ -*- // std::numpunct implementation details, GNU version -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
......
// std::time_get, std::time_put implementation, GNU version -*- C++ -*- // std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -44,8 +44,9 @@ namespace std ...@@ -44,8 +44,9 @@ namespace std
_M_put_helper(char* __s, size_t __maxlen, const char* __format, _M_put_helper(char* __s, size_t __maxlen, const char* __format,
const tm* __tm) const const tm* __tm) const
{ {
setlocale(LC_ALL, _M_name_timepunct); const char* __old = setlocale(LC_ALL, _M_name_timepunct);
strftime(__s, __maxlen, __format, __tm); strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
} }
template<> template<>
...@@ -117,8 +118,9 @@ namespace std ...@@ -117,8 +118,9 @@ namespace std
_M_put_helper(wchar_t* __s, size_t __maxlen, const wchar_t* __format, _M_put_helper(wchar_t* __s, size_t __maxlen, const wchar_t* __format,
const tm* __tm) const const tm* __tm) const
{ {
setlocale(LC_ALL, _M_name_timepunct); const char* __old = setlocale(LC_ALL, _M_name_timepunct);
wcsftime(__s, __maxlen, __format, __tm); wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
} }
template<> template<>
......
// std::time_get, std::time_put implementation, GNU version -*- C++ -*- // std::time_get, std::time_put implementation, GNU version -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -51,8 +51,9 @@ namespace std ...@@ -51,8 +51,9 @@ namespace std
else else
strftime(__s, __maxlen, __format, __tm); strftime(__s, __maxlen, __format, __tm);
#else #else
setlocale(LC_ALL, _M_name_timepunct); const char* __old = setlocale(LC_ALL, _M_name_timepunct);
strftime(__s, __maxlen, __format, __tm); strftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
#endif #endif
} }
...@@ -195,8 +196,9 @@ namespace std ...@@ -195,8 +196,9 @@ namespace std
else else
wcsftime(__s, __maxlen, __format, __tm); wcsftime(__s, __maxlen, __format, __tm);
#else #else
setlocale(LC_ALL, _M_name_timepunct); const char* __old = setlocale(LC_ALL, _M_name_timepunct);
wcsftime(__s, __maxlen, __format, __tm); wcsftime(__s, __maxlen, __format, __tm);
setlocale(LC_ALL, __old);
#endif #endif
} }
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -53,7 +54,7 @@ namespace std ...@@ -53,7 +54,7 @@ namespace std
// Include host and configuration specific ctype enums for ctype_base. // Include host and configuration specific ctype enums for ctype_base.
#include <bits/ctype_base.h> #include <bits/ctype_base.h>
// __ctype_abstract_base is the common base for ctype<_CharT>. // Common base for ctype<_CharT>.
template<typename _CharT> template<typename _CharT>
class __ctype_abstract_base : public locale::facet, public ctype_base class __ctype_abstract_base : public locale::facet, public ctype_base
{ {
...@@ -419,7 +420,7 @@ namespace std ...@@ -419,7 +420,7 @@ namespace std
// 22.2.2 The numeric category. // 22.2.2 The numeric category.
class __num_base class __num_base
{ {
public: protected:
// Used to establish gating factor for base 16 input. // Used to establish gating factor for base 16 input.
static const double _S_scale_hex; static const double _S_scale_hex;
...@@ -438,6 +439,7 @@ namespace std ...@@ -438,6 +439,7 @@ namespace std
_M_size = 21 + 1 _M_size = 21 + 1
}; };
// num_put
// Construct and return valid scanf format for floating point types. // Construct and return valid scanf format for floating point types.
static bool static bool
_S_format_float(const ios_base& __io, char* __fptr, char __mod, _S_format_float(const ios_base& __io, char* __fptr, char __mod,
...@@ -448,6 +450,7 @@ namespace std ...@@ -448,6 +450,7 @@ namespace std
_S_format_int(const ios_base& __io, char* __fptr, char __mod, char __modl); _S_format_int(const ios_base& __io, char* __fptr, char __mod, char __modl);
}; };
template<typename _CharT> template<typename _CharT>
class numpunct : public locale::facet class numpunct : public locale::facet
{ {
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
// Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -295,7 +296,7 @@ namespace std ...@@ -295,7 +296,7 @@ namespace std
}; };
// locale implementation object // Implementation object for locale
class locale::_Impl class locale::_Impl
{ {
public: public:
...@@ -390,9 +391,12 @@ namespace std ...@@ -390,9 +391,12 @@ namespace std
friend class locale::_Impl; friend class locale::_Impl;
friend class __enc_traits; friend class __enc_traits;
private:
size_t _M_references;
protected: protected:
// Contains data from the underlying "C" library for default "C" // Contains data from the underlying "C" library for default "C"
// and "POSIX" locales. // or "POSIX" locale.
static __c_locale _S_c_locale; static __c_locale _S_c_locale;
explicit explicit
...@@ -411,18 +415,16 @@ namespace std ...@@ -411,18 +415,16 @@ namespace std
_S_destroy_c_locale(__c_locale& __cloc); _S_destroy_c_locale(__c_locale& __cloc);
private: private:
size_t _M_references;
void void
_M_add_reference() throw(); _M_add_reference() throw();
void void
_M_remove_reference() throw(); _M_remove_reference() throw();
facet(const facet&); // not defined facet(const facet&); // Not defined.
void void
operator=(const facet&); // not defined operator=(const facet&); // Not defined.
}; };
......
// Locale support -*- C++ -*- // Locale support -*- C++ -*-
// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. // Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -373,6 +373,32 @@ namespace std ...@@ -373,6 +373,32 @@ namespace std
#endif // _GLIBCPP_USE_WCHAR_T #endif // _GLIBCPP_USE_WCHAR_T
template template
int
__convert_from_v(char*, const char*, double, const __c_locale&, int);
template
int
__convert_from_v(char*, const char*, long double, const __c_locale&, int);
template
int
__convert_from_v(char*, const char*, long, const __c_locale&, int);
template
int
__convert_from_v(char*, const char*, unsigned long,
const __c_locale&, int);
template
int
__convert_from_v(char*, const char*, long long, const __c_locale&, int);
template
int
__convert_from_v(char*, const char*, unsigned long long,
const __c_locale&, int);
template
locale::facet** locale::facet**
fill_n<locale::facet**, size_t, locale::facet*> fill_n<locale::facet**, size_t, locale::facet*>
(locale::facet**, size_t, locale::facet* const&); (locale::facet**, size_t, locale::facet* const&);
......
// 2000-08-17 Benjamin Kosnik <bkoz@cygnus.com> // 2000-08-17 Benjamin Kosnik <bkoz@cygnus.com>
// Copyright (C) 2000 Free Software Foundation // Copyright (C) 2000, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -79,9 +79,25 @@ void test01() ...@@ -79,9 +79,25 @@ void test01()
delete [] c_arr; delete [] c_arr;
} }
int main () // libstdc++/5280
void test02()
{ {
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01(); test01();
setenv("LANG", oldLANG, 1);
}
}
int main ()
{
test01();
test02();
return 0; return 0;
} }
// 2000-08-18 Benjamin Kosnik <bkoz@cygnus.com> // 2000-08-18 Benjamin Kosnik <bkoz@cygnus.com>
// Copyright (C) 2000 Free Software Foundation // Copyright (C) 2000, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -110,6 +110,22 @@ void test01() ...@@ -110,6 +110,22 @@ void test01()
delete [] e_arr; delete [] e_arr;
delete [] i_arr; delete [] i_arr;
} }
// libstdc++/5280
void test02()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
setenv("LANG", oldLANG, 1);
}
}
#endif /* !defined(_GLIBCPP_USE_WCHAR_T) */ #endif /* !defined(_GLIBCPP_USE_WCHAR_T) */
...@@ -117,6 +133,7 @@ int main () ...@@ -117,6 +133,7 @@ int main ()
{ {
#if _GLIBCPP_USE_WCHAR_T #if _GLIBCPP_USE_WCHAR_T
test01(); test01();
test02();
#endif #endif
return 0; return 0;
......
// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com> // 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation // Copyright (C) 2001, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -129,10 +129,26 @@ void test01() ...@@ -129,10 +129,26 @@ void test01()
VERIFY(i1 == i2); VERIFY(i1 == i2);
} }
int main() // libstdc++/5280
void test02()
{ {
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01(); test01();
setenv("LANG", oldLANG, 1);
}
}
int main()
{
test01();
test02();
return 0; return 0;
} }
......
// 2001-08-17 Benjamin Kosnik <bkoz@redhat.com> // 2001-08-17 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation // Copyright (C) 2001, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -128,12 +128,29 @@ void test01() ...@@ -128,12 +128,29 @@ void test01()
i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4); i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4);
VERIFY(i1 == i2); VERIFY(i1 == i2);
} }
// libstdc++/5280
void test02()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
{ {
#if _GLIBCPP_USE_WCHAR_T #if _GLIBCPP_USE_WCHAR_T
test01(); test01();
test02();
#endif #endif
return 0; return 0;
} }
......
...@@ -243,10 +243,27 @@ public: ...@@ -243,10 +243,27 @@ public:
{ classic_table(); } { classic_table(); }
}; };
int main() // libstdc++/5280
void test03()
{ {
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01(); test01();
test02(); test02();
setenv("LANG", oldLANG, 1);
}
}
int main()
{
test01();
test02();
test03();
return 0; return 0;
} }
// 2000-09-01 Benjamin Kosnik <bkoz@redhat.com> // 2000-09-01 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2000, 2001 Free Software Foundation, Inc. // Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -96,12 +96,29 @@ void test01() ...@@ -96,12 +96,29 @@ void test01()
assert(test); assert(test);
#endif #endif
} }
// libstdc++/5280
void test03()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
setenv("LANG", oldLANG, 1);
}
}
#endif /* !defined(_GLIBCPP_USE_WCHAR_T) */ #endif /* !defined(_GLIBCPP_USE_WCHAR_T) */
int main() int main()
{ {
#if _GLIBCPP_USE_WCHAR_T #if _GLIBCPP_USE_WCHAR_T
test01(); test01();
test03();
#endif #endif
return 0; return 0;
......
// 2001-07-17 Benjamin Kosnik <bkoz@redhat.com> // 2001-07-17 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation // Copyright (C) 2001, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -79,12 +79,27 @@ void test01() ...@@ -79,12 +79,27 @@ void test01()
VERIFY ( s01 == "please" ); VERIFY ( s01 == "please" );
VERIFY ( s02 == "thank you" ); VERIFY ( s02 == "thank you" );
mssg_us.close(cat_us); mssg_us.close(cat_us);
}
// libstdc++/5280
void test02()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
setenv("LANG", oldLANG, 1);
} }
}
int main() int main()
{ {
test01(); test01();
test02();
return 0; return 0;
} }
...@@ -289,10 +289,29 @@ void test03() ...@@ -289,10 +289,29 @@ void test03()
VERIFY( rem2 == "Eleanor Roosevelt" ); VERIFY( rem2 == "Eleanor Roosevelt" );
} }
// libstdc++/5280
void test04()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
test03();
setenv("LANG", oldLANG, 1);
}
}
int main() int main()
{ {
test01(); test01();
test02(); test02();
test03(); test03();
test04();
return 0; return 0;
} }
...@@ -290,6 +290,24 @@ void test03() ...@@ -290,6 +290,24 @@ void test03()
VERIFY( res2 == 1 ); VERIFY( res2 == 1 );
VERIFY( rem2 == L"Eleanor Roosevelt" ); VERIFY( rem2 == L"Eleanor Roosevelt" );
} }
// libstdc++/5280
void test04()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
test03();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
...@@ -299,6 +317,7 @@ int main() ...@@ -299,6 +317,7 @@ int main()
test01(); test01();
test02(); test02();
test03(); test03();
test04();
#endif #endif
return 0; return 0;
} }
...@@ -283,10 +283,29 @@ void test03() ...@@ -283,10 +283,29 @@ void test03()
VERIFY( sanity2 == "1943" ); VERIFY( sanity2 == "1943" );
} }
// libstdc++/5280
void test04()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
test03();
setenv("LANG", oldLANG, 1);
}
}
int main() int main()
{ {
test01(); test01();
test02(); test02();
test03(); test03();
test04();
return 0; return 0;
} }
...@@ -282,6 +282,24 @@ void test03() ...@@ -282,6 +282,24 @@ void test03()
VERIFY( res == L"1943xxxxxxxxxxxxx" ); VERIFY( res == L"1943xxxxxxxxxxxxx" );
VERIFY( sanity2 == L"1943" ); VERIFY( sanity2 == L"1943" );
} }
// libstdc++/5280
void test04()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
test03();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
...@@ -290,6 +308,7 @@ int main() ...@@ -290,6 +308,7 @@ int main()
test01(); test01();
test02(); test02();
test03(); test03();
test04();
#endif #endif
return 0; return 0;
} }
// 2001-08-23 Benjamin Kosnik <bkoz@redhat.com> // 2001-08-23 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation // Copyright (C) 2001, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -105,9 +105,25 @@ void test01() ...@@ -105,9 +105,25 @@ void test01()
VERIFY(static_cast<part>(neg1.field[3]) != static_cast<part>(neg2.field[3])); VERIFY(static_cast<part>(neg1.field[3]) != static_cast<part>(neg2.field[3]));
} }
int main() // libstdc++/5280
void test02()
{ {
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01(); test01();
setenv("LANG", oldLANG, 1);
}
}
int main()
{
test01();
test02();
return 0; return 0;
} }
// 2001-09-09 Benjamin Kosnik <bkoz@redhat.com> // 2001-09-09 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation // Copyright (C) 2001, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -105,12 +105,29 @@ void test01() ...@@ -105,12 +105,29 @@ void test01()
VERIFY(static_cast<part>(neg1.field[2]) != static_cast<part>(neg2.field[2])); VERIFY(static_cast<part>(neg1.field[2]) != static_cast<part>(neg2.field[2]));
VERIFY(static_cast<part>(neg1.field[3]) != static_cast<part>(neg2.field[3])); VERIFY(static_cast<part>(neg1.field[3]) != static_cast<part>(neg2.field[3]));
} }
// libstdc++/5280
void test02()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
{ {
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
test01(); test01();
test02();
#endif #endif
return 0; return 0;
} }
...@@ -313,10 +313,28 @@ void test02() ...@@ -313,10 +313,28 @@ void test02()
VERIFY( rem5 == " Durack" ); VERIFY( rem5 == " Durack" );
} }
// libstdc++/5280
void test03()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
setenv("LANG", oldLANG, 1);
}
}
int main() int main()
{ {
test01(); test01();
test02(); test02();
test03();
return 0; return 0;
} }
......
...@@ -314,6 +314,23 @@ void test02() ...@@ -314,6 +314,23 @@ void test02()
VERIFY( b == true ); VERIFY( b == true );
VERIFY( rem5 == L" Durack" ); VERIFY( rem5 == L" Durack" );
} }
// libstdc++/5280
void test03()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
...@@ -321,6 +338,7 @@ int main() ...@@ -321,6 +338,7 @@ int main()
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
test01(); test01();
test02(); test02();
test03();
#endif #endif
return 0; return 0;
} }
......
...@@ -291,9 +291,29 @@ void test02() ...@@ -291,9 +291,29 @@ void test02()
VERIFY( sanity5[1] == 'x' ); VERIFY( sanity5[1] == 'x' );
} }
// libstdc++/5280
void test03()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
setenv("LANG", oldLANG, 1);
}
}
int main() int main()
{ {
test01(); test01();
test02(); test02();
test03();
return 0; return 0;
} }
...@@ -290,6 +290,23 @@ void test02() ...@@ -290,6 +290,23 @@ void test02()
VERIFY( sanity5.size() ); VERIFY( sanity5.size() );
VERIFY( sanity5[1] == L'x' ); VERIFY( sanity5[1] == L'x' );
} }
// libstdc++/5280
void test03()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
...@@ -297,6 +314,7 @@ int main() ...@@ -297,6 +314,7 @@ int main()
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
test01(); test01();
test02(); test02();
test03();
#endif #endif
return 0; return 0;
} }
...@@ -304,3 +322,4 @@ int main() ...@@ -304,3 +322,4 @@ int main()
// Diana D. Brooks, former chief executive of Sotheby's // Diana D. Brooks, former chief executive of Sotheby's
// art-thief extraordinaire // art-thief extraordinaire
// 2001-01-17 Benjamin Kosnik <bkoz@redhat.com> // 2001-01-17 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation // Copyright (C) 2001, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -83,9 +83,25 @@ void test01() ...@@ -83,9 +83,25 @@ void test01()
// VERIFY( f2 != f3 ); // VERIFY( f2 != f3 );
} }
int main() // libstdc++/5280
void test02()
{ {
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01(); test01();
setenv("LANG", oldLANG, 1);
}
}
int main()
{
test01();
test02();
return 0; return 0;
} }
// 2001-11-20 Benjamin Kosnik <bkoz@redhat.com> // 2001-11-20 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001 Free Software Foundation // Copyright (C) 2001, 2002 Free Software Foundation
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -80,12 +80,29 @@ void test01() ...@@ -80,12 +80,29 @@ void test01()
VERIFY( dp2 != dp4 ); VERIFY( dp2 != dp4 );
VERIFY( th2 != th4 ); VERIFY( th2 != th4 );
} }
// libstdc++/5280
void test02()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
{ {
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
test01(); test01();
test02();
#endif #endif
return 0; return 0;
} }
...@@ -193,6 +193,7 @@ void test02() ...@@ -193,6 +193,7 @@ void test02()
// ios_base::iostate&, tm*) const // ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str("Sunday"); iss.str("Sunday");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -315,6 +316,7 @@ void test03() ...@@ -315,6 +316,7 @@ void test03()
// ios_base::iostate&, tm*) const // ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str("April"); iss.str("April");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -436,6 +438,7 @@ void test04() ...@@ -436,6 +438,7 @@ void test04()
// get_year(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const // get_year(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str("1971"); iss.str("1971");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -527,6 +530,7 @@ void test05() ...@@ -527,6 +530,7 @@ void test05()
// get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const // get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str("04/04/71"); iss.str("04/04/71");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -672,6 +676,27 @@ void test06() ...@@ -672,6 +676,27 @@ void test06()
VERIFY( rem5 == " Cindy Sherman" ); VERIFY( rem5 == " Cindy Sherman" );
} }
// libstdc++/5280
void test07()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
test03();
test04();
test05();
test06();
setenv("LANG", oldLANG, 1);
}
}
int main() int main()
{ {
test01(); test01();
...@@ -681,5 +706,7 @@ int main() ...@@ -681,5 +706,7 @@ int main()
test05(); test05();
test06(); test06();
test07();
return 0; return 0;
} }
...@@ -193,6 +193,7 @@ void test02() ...@@ -193,6 +193,7 @@ void test02()
// ios_base::iostate&, tm*) const // ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str(L"Sunday"); iss.str(L"Sunday");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -315,6 +316,7 @@ void test03() ...@@ -315,6 +316,7 @@ void test03()
// ios_base::iostate&, tm*) const // ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str(L"April"); iss.str(L"April");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -436,6 +438,7 @@ void test04() ...@@ -436,6 +438,7 @@ void test04()
// get_year(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const // get_year(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str(L"1971"); iss.str(L"1971");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -527,6 +530,7 @@ void test05() ...@@ -527,6 +530,7 @@ void test05()
// get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const // get_date(iter_type, iter_type, ios_base&, ios_base::iostate&, tm*) const
// sanity checks for "C" locale // sanity checks for "C" locale
iss.imbue(loc_c);
iss.str(L"04/04/71"); iss.str(L"04/04/71");
iterator_type is_it01(iss); iterator_type is_it01(iss);
tm time01; tm time01;
...@@ -671,6 +675,27 @@ void test06() ...@@ -671,6 +675,27 @@ void test06()
VERIFY( tm1.tm_year == time_sanity.tm_year ); VERIFY( tm1.tm_year == time_sanity.tm_year );
VERIFY( rem5 == L" Cindy Sherman" ); VERIFY( rem5 == L" Cindy Sherman" );
} }
// libstdc++/5280
void test07()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
test03();
test04();
test05();
test06();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
...@@ -683,6 +708,8 @@ int main() ...@@ -683,6 +708,8 @@ int main()
test05(); test05();
test06(); test06();
test07();
#endif #endif
return 0; return 0;
} }
...@@ -231,9 +231,27 @@ void test02() ...@@ -231,9 +231,27 @@ void test02()
VERIFY( sanity2 == "Tuesday" ); VERIFY( sanity2 == "Tuesday" );
} }
// libstdc++/5280
void test03()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
setenv("LANG", oldLANG, 1);
}
}
int main() int main()
{ {
test01(); test01();
test02(); test02();
test03();
return 0; return 0;
} }
...@@ -232,6 +232,23 @@ void test02() ...@@ -232,6 +232,23 @@ void test02()
VERIFY( res == L"Tuesdayxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ); VERIFY( res == L"Tuesdayxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );
VERIFY( sanity2 == L"Tuesday" ); VERIFY( sanity2 == L"Tuesday" );
} }
// libstdc++/5280
void test03()
{
// Set the global locale to non-"C".
std::locale loc_de("de_DE");
std::locale::global(loc_de);
// Set LANG environment variable to de_DE.
const char* oldLANG = getenv("LANG");
if (!setenv("LANG", "de_DE", 1))
{
test01();
test02();
setenv("LANG", oldLANG, 1);
}
}
#endif #endif
int main() int main()
...@@ -239,6 +256,7 @@ int main() ...@@ -239,6 +256,7 @@ int main()
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
test01(); test01();
test02(); test02();
test03();
#endif #endif
return 0; return 0;
} }
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