+2003-10-22 Benjamin Kosnik <bkoz@redhat.com>
+
+ * include/bits/locale_facets.h: Correct byname facets for "C"
+ locale.
+ * config/locale/generic/ctype_members.cc: Same.
+ * config/locale/generic/messages_members.h: Same.
+ * config/locale/gnu/ctype_members.cc: Same.
+ * config/locale/gnu/messages_members.h: Same.
+ * include/bits/codecvt.h: Same.
+ * src/ctype.cc: Same.
+ * testsuite/22_locale/codecvt_byname/1.cc: New.
+ * testsuite/22_locale/collate/1.cc: Edit.
+ * testsuite/22_locale/collate_byname/1.cc: Derivation tests, move to...
+ * testsuite/22_locale/collate_byname/named_equivalence.cc: ...here.
+ * testsuite/22_locale/ctype/1.cc: Derivation tests.
+ * testsuite/22_locale/ctype/11844.cc: Move...
+ * testsuite/22_locale/ctype_base/11844.cc: ...here.
+ * testsuite/22_locale/ctype_base/1.cc: Move mask bits here.
+ * testsuite/22_locale/ctype_byname/1.cc: Name.
+ * testsuite/22_locale/messages_byname/1.cc: New.
+ * testsuite/22_locale/messages_byname/named_equivalence.cc: New.
+ * testsuite/22_locale/moneypunct_byname/1.cc: Derivation test.
+ * testsuite/22_locale/moneypunct_byname/named_equivalence.cc: New.
+ * testsuite/22_locale/numpunct/1.cc: Edit.
+ * testsuite/22_locale/numpunct_byname/2.cc: Move...
+ * testsuite/22_locale/numpunct/members/char/3.cc: ...here.
+ * testsuite/22_locale/numpunct_byname/1.cc: Derivation tests.
+ * testsuite/22_locale/numpunct_byname/named_equivalence.cc: New.
+
2003-10-22 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/8610
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
: ctype<char>(0, false, __refs)
{
- _S_destroy_c_locale(_M_c_locale_ctype);
- _S_create_c_locale(_M_c_locale_ctype, __s);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ _S_destroy_c_locale(_M_c_locale_ctype);
+ _S_create_c_locale(_M_c_locale_ctype, __s);
+ }
}
#ifdef _GLIBCXX_USE_WCHAR_T
messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs)
: messages<_CharT>(__refs)
{
- _S_destroy_c_locale(this->_M_c_locale_messages);
- _S_create_c_locale(this->_M_c_locale_messages, __s);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ _S_destroy_c_locale(this->_M_c_locale_messages);
+ _S_create_c_locale(this->_M_c_locale_messages, __s);
+ }
}
template<>
ctype_byname<char>::ctype_byname(const char* __s, size_t __refs)
: ctype<char>(0, false, __refs)
- {
- _S_destroy_c_locale(_M_c_locale_ctype);
- _S_create_c_locale(_M_c_locale_ctype, __s);
- _M_toupper = _M_c_locale_ctype->__ctype_toupper;
- _M_tolower = _M_c_locale_ctype->__ctype_tolower;
- _M_table = _M_c_locale_ctype->__ctype_b;
+ {
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ _S_destroy_c_locale(_M_c_locale_ctype);
+ _S_create_c_locale(_M_c_locale_ctype, __s);
+ _M_toupper = _M_c_locale_ctype->__ctype_toupper;
+ _M_tolower = _M_c_locale_ctype->__ctype_tolower;
+ _M_table = _M_c_locale_ctype->__ctype_b;
+ }
}
#ifdef _GLIBCXX_USE_WCHAR_T
std::strcpy(__tmp, __s);
this->_M_name_messages = __tmp;
#endif
- _S_destroy_c_locale(this->_M_c_locale_messages);
- _S_create_c_locale(this->_M_c_locale_messages, __s);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ _S_destroy_c_locale(this->_M_c_locale_messages);
+ _S_create_c_locale(this->_M_c_locale_messages, __s);
+ }
}
codecvt_byname(const char* __s, size_t __refs = 0)
: codecvt<_InternT, _ExternT, _StateT>(__refs)
{
- _S_destroy_c_locale(this->_M_c_locale_codecvt);
- _S_create_c_locale(this->_M_c_locale_codecvt, __s);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ _S_destroy_c_locale(this->_M_c_locale_codecvt);
+ _S_create_c_locale(this->_M_c_locale_codecvt, __s);
+ }
}
protected:
template<typename _CharT>
class numpunct_byname : public numpunct<_CharT>
{
- // Data Member.
- __c_locale _M_c_locale_numpunct;
-
public:
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
numpunct_byname(const char* __s, size_t __refs = 0)
: numpunct<_CharT>(__refs)
{
- this->_S_create_c_locale(_M_c_locale_numpunct, __s);
- this->_M_initialize_numpunct(_M_c_locale_numpunct);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ __c_locale __tmp;
+ this->_S_create_c_locale(__tmp, __s);
+ this->_M_initialize_numpunct(__tmp);
+ this->_S_destroy_c_locale(__tmp);
+ }
}
protected:
virtual
- ~numpunct_byname()
- { this->_S_destroy_c_locale(_M_c_locale_numpunct); }
+ ~numpunct_byname() { }
};
template<typename _CharT, typename _InIter>
collate_byname(const char* __s, size_t __refs = 0)
: collate<_CharT>(__refs)
{
- this->_S_destroy_c_locale(this->_M_c_locale_collate);
- this->_S_create_c_locale(this->_M_c_locale_collate, __s);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ this->_S_destroy_c_locale(this->_M_c_locale_collate);
+ this->_S_create_c_locale(this->_M_c_locale_collate, __s);
+ }
}
protected:
typedef _OutIter iter_type;
explicit
- time_put_byname(const char* /*__s*/, size_t __refs = 0)
+ time_put_byname(const char*, size_t __refs = 0)
: time_put<_CharT, _OutIter>(__refs)
{ };
template<typename _CharT, bool _Intl>
class moneypunct_byname : public moneypunct<_CharT, _Intl>
{
- __c_locale _M_c_locale_moneypunct;
-
public:
typedef _CharT char_type;
typedef basic_string<_CharT> string_type;
moneypunct_byname(const char* __s, size_t __refs = 0)
: moneypunct<_CharT, _Intl>(__refs)
{
- this->_S_create_c_locale(_M_c_locale_moneypunct, __s);
- this->_M_initialize_moneypunct(_M_c_locale_moneypunct);
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ __c_locale __tmp;
+ this->_S_create_c_locale(__tmp, __s);
+ this->_M_initialize_moneypunct(__tmp);
+ this->_S_destroy_c_locale(__tmp);
+ }
}
protected:
virtual
- ~moneypunct_byname()
- { this->_S_destroy_c_locale(_M_c_locale_moneypunct); }
+ ~moneypunct_byname() { }
};
template<typename _CharT, bool _Intl>
template<>
ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
: ctype<wchar_t>(__refs)
- {
- _S_destroy_c_locale(_M_c_locale_ctype);
- _S_create_c_locale(_M_c_locale_ctype, __s);
+ {
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ _S_destroy_c_locale(_M_c_locale_ctype);
+ _S_create_c_locale(_M_c_locale_ctype, __s);
+ }
}
#endif
} // namespace std
--- /dev/null
+// { dg-do compile }
+// 2001-08-27 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.1.5 Template class codecvt
+
+#include <locale>
+
+void test01()
+{
+ // Check for required base class.
+ typedef std::codecvt_byname<char, char, mbstate_t> test_type;
+ typedef std::codecvt<char, char, mbstate_t> base_type;
+ const test_type& obj = std::use_facet<test_type>(std::locale::classic());
+ const base_type* base __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::intern_type intern_type;
+ typedef test_type::extern_type extern_type;
+ typedef test_type::state_type state_type;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
void test01()
{
// Check for required base class.
- typedef std::messages<char> test_type;
+ typedef std::collate<char> test_type;
typedef std::locale::facet base_type;
const test_type& obj = std::use_facet<test_type>(std::locale());
const base_type* base __attribute__((unused)) = &obj;
-// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2002 Free Software Foundation
+// Copyright (C) 2001 Free Software Foundation
//
// 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 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
-// 22.2.4.2 Template class collate_byname
+// 22.2.4 The collate category
#include <locale>
-#include <testsuite_hooks.h>
void test01()
{
- using namespace std;
- typedef std::collate<char>::string_type string_type;
-
- bool test __attribute__((unused)) = true;
- string str;
- locale loc_c = locale::classic();
-
- locale loc_de = __gnu_test::try_named_locale("de_DE");
- str = loc_de.name();
-
- locale loc_byname(locale::classic(), new collate_byname<char>("de_DE"));
- str = loc_byname.name();
-
- VERIFY( loc_de != loc_byname );
-
- // cache the collate facets
- const collate<char>& coll_de = use_facet<collate<char> >(loc_de);
-
- // Check German "de_DE" locale.
- int i1;
- int i2;
- long l1;
- long l2;
- const char* strlit3 = "Äuglein Augment"; // "C" == "Augment Äuglein"
- const char* strlit4 = "Base baß Baß Bast"; // "C" == "Base baß Baß Bast"
-
- int size3 = strlen(strlit3) - 1;
- i1 = coll_de.compare(strlit3, strlit3 + size3, strlit3, strlit3 + 7);
- VERIFY ( i1 == 1 );
- i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size3);
- VERIFY ( i1 == -1 );
- i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
- VERIFY ( i1 == 0 );
-
- i1 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
- VERIFY ( i1 == -1 );
-
- int size4 = strlen(strlit4) - 1;
- i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
- VERIFY ( i2 == 1 );
- i2 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
- VERIFY ( i2 == -1 );
- i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
- VERIFY ( i2 == 0 );
-
- l1 = coll_de.hash(strlit3, strlit3 + size3);
- l2 = coll_de.hash(strlit3, strlit3 + size3 - 1);
- VERIFY ( l1 != l2 );
- l1 = coll_de.hash(strlit3, strlit3 + size3);
- l2 = coll_de.hash(strlit4, strlit4 + size4);
- VERIFY ( l1 != l2 );
-
- string str3 = coll_de.transform(strlit3, strlit3 + size3);
- string str4 = coll_de.transform(strlit4, strlit4 + size4);
- i1 = str3.compare(str4);
- i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4);
- VERIFY ( i2 == -1 );
- VERIFY ( i1 * i2 > 0 );
-
-
- // Check byname locale
- int i3;
- int i4;
- long l3;
- long l4;
- size4 = strlen(strlit3) - 1;
- i3 = coll_de.compare(strlit3, strlit3 + size4, strlit3, strlit3 + 7);
- VERIFY ( i3 == 1 );
- i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size4);
- VERIFY ( i3 == -1 );
- i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
- VERIFY ( i3 == 0 );
-
- i3 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
- VERIFY ( i3 == -1 );
-
- size4 = strlen(strlit4) - 1;
- i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
- VERIFY ( i4 == 1 );
- i4 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
- VERIFY ( i4 == -1 );
- i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
- VERIFY ( i4 == 0 );
-
- l3 = coll_de.hash(strlit3, strlit3 + size4);
- l4 = coll_de.hash(strlit3, strlit3 + size4 - 1);
- VERIFY ( l3 != l4 );
- l3 = coll_de.hash(strlit3, strlit3 + size4);
- l4 = coll_de.hash(strlit4, strlit4 + size4);
- VERIFY ( l3 != l4 );
-
- string str5 = coll_de.transform(strlit3, strlit3 + size3);
- string str6 = coll_de.transform(strlit4, strlit4 + size4);
- i3 = str5.compare(str6);
- i4 = coll_de.compare(strlit3, strlit3 + size4, strlit4, strlit4 + size4);
- VERIFY ( i4 == -1 );
- VERIFY ( i3 * i4 > 0 );
-
- // Verify byname == de
- VERIFY ( str5 == str3 );
- VERIFY ( str6 == str4 );
+ // Check for required base class.
+ typedef std::collate_byname<char> test_type;
+ typedef std::collate<char> base_type;
+ const test_type& obj = std::use_facet<test_type>(std::locale::classic());
+ const base_type* base __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::string_type string_type;
}
int main()
--- /dev/null
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.4.2 Template class collate_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef std::collate<char>::string_type string_type;
+
+ bool test __attribute__((unused)) = true;
+ string str;
+ locale loc_c = locale::classic();
+
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ str = loc_de.name();
+
+ locale loc_byname(locale::classic(), new collate_byname<char>("de_DE"));
+ str = loc_byname.name();
+
+ VERIFY( loc_de != loc_byname );
+
+ // cache the collate facets
+ const collate<char>& coll_de = use_facet<collate<char> >(loc_de);
+
+ // Check German "de_DE" locale.
+ int i1;
+ int i2;
+ long l1;
+ long l2;
+ const char* strlit3 = "Äuglein Augment"; // "C" == "Augment Äuglein"
+ const char* strlit4 = "Base baß Baß Bast"; // "C" == "Base baß Baß Bast"
+
+ int size3 = strlen(strlit3) - 1;
+ i1 = coll_de.compare(strlit3, strlit3 + size3, strlit3, strlit3 + 7);
+ VERIFY ( i1 == 1 );
+ i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size3);
+ VERIFY ( i1 == -1 );
+ i1 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
+ VERIFY ( i1 == 0 );
+
+ i1 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
+ VERIFY ( i1 == -1 );
+
+ int size4 = strlen(strlit4) - 1;
+ i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
+ VERIFY ( i2 == 1 );
+ i2 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
+ VERIFY ( i2 == -1 );
+ i2 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
+ VERIFY ( i2 == 0 );
+
+ l1 = coll_de.hash(strlit3, strlit3 + size3);
+ l2 = coll_de.hash(strlit3, strlit3 + size3 - 1);
+ VERIFY ( l1 != l2 );
+ l1 = coll_de.hash(strlit3, strlit3 + size3);
+ l2 = coll_de.hash(strlit4, strlit4 + size4);
+ VERIFY ( l1 != l2 );
+
+ string str3 = coll_de.transform(strlit3, strlit3 + size3);
+ string str4 = coll_de.transform(strlit4, strlit4 + size4);
+ i1 = str3.compare(str4);
+ i2 = coll_de.compare(strlit3, strlit3 + size3, strlit4, strlit4 + size4);
+ VERIFY ( i2 == -1 );
+ VERIFY ( i1 * i2 > 0 );
+
+
+ // Check byname locale
+ int i3;
+ int i4;
+ long l3;
+ long l4;
+ size4 = strlen(strlit3) - 1;
+ i3 = coll_de.compare(strlit3, strlit3 + size4, strlit3, strlit3 + 7);
+ VERIFY ( i3 == 1 );
+ i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + size4);
+ VERIFY ( i3 == -1 );
+ i3 = coll_de.compare(strlit3, strlit3 + 7, strlit3, strlit3 + 7);
+ VERIFY ( i3 == 0 );
+
+ i3 = coll_de.compare(strlit3, strlit3 + 6, strlit3 + 8, strlit3 + 14);
+ VERIFY ( i3 == -1 );
+
+ size4 = strlen(strlit4) - 1;
+ i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + 13);
+ VERIFY ( i4 == 1 );
+ i4 = coll_de.compare(strlit4, strlit4 + 13, strlit4, strlit4 + size4);
+ VERIFY ( i4 == -1 );
+ i4 = coll_de.compare(strlit4, strlit4 + size4, strlit4, strlit4 + size4);
+ VERIFY ( i4 == 0 );
+
+ l3 = coll_de.hash(strlit3, strlit3 + size4);
+ l4 = coll_de.hash(strlit3, strlit3 + size4 - 1);
+ VERIFY ( l3 != l4 );
+ l3 = coll_de.hash(strlit3, strlit3 + size4);
+ l4 = coll_de.hash(strlit4, strlit4 + size4);
+ VERIFY ( l3 != l4 );
+
+ string str5 = coll_de.transform(strlit3, strlit3 + size3);
+ string str6 = coll_de.transform(strlit4, strlit4 + size4);
+ i3 = str5.compare(str6);
+ i4 = coll_de.compare(strlit3, strlit3 + size4, strlit4, strlit4 + size4);
+ VERIFY ( i4 == -1 );
+ VERIFY ( i3 * i4 > 0 );
+
+ // Verify byname == de
+ VERIFY ( str5 == str3 );
+ VERIFY ( str6 == str4 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
// { dg-do compile }
-// 1999-08-24 bkoz
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 1999, 2000, 2003 Free Software Foundation
+// Copyright (C) 2003 Free Software Foundation
//
// 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 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
-// 22.2.1 The ctype category
-
-// 1: Test that the locale headers are picking up the correct declaration
-// of the internal type `ctype_base::mask'.
-int mask ();
+// 22.2.1.1 - Template class ctype
#include <locale>
-// 2: Should be able to instantiate this for other types besides char, wchar_t
-typedef std::ctype<char> cctype;
-
-class gnu_ctype: public std::ctype<unsigned char>
-{
-private:
- const cctype& _M_cctype;
-
-public:
- explicit
- gnu_ctype(size_t __refs = 0)
- : std::ctype<unsigned char>(__refs),
- _M_cctype(std::use_facet<cctype>(std::locale::classic()))
- { }
-
- ~gnu_ctype();
-
-protected:
- virtual bool
- do_is(mask __m, char_type __c) const
- { return _M_cctype.is(__m, __c); }
-
- virtual const char_type*
- do_is(const char_type* __lo, const char_type* __hi, mask* __vec) const
- {
- const char* __c = _M_cctype.is(reinterpret_cast<const char*>(__lo),
- reinterpret_cast<const char*>(__hi), __vec);
- return reinterpret_cast<const char_type*>(__c);
- }
-
- virtual const char_type*
- do_scan_is(mask __m, const char_type* __lo, const char_type* __hi) const
- {
- const char* __c = _M_cctype.scan_is(__m,
- reinterpret_cast<const char*>(__lo),
- reinterpret_cast<const char*>(__hi));
- return reinterpret_cast<const char_type*>(__c);
- }
-
- virtual const char_type*
- do_scan_not(mask __m, const char_type* __lo, const char_type* __hi) const
- {
- const char* __c = _M_cctype.scan_is(__m,
- reinterpret_cast<const char*>(__lo),
- reinterpret_cast<const char*>(__hi));
- return reinterpret_cast<const char_type*>(__c);
- }
-
- virtual char_type
- do_toupper(char_type __c) const
- { return _M_cctype.toupper(__c); }
-
- virtual const char_type*
- do_toupper(char_type* __lo, const char_type* __hi) const
- {
- const char* __c = _M_cctype.toupper(reinterpret_cast<char*>(__lo),
- reinterpret_cast<const char*>(__hi));
- return reinterpret_cast<const char_type*>(__c);
- }
-
- virtual char_type
- do_tolower(char_type __c) const
- { return _M_cctype.tolower(__c); }
-
- virtual const char_type*
- do_tolower(char_type* __lo, const char_type* __hi) const
- {
- const char* __c = _M_cctype.toupper(reinterpret_cast<char*>(__lo),
- reinterpret_cast<const char*>(__hi));
- return reinterpret_cast<const char_type*>(__c);
- }
-
- virtual char_type
- do_widen(char __c) const
- { return _M_cctype.widen(__c); }
-
- virtual const char*
- do_widen(const char* __lo, const char* __hi, char_type* __dest) const
- {
- const char* __c = _M_cctype.widen(reinterpret_cast<const char*>(__lo),
- reinterpret_cast<const char*>(__hi),
- reinterpret_cast<char*>(__dest));
- return __c;
- }
-
- virtual char
- do_narrow(char_type __c, char __dfault) const
- { return _M_cctype.narrow(__c, __dfault); }
-
- virtual const char_type*
- do_narrow(const char_type* __lo, const char_type* __hi, char __dfault,
- char* __dest) const
- {
- const char* __c = _M_cctype.narrow(reinterpret_cast<const char*>(__lo),
- reinterpret_cast<const char*>(__hi),
- __dfault,
- reinterpret_cast<char*>(__dest));
- return reinterpret_cast<const char_type*>(__c);
- }
-
-};
-
-gnu_ctype::~gnu_ctype() { }
-
-gnu_ctype facet01;
-
-// 3: Sanity check ctype_base::mask bitmask requirements
-void
-test01()
+void test01()
{
- using namespace std;
-
- ctype_base::mask m01;
- ctype_base::mask m02;
- ctype_base::mask res;
-
- m01 = ctype_base::space;
- m02 = ctype_base::xdigit;
-
- res = m01 & m02;
- res = m01 | m02;
- res = m01 ^ m02;
- res = ~m01;
- m01 &= m02;
- m01 |= m02;
- m01 ^= m02;
+ // Check for required base class.
+ typedef std::ctype<char> test_type;
+ typedef std::locale::facet base_type1;
+ typedef std::ctype_base base_type2;
+ const test_type& obj = std::use_facet<test_type>(std::locale::classic());
+ const base_type1* base1 __attribute__((unused)) = &obj;
+ const base_type2* base2 __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
}
-int main()
-{
+int main()
+{
test01();
return 0;
}
--- /dev/null
+// { dg-do compile }
+// 1999-08-24 bkoz
+
+// Copyright (C) 1999, 2000, 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.1 The ctype category
+
+// 1: Test that the locale headers are picking up the correct declaration
+// of the internal type `ctype_base::mask'.
+int mask ();
+
+#include <locale>
+
+// 2: Sanity check ctype_base::mask bitmask requirements
+void
+test01()
+{
+ using namespace std;
+
+ ctype_base::mask m01;
+ ctype_base::mask m02;
+ ctype_base::mask res;
+
+ m01 = ctype_base::space;
+ m02 = ctype_base::xdigit;
+
+ res = m01 & m02;
+ res = m01 | m02;
+ res = m01 ^ m02;
+ res = ~m01;
+ m01 &= m02;
+ m01 |= m02;
+ m01 ^= m02;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// { dg-do compile }
+// 2001-08-15 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.1.1 - Template class ctype
+
+#include <locale>
+
+void test01()
+{
+ // Check for required base class.
+ typedef std::ctype_byname<char> test_type;
+ typedef std::ctype<char> base_type;
+ const test_type& obj = std::use_facet<test_type>(std::locale::classic());
+ const base_type* base __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
-// 2001-07-17 Benjamin Kosnik <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-07-17 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2003 Free Software Foundation
//
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
-// 22.2.7.2 Template class messages_byname
+// 22.2.7 The message retrieval category
#include <locale>
-#include <testsuite_hooks.h>
void test01()
{
- using namespace std;
- typedef std::messages<char>::catalog catalog;
- typedef std::messages<char>::string_type string_type;
-
- bool test __attribute__((unused)) = true;
- string str;
- // This is defined through CXXFLAGS in scripts/testsuite_flags[.in].
- const char* dir = LOCALEDIR;
- locale loc_c = locale::classic();
-
- locale loc_de = __gnu_test::try_named_locale("de_DE");
- str = loc_de.name();
-
- locale loc_byname(locale::classic(), new messages_byname<char>("de_DE"));
- str = loc_byname.name();
-
- VERIFY( loc_de != loc_byname );
-
- // cache the messages facets
- const messages<char>& mssg_byname = use_facet<messages<char> >(loc_byname);
- const messages<char>& mssg_de = use_facet<messages<char> >(loc_de);
-
- // catalog open(const string&, const locale&) const;
- // string_type get(catalog, int, int, const string_type& ) const;
- // void close(catalog) const;
-
- // Check German (de_DE) locale.
- catalog cat_de = mssg_de.open("libstdc++", loc_c, dir);
- string s01 = mssg_de.get(cat_de, 0, 0, "please");
- string s02 = mssg_de.get(cat_de, 0, 0, "thank you");
- VERIFY ( s01 == "bitte" );
- VERIFY ( s02 == "danke" );
- mssg_de.close(cat_de);
-
- // Check byname locale.
- catalog cat_byname = mssg_byname.open("libstdc++", loc_c, dir);
- string s03 = mssg_byname.get(cat_de, 0, 0, "please");
- string s04 = mssg_byname.get(cat_de, 0, 0, "thank you");
- VERIFY ( s03 == "bitte" );
- VERIFY ( s04 == "danke" );
- mssg_byname.close(cat_byname);
-
- VERIFY ( s01 == s03 );
- VERIFY ( s02 == s04 );
+ // Check for required base class.
+ typedef std::messages_byname<char> test_type;
+ typedef std::messages<char> base_type;
+ const test_type& obj = std::use_facet<test_type>(std::locale::classic());
+ const base_type* base __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::string_type string_type;
}
int main()
--- /dev/null
+// 2001-07-17 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.7.2 Template class messages_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef std::messages<char>::catalog catalog;
+ typedef std::messages<char>::string_type string_type;
+
+ bool test __attribute__((unused)) = true;
+ string str;
+ // This is defined through CXXFLAGS in scripts/testsuite_flags[.in].
+ const char* dir = LOCALEDIR;
+ locale loc_c = locale::classic();
+
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ str = loc_de.name();
+
+ locale loc_byname(locale::classic(), new messages_byname<char>("de_DE"));
+ str = loc_byname.name();
+
+ VERIFY( loc_de != loc_byname );
+
+ // cache the messages facets
+ const messages<char>& mssg_byname = use_facet<messages<char> >(loc_byname);
+ const messages<char>& mssg_de = use_facet<messages<char> >(loc_de);
+
+ // catalog open(const string&, const locale&) const;
+ // string_type get(catalog, int, int, const string_type& ) const;
+ // void close(catalog) const;
+
+ // Check German (de_DE) locale.
+ catalog cat_de = mssg_de.open("libstdc++", loc_c, dir);
+ string s01 = mssg_de.get(cat_de, 0, 0, "please");
+ string s02 = mssg_de.get(cat_de, 0, 0, "thank you");
+ VERIFY ( s01 == "bitte" );
+ VERIFY ( s02 == "danke" );
+ mssg_de.close(cat_de);
+
+ // Check byname locale.
+ catalog cat_byname = mssg_byname.open("libstdc++", loc_c, dir);
+ string s03 = mssg_byname.get(cat_de, 0, 0, "please");
+ string s04 = mssg_byname.get(cat_de, 0, 0, "thank you");
+ VERIFY ( s03 == "bitte" );
+ VERIFY ( s04 == "danke" );
+ mssg_byname.close(cat_byname);
+
+ VERIFY ( s01 == s03 );
+ VERIFY ( s02 == s04 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
-// 2001-08-24 Benjamin Kosnik <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-08-23 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2001, 2003 Free Software Foundation
//
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
-// 22.2.6.4 Template class moneypunct_byname
+// 22.2.6.3 Template class moneypunct
#include <locale>
#include <testsuite_hooks.h>
void test01()
{
- using namespace std;
- typedef money_base::part part;
- typedef money_base::pattern pattern;
-
- bool test __attribute__((unused)) = true;
- string str;
-
- locale loc_de = __gnu_test::try_named_locale("de_DE");
- str = loc_de.name();
-
- locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE"));
- str = loc_byname.name();
-
- locale loc_c = locale::classic();
-
- VERIFY( loc_de != loc_byname );
-
- // cache the moneypunct facets
- const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c);
- const moneypunct<char>& monp_byname =
- use_facet<moneypunct<char> >(loc_byname);
- const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de);
-
- // sanity check that the data match
- char dp1 = monp_de.decimal_point();
- char th1 = monp_de.thousands_sep();
- string g1 = monp_de.grouping();
- string cs1 = monp_de.curr_symbol();
- string ps1 = monp_de.positive_sign();
- string ns1 = monp_de.negative_sign();
- int fd1 = monp_de.frac_digits();
- pattern pos1 = monp_de.pos_format();
- pattern neg1 = monp_de.neg_format();
-
- char dp2 = monp_byname.decimal_point();
- char th2 = monp_byname.thousands_sep();
- string g2 = monp_byname.grouping();
- string cs2 = monp_byname.curr_symbol();
- string ps2 = monp_byname.positive_sign();
- string ns2 = monp_byname.negative_sign();
- int fd2 = monp_byname.frac_digits();
- pattern pos2 = monp_byname.pos_format();
- pattern neg2 = monp_byname.neg_format();
-
- VERIFY( dp1 == dp2 );
- VERIFY( th1 == th2 );
- VERIFY( g1 == g2 );
- VERIFY( cs1 == cs2 );
- VERIFY( ps1 == ps2 );
- VERIFY( ns1 == ns2 );
- VERIFY( fd1 == fd2 );
- VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
- VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
- VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
- VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
-
- VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
- VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
- 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]));
-
- // ...and don't match "C"
- char dp3 = monp_c.decimal_point();
- VERIFY( dp1 != dp3 );
+ // Check for required base class.
+ typedef std::moneypunct_byname<char, true> test_type;
+ typedef std::moneypunct<char, true> base_type;
+ const test_type& obj = std::use_facet<test_type>(std::locale());
+ const base_type* base __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::string_type string_type;
}
int main()
--- /dev/null
+// 2001-08-24 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.6.4 Template class moneypunct_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+ typedef money_base::part part;
+ typedef money_base::pattern pattern;
+
+ bool test __attribute__((unused)) = true;
+ string str;
+
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ str = loc_de.name();
+
+ locale loc_byname(locale::classic(), new moneypunct_byname<char>("de_DE"));
+ str = loc_byname.name();
+
+ locale loc_c = locale::classic();
+
+ VERIFY( loc_de != loc_byname );
+
+ // cache the moneypunct facets
+ const moneypunct<char>& monp_c = use_facet<moneypunct<char> >(loc_c);
+ const moneypunct<char>& monp_byname =
+ use_facet<moneypunct<char> >(loc_byname);
+ const moneypunct<char>& monp_de = use_facet<moneypunct<char> >(loc_de);
+
+ // sanity check that the data match
+ char dp1 = monp_de.decimal_point();
+ char th1 = monp_de.thousands_sep();
+ string g1 = monp_de.grouping();
+ string cs1 = monp_de.curr_symbol();
+ string ps1 = monp_de.positive_sign();
+ string ns1 = monp_de.negative_sign();
+ int fd1 = monp_de.frac_digits();
+ pattern pos1 = monp_de.pos_format();
+ pattern neg1 = monp_de.neg_format();
+
+ char dp2 = monp_byname.decimal_point();
+ char th2 = monp_byname.thousands_sep();
+ string g2 = monp_byname.grouping();
+ string cs2 = monp_byname.curr_symbol();
+ string ps2 = monp_byname.positive_sign();
+ string ns2 = monp_byname.negative_sign();
+ int fd2 = monp_byname.frac_digits();
+ pattern pos2 = monp_byname.pos_format();
+ pattern neg2 = monp_byname.neg_format();
+
+ VERIFY( dp1 == dp2 );
+ VERIFY( th1 == th2 );
+ VERIFY( g1 == g2 );
+ VERIFY( cs1 == cs2 );
+ VERIFY( ps1 == ps2 );
+ VERIFY( ns1 == ns2 );
+ VERIFY( fd1 == fd2 );
+ VERIFY(static_cast<part>(pos1.field[0]) == static_cast<part>(pos2.field[0]));
+ VERIFY(static_cast<part>(pos1.field[1]) == static_cast<part>(pos2.field[1]));
+ VERIFY(static_cast<part>(pos1.field[2]) == static_cast<part>(pos2.field[2]));
+ VERIFY(static_cast<part>(pos1.field[3]) == static_cast<part>(pos2.field[3]));
+
+ VERIFY(static_cast<part>(neg1.field[0]) == static_cast<part>(neg2.field[0]));
+ VERIFY(static_cast<part>(neg1.field[1]) == static_cast<part>(neg2.field[1]));
+ 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]));
+
+ // ...and don't match "C"
+ char dp3 = monp_c.decimal_point();
+ VERIFY( dp1 != dp3 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
typedef std::locale::facet base_type;
const test_type& obj = std::use_facet<test_type>(std::locale());
const base_type* base __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::string_type string_type;
}
int main()
-// 2001-01-24 Benjamin Kosnik <bkoz@redhat.com>
+// { dg-do compile }
+// 2001-01-23 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001, 2003 Free Software Foundation
+// Copyright (C) 2001, 2003 Free Software Foundation
//
// 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 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
-// 22.2.3.2 Template class numpunct_byname
+// 22.2.3 The numeric punctuation facet
#include <locale>
-#include <testsuite_hooks.h>
void test01()
{
- using namespace std;
-
- bool test __attribute__((unused)) = true;
- string str;
-
- locale loc_de = __gnu_test::try_named_locale("de_DE");
- str = loc_de.name();
-
- locale loc_byname(locale::classic(), new numpunct_byname<char>("de_DE"));
- str = loc_byname.name();
-
- locale loc_c = locale::classic();
-
- VERIFY( loc_de != loc_byname );
-
- // cache the numpunct facets
- const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c);
- const numpunct<char>& nump_byname = use_facet<numpunct<char> >(loc_byname);
- const numpunct<char>& nump_de = use_facet<numpunct<char> >(loc_de);
-
- // sanity check that the data match
- char dp1 = nump_byname.decimal_point();
- char th1 = nump_byname.thousands_sep();
- string g1 = nump_byname.grouping();
- string t1 = nump_byname.truename();
- string f1 = nump_byname.falsename();
-
- char dp2 = nump_de.decimal_point();
- char th2 = nump_de.thousands_sep();
- string g2 = nump_de.grouping();
- string t2 = nump_de.truename();
- string f2 = nump_de.falsename();
-
- VERIFY( dp1 == dp2 );
- VERIFY( th1 == th2 );
- VERIFY( g1 == g2 );
- VERIFY( t1 == t2 );
- VERIFY( f1 == f2 );
-
- // ...and don't match "C"
- char dp3 = nump_c.decimal_point();
- VERIFY( dp1 != dp3 );
+ // Check for required base class.
+ typedef std::numpunct_byname<char> test_type;
+ typedef std::numpunct<char> base_type;
+ const test_type& obj = std::use_facet<test_type>(std::locale());
+ const base_type* base __attribute__((unused)) = &obj;
+
+ // Check for required typedefs
+ typedef test_type::char_type char_type;
+ typedef test_type::string_type string_type;
}
int main()
--- /dev/null
+// 2001-01-24 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2003 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 22.2.3.2 Template class numpunct_byname
+
+#include <locale>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ using namespace std;
+
+ bool test __attribute__((unused)) = true;
+ string str;
+
+ locale loc_de = __gnu_test::try_named_locale("de_DE");
+ str = loc_de.name();
+
+ locale loc_byname(locale::classic(), new numpunct_byname<char>("de_DE"));
+ str = loc_byname.name();
+
+ locale loc_c = locale::classic();
+
+ VERIFY( loc_de != loc_byname );
+
+ // cache the numpunct facets
+ const numpunct<char>& nump_c = use_facet<numpunct<char> >(loc_c);
+ const numpunct<char>& nump_byname = use_facet<numpunct<char> >(loc_byname);
+ const numpunct<char>& nump_de = use_facet<numpunct<char> >(loc_de);
+
+ // sanity check that the data match
+ char dp1 = nump_byname.decimal_point();
+ char th1 = nump_byname.thousands_sep();
+ string g1 = nump_byname.grouping();
+ string t1 = nump_byname.truename();
+ string f1 = nump_byname.falsename();
+
+ char dp2 = nump_de.decimal_point();
+ char th2 = nump_de.thousands_sep();
+ string g2 = nump_de.grouping();
+ string t2 = nump_de.truename();
+ string f2 = nump_de.falsename();
+
+ VERIFY( dp1 == dp2 );
+ VERIFY( th1 == th2 );
+ VERIFY( g1 == g2 );
+ VERIFY( t1 == t2 );
+ VERIFY( f1 == f2 );
+
+ // ...and don't match "C"
+ char dp3 = nump_c.decimal_point();
+ VERIFY( dp1 != dp3 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}