Commit 821503db by Benjamin Kosnik Committed by Benjamin Kosnik

pod_char_traits.h (__gnu_cxx::character): Add char_type.


2005-04-14  Benjamin Kosnik  <bkoz@redhat.com>

	*  include/ext/pod_char_traits.h (__gnu_cxx::character): Add char_type.
	(character::to): New.
	(character::from): New.
	(operator==): Add state parameter.
	(operator<): Same.
	(char_traits::copy): Use std::copy.
	(char_traits::assign): Use std::fill_n.
	(char_traits::to_char_type): Use character::from.
	(char_traits::to_int_type): Use character::to.
	*  testsuite/testsuite_character.h (__gnu_test::character): Remove.
	(__gnu_test::conversion_state): Remove.
	(__gnu_test::pod_char): Remove.
	(pod_char): New typedef.
	(pod_uchar): New typedef.
	(pod_ushort): New typedef.
	*  testsuite/testsuite_character.cc: Fixups.
	*  testsuite/21_strings/basic_string/inserters_extractors/pod/
	10081-in.cc: Same.
	*  testsuite/21_strings/basic_string/inserters_extractors/pod/
	10081-out.cc: Same.
	*  testsuite/22_locale/numpunct/members/pod/1.cc: Same.
	*  testsuite/22_locale/numpunct/members/pod/2.cc: Same.
	*  testsuite/27_io/basic_filebuf/close/12790-1.cc: Same.
	*  testsuite/27_io/basic_filebuf/open/12790-1.cc: Same.
	*  testsuite/27_io/basic_filebuf/seekoff/12790-1.cc: Same.
	*  testsuite/27_io/basic_filebuf/seekoff/12790-2.cc: Same.
	*  testsuite/27_io/basic_filebuf/seekoff/12790-3.cc: Same.
	*  testsuite/27_io/basic_filebuf/seekoff/12790-4.cc: Same.
	*  testsuite/27_io/basic_filebuf/seekpos/12790-1.cc: Same.
	*  testsuite/27_io/basic_filebuf/seekpos/12790-2.cc: Same.
	*  testsuite/27_io/basic_filebuf/seekpos/12790-3.cc: Same.
	*  testsuite/27_io/basic_ios/imbue/14072.cc: Same.
	*  testsuite/27_io/basic_istream/extractors_arithmetic/pod/
	3983-1.cc: Same.
	*  testsuite/27_io/basic_istream/extractors_character/pod/
	3983-2.cc: Same.
	*  testsuite/27_io/basic_istream/extractors_other/pod/3983-3.cc: Same.
	*  testsuite/27_io/basic_istream/sentry/pod/1.cc: Same.
	*  testsuite/27_io/basic_ostream/sentry/pod/1.cc: Same.

From-SVN: r98165
parent a68bdb0b
2005-04-14 Benjamin Kosnik <bkoz@redhat.com>
* include/ext/pod_char_traits.h (__gnu_cxx::character): Add char_type.
(character::to): New.
(character::from): New.
(operator==): Add state parameter.
(operator<): Same.
(char_traits::copy): Use std::copy.
(char_traits::assign): Use std::fill_n.
(char_traits::to_char_type): Use character::from.
(char_traits::to_int_type): Use character::to.
* testsuite/testsuite_character.h (__gnu_test::character): Remove.
(__gnu_test::conversion_state): Remove.
(__gnu_test::pod_char): Remove.
(pod_char): New typedef.
(pod_uchar): New typedef.
(pod_ushort): New typedef.
* testsuite/testsuite_character.cc: Fixups.
* testsuite/21_strings/basic_string/inserters_extractors/pod/
10081-in.cc: Same.
* testsuite/21_strings/basic_string/inserters_extractors/pod/
10081-out.cc: Same.
* testsuite/22_locale/numpunct/members/pod/1.cc: Same.
* testsuite/22_locale/numpunct/members/pod/2.cc: Same.
* testsuite/27_io/basic_filebuf/close/12790-1.cc: Same.
* testsuite/27_io/basic_filebuf/open/12790-1.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/12790-1.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/12790-2.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/12790-3.cc: Same.
* testsuite/27_io/basic_filebuf/seekoff/12790-4.cc: Same.
* testsuite/27_io/basic_filebuf/seekpos/12790-1.cc: Same.
* testsuite/27_io/basic_filebuf/seekpos/12790-2.cc: Same.
* testsuite/27_io/basic_filebuf/seekpos/12790-3.cc: Same.
* testsuite/27_io/basic_ios/imbue/14072.cc: Same.
* testsuite/27_io/basic_istream/extractors_arithmetic/pod/
3983-1.cc: Same.
* testsuite/27_io/basic_istream/extractors_character/pod/
3983-2.cc: Same.
* testsuite/27_io/basic_istream/extractors_other/pod/3983-3.cc: Same.
* testsuite/27_io/basic_istream/sentry/pod/1.cc: Same.
* testsuite/27_io/basic_ostream/sentry/pod/1.cc: Same.
2005-04-12 Mike Stump <mrs@apple.com> 2005-04-12 Mike Stump <mrs@apple.com>
* configure: Regenerate. * configure: Regenerate.
......
// POD character, std::char_traits specialization -*- C++ -*- // POD character, std::char_traits specialization -*- C++ -*-
// Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. // Copyright (C) 2002, 2003, 2004, 2005 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
...@@ -41,24 +41,47 @@ ...@@ -41,24 +41,47 @@
namespace __gnu_cxx namespace __gnu_cxx
{ {
// POD character abstraction.
// NB: The char_type parameter is a subset of int_type, as to allow
// int_type to properly hold the full range of char_type values as
// well as EOF.
/// @brief A POD class that serves as a character abstraction class. /// @brief A POD class that serves as a character abstraction class.
template<typename V, typename I, typename S = mbstate_t> template<typename V, typename I, typename S = mbstate_t>
struct character struct character
{ {
typedef V value_type; typedef V value_type;
typedef I int_type; typedef I int_type;
typedef S state_type; typedef S state_type;
typedef character<V, I, S> char_type;
value_type value; value_type value;
template<typename V2>
static char_type
from(const V2& v)
{
char_type ret = { static_cast<value_type>(v) };
return ret;
}
template<typename V2>
static V2
to(const char_type& c)
{
V2 ret = { static_cast<V2>(c.value) };
return ret;
}
}; };
template<typename V, typename I> template<typename V, typename I, typename S>
inline bool inline bool
operator==(const character<V, I>& lhs, const character<V, I>& rhs) operator==(const character<V, I, S>& lhs, const character<V, I, S>& rhs)
{ return lhs.value == rhs.value; } { return lhs.value == rhs.value; }
template<typename V, typename I> template<typename V, typename I, typename S>
inline bool inline bool
operator<(const character<V, I>& lhs, const character<V, I>& rhs) operator<(const character<V, I, S>& lhs, const character<V, I, S>& rhs)
{ return lhs.value < rhs.value; } { return lhs.value < rhs.value; }
} // namespace __gnu_cxx } // namespace __gnu_cxx
...@@ -69,13 +92,6 @@ namespace std ...@@ -69,13 +92,6 @@ namespace std
struct char_traits<__gnu_cxx::character<V, I, S> > struct char_traits<__gnu_cxx::character<V, I, S> >
{ {
typedef __gnu_cxx::character<V, I, S> char_type; typedef __gnu_cxx::character<V, I, S> char_type;
// NB: This type should be bigger than char_type, so as to
// properly hold EOF values in addition to the full range of
// char_type values.
// Also, assumes
// int_type(value_type) is valid.
// int_type(-1) is possible.
typedef typename char_type::int_type int_type; typedef typename char_type::int_type int_type;
typedef typename char_type::state_type state_type; typedef typename char_type::state_type state_type;
typedef fpos<state_type> pos_type; typedef fpos<state_type> pos_type;
...@@ -122,41 +138,47 @@ namespace std ...@@ -122,41 +138,47 @@ namespace std
static char_type* static char_type*
move(char_type* __s1, const char_type* __s2, size_t __n) move(char_type* __s1, const char_type* __s2, size_t __n)
{ return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); } {
return static_cast<char_type*>(std::memmove(__s1, __s2,
__n * sizeof(char_type)));
}
static char_type* static char_type*
copy(char_type* __s1, const char_type* __s2, size_t __n) copy(char_type* __s1, const char_type* __s2, size_t __n)
{ return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); } {
std::copy(__s2, __s2 + __n, __s1);
return __s1;
}
static char_type* static char_type*
assign(char_type* __s, size_t __n, char_type __a) assign(char_type* __s, size_t __n, char_type __a)
{ {
for (char_type* __p = __s; __p < __s + __n; ++__p) std::fill_n(__s, __n, __a);
assign(*__p, __a);
return __s; return __s;
} }
static char_type static char_type
to_char_type(const int_type& __c) to_char_type(const int_type& __i)
{ { return char_type::template from(__i); }
char_type __r = { __c };
return __r;
}
static int_type static int_type
to_int_type(const char_type& __c) to_int_type(const char_type& __c)
{ return int_type(__c.value); } { return char_type::template to<int_type>(__c); }
static bool static bool
eq_int_type(const int_type& __c1, const int_type& __c2) eq_int_type(const int_type& __c1, const int_type& __c2)
{ return __c1 == __c2; } { return __c1 == __c2; }
static int_type static int_type
eof() { return static_cast<int_type>(-1); } eof()
{
int_type __r = { -1 };
return __r;
}
static int_type static int_type
not_eof(const int_type& __c) not_eof(const int_type& __c)
{ return eq_int_type(__c, eof()) ? int_type(0) : __c; } { return eq_int_type(__c, eof()) ? int_type() : __c; }
}; };
} }
......
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
typedef basic_string<pod_type> string_type; typedef basic_string<pod_ushort> string_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_istream<pod_type> istream_type; typedef basic_istream<pod_ushort> istream_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -61,7 +61,7 @@ void test01() ...@@ -61,7 +61,7 @@ void test01()
VERIFY( false ); VERIFY( false );
} }
const std::locale loc(std::locale::classic(), new std::ctype<pod_type>); const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
stream.imbue(loc); stream.imbue(loc);
try try
{ {
...@@ -76,12 +76,12 @@ void test01() ...@@ -76,12 +76,12 @@ void test01()
#if !__GXX_WEAK__ #if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support. // Explicitly instantiate for systems with no COMDAT or weak support.
template template
std::basic_string<__gnu_test::pod_type>::size_type std::basic_string<__gnu_test::pod_ushort>::size_type
std::basic_string<__gnu_test::pod_type>::_Rep::_S_max_size; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
template template
__gnu_test::pod_type __gnu_test::pod_ushort
std::basic_string<__gnu_test::pod_type>::_Rep::_S_terminal; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
#endif #endif
int main() int main()
......
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
typedef basic_string<pod_type> string_type; typedef basic_string<pod_ushort> string_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_ostream<pod_type> ostream_type; typedef basic_ostream<pod_ushort> ostream_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -61,7 +61,7 @@ void test01() ...@@ -61,7 +61,7 @@ void test01()
VERIFY( false ); VERIFY( false );
} }
const std::locale loc(std::locale::classic(), new std::ctype<pod_type>); const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
stream.imbue(loc); stream.imbue(loc);
try try
{ {
...@@ -76,12 +76,12 @@ void test01() ...@@ -76,12 +76,12 @@ void test01()
#if !__GXX_WEAK__ #if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support. // Explicitly instantiate for systems with no COMDAT or weak support.
template template
std::basic_string<__gnu_test::pod_type>::size_type std::basic_string<__gnu_test::pod_ushort>::size_type
std::basic_string<__gnu_test::pod_type>::_Rep::_S_max_size; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
template template
__gnu_test::pod_type __gnu_test::pod_ushort
std::basic_string<__gnu_test::pod_type>::_Rep::_S_terminal; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
#endif #endif
int main() int main()
......
...@@ -30,42 +30,42 @@ ...@@ -30,42 +30,42 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
using __gnu_test::value_type; typedef pod_ushort::value_type value_type;
typedef numpunct<pod_type>::string_type string_type; typedef numpunct<pod_ushort>::string_type string_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_ostream<pod_type> ostream_type; typedef basic_ostream<pod_ushort> ostream_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// Pre-cache sanity check. // Pre-cache sanity check.
const locale loc(locale::classic(), new numpunct<pod_type>); const locale loc(locale::classic(), new numpunct<pod_ushort>);
const numpunct<pod_type>& np = use_facet<numpunct<pod_type> >(loc); const numpunct<pod_ushort>& np = use_facet<numpunct<pod_ushort> >(loc);
pod_type dp = np.decimal_point(); pod_ushort dp = np.decimal_point();
pod_type ts = np.thousands_sep(); pod_ushort ts = np.thousands_sep();
string g = np.grouping(); string g = np.grouping();
string_type strue = np.truename(); string_type strue = np.truename();
string_type sfalse = np.falsename(); string_type sfalse = np.falsename();
pod_type basedp = { value_type('.') }; pod_ushort basedp = { value_type('.') };
pod_type basets = { value_type(',') }; pod_ushort basets = { value_type(',') };
string_type basetrue(4, pod_type()); string_type basetrue(4, pod_ushort());
basetrue[0].value = value_type('t'); basetrue[0].value = value_type('t');
basetrue[1].value = value_type('r'); basetrue[1].value = value_type('r');
basetrue[2].value = value_type('u'); basetrue[2].value = value_type('u');
basetrue[3].value = value_type('e'); basetrue[3].value = value_type('e');
string_type basefalse(5, pod_type()); string_type basefalse(5, pod_ushort());
basefalse[0].value = value_type('f'); basefalse[0].value = value_type('f');
basefalse[1].value = value_type('a'); basefalse[1].value = value_type('a');
basefalse[2].value = value_type('l'); basefalse[2].value = value_type('l');
basefalse[3].value = value_type('s'); basefalse[3].value = value_type('s');
basefalse[4].value = value_type('e'); basefalse[4].value = value_type('e');
VERIFY( char_traits<pod_type>::eq(dp, basedp) ); VERIFY( char_traits<pod_ushort>::eq(dp, basedp) );
VERIFY( char_traits<pod_type>::eq(ts, basets) ); VERIFY( char_traits<pod_ushort>::eq(ts, basets) );
VERIFY( g == "" ); VERIFY( g == "" );
VERIFY( strue == basetrue ); VERIFY( strue == basetrue );
VERIFY( sfalse == basefalse ); VERIFY( sfalse == basefalse );
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
typedef numpunct<pod_type>::string_type string_type; typedef numpunct<pod_ushort>::string_type string_type;
typedef basic_ostringstream<pod_type> ostream_type; typedef basic_ostringstream<pod_ushort> ostream_type;
bool test = true; bool test = true;
...@@ -58,7 +58,7 @@ void test01() ...@@ -58,7 +58,7 @@ void test01()
VERIFY( test ); VERIFY( test );
// 2: fail, no ctype // 2: fail, no ctype
const locale loc2(loc, new num_put<pod_type>); const locale loc2(loc, new num_put<pod_ushort>);
os.clear(); os.clear();
os.imbue(loc2); os.imbue(loc2);
try try
...@@ -74,7 +74,7 @@ void test01() ...@@ -74,7 +74,7 @@ void test01()
VERIFY( test ); VERIFY( test );
// 3: fail, no numpunct // 3: fail, no numpunct
const locale loc3(loc2, new ctype<pod_type>); const locale loc3(loc2, new ctype<pod_ushort>);
os.clear(); os.clear();
os.imbue(loc3); os.imbue(loc3);
try try
...@@ -90,7 +90,7 @@ void test01() ...@@ -90,7 +90,7 @@ void test01()
VERIFY( test ); VERIFY( test );
// 4: works. // 4: works.
const locale loc4(loc3, new numpunct<pod_type>); const locale loc4(loc3, new numpunct<pod_ushort>);
os.clear(); os.clear();
os.imbue(loc4); os.imbue(loc4);
try try
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_close_12790"; const char* name = "tmp_close_12790";
...@@ -37,23 +37,23 @@ void test01() ...@@ -37,23 +37,23 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubsetbuf(0, 0); fb.pubsetbuf(0, 0);
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::out | ios_base::trunc); fb.open(name, ios_base::out | ios_base::trunc);
fb.sputc(character::from_char('b')); fb.sputc(pod_uchar::from<char>('b'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
// Check that close() writes unshift sequence // Check that close() writes unshift sequence
fb.close(); fb.close();
fb.open(name, ios_base::in | ios_base::out | ios_base::ate); fb.open(name, ios_base::in | ios_base::out | ios_base::ate);
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.close(); fb.close();
...@@ -66,7 +66,7 @@ void test01() ...@@ -66,7 +66,7 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.close(); fb.close();
} }
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_open_12790"; const char* name = "tmp_open_12790";
...@@ -37,11 +37,11 @@ void test01() ...@@ -37,11 +37,11 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::out); fb.open(name, ios_base::out);
fb.sputc(character::from_char('b')); fb.sputc(pod_uchar::from<char>('b'));
fb.close(); fb.close();
// Check that reopened basic_filebuf begins in the initial state. // Check that reopened basic_filebuf begins in the initial state.
...@@ -49,7 +49,7 @@ void test01() ...@@ -49,7 +49,7 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('b')) ); pod_uchar::from<char>('b')) );
fb.close(); fb.close();
} }
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_seekoff_12790"; const char* name = "tmp_seekoff_12790";
...@@ -37,17 +37,17 @@ void test01() ...@@ -37,17 +37,17 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::out); fb.open(name, ios_base::out);
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.close(); fb.close();
fb.open(name, ios_base::in); fb.open(name, ios_base::in);
...@@ -62,13 +62,13 @@ void test01() ...@@ -62,13 +62,13 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.sbumpc(); fb.sbumpc();
fb.sbumpc(); fb.sbumpc();
c = fb.sbumpc(); c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
c = fb.sbumpc(); c = fb.sbumpc();
VERIFY( c == traits_type::eof() ); VERIFY( c == traits_type::eof() );
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_seekoff_12790"; const char* name = "tmp_seekoff_12790";
...@@ -37,17 +37,17 @@ void test01() ...@@ -37,17 +37,17 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::out); fb.open(name, ios_base::out);
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.close(); fb.close();
fb.open(name, ios_base::in); fb.open(name, ios_base::in);
...@@ -62,7 +62,7 @@ void test01() ...@@ -62,7 +62,7 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char(0xff)) ); pod_uchar::from<char>(0xff)) );
fb.sbumpc(); fb.sbumpc();
fb.sbumpc(); fb.sbumpc();
fb.sbumpc(); fb.sbumpc();
...@@ -71,7 +71,7 @@ void test01() ...@@ -71,7 +71,7 @@ void test01()
c = fb.sbumpc(); c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
c = fb.sbumpc(); c = fb.sbumpc();
VERIFY( c == traits_type::eof() ); VERIFY( c == traits_type::eof() );
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_seekoff_12790"; const char* name = "tmp_seekoff_12790";
...@@ -37,16 +37,16 @@ void test01() ...@@ -37,16 +37,16 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::out | ios_base::trunc); fb.open(name, ios_base::out | ios_base::trunc);
fb.sputc(character::from_char('b')); fb.sputc(pod_uchar::from<char>('b'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char(0xfc)); fb.sputc(pod_uchar::from<char>(0xfc));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.close(); fb.close();
fb.open(name, ios_base::in); fb.open(name, ios_base::in);
...@@ -60,7 +60,7 @@ void test01() ...@@ -60,7 +60,7 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.sbumpc(); fb.sbumpc();
fb.pubseekpos(pos); fb.pubseekpos(pos);
...@@ -68,7 +68,7 @@ void test01() ...@@ -68,7 +68,7 @@ void test01()
c = fb.sbumpc(); c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.close(); fb.close();
} }
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_seekoff_12790"; const char* name = "tmp_seekoff_12790";
...@@ -37,20 +37,20 @@ void test01() ...@@ -37,20 +37,20 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubsetbuf(0, 0); fb.pubsetbuf(0, 0);
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::in | ios_base::out | ios_base::trunc); fb.open(name, ios_base::in | ios_base::out | ios_base::trunc);
fb.sputc(character::from_char('b')); fb.sputc(pod_uchar::from<char>('b'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
// Check that seekoff sets the current state during output // Check that seekoff sets the current state during output
traits_type::pos_type pos = fb.pubseekoff(0, ios_base::cur); traits_type::pos_type pos = fb.pubseekoff(0, ios_base::cur);
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.pubseekoff(0, ios_base::beg); fb.pubseekoff(0, ios_base::beg);
fb.sbumpc(); fb.sbumpc();
...@@ -59,7 +59,7 @@ void test01() ...@@ -59,7 +59,7 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.close(); fb.close();
} }
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_seekpos_12790"; const char* name = "tmp_seekpos_12790";
...@@ -37,16 +37,16 @@ void test01() ...@@ -37,16 +37,16 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubsetbuf(0, 0); fb.pubsetbuf(0, 0);
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::in | ios_base::out | ios_base::trunc); fb.open(name, ios_base::in | ios_base::out | ios_base::trunc);
traits_type::pos_type pos = fb.pubseekoff(0, ios_base::cur); traits_type::pos_type pos = fb.pubseekoff(0, ios_base::cur);
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
// Check that seekpos restores the state correctly // Check that seekpos restores the state correctly
fb.pubseekpos(pos); fb.pubseekpos(pos);
...@@ -54,7 +54,7 @@ void test01() ...@@ -54,7 +54,7 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.close(); fb.close();
} }
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_seekpos_12790"; const char* name = "tmp_seekpos_12790";
...@@ -37,16 +37,16 @@ void test01() ...@@ -37,16 +37,16 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::out | ios_base::trunc); fb.open(name, ios_base::out | ios_base::trunc);
fb.sputc(character::from_char('b')); fb.sputc(pod_uchar::from<char>('b'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char(0xfc)); fb.sputc(pod_uchar::from<char>(0xfc));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.close(); fb.close();
fb.open(name, ios_base::in); fb.open(name, ios_base::in);
...@@ -62,14 +62,14 @@ void test01() ...@@ -62,14 +62,14 @@ void test01()
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.sbumpc(); fb.sbumpc();
fb.pubseekpos(pos2); fb.pubseekpos(pos2);
c = fb.sbumpc(); c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.close(); fb.close();
} }
......
// Copyright (C) 2003 Free Software Foundation, Inc. // Copyright (C) 2003, 2005 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
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::character; using __gnu_test::pod_uchar;
typedef basic_filebuf<character>::traits_type traits_type; typedef basic_filebuf<pod_uchar>::traits_type traits_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
const char* name = "tmp_seekpos_12790"; const char* name = "tmp_seekpos_12790";
...@@ -37,14 +37,14 @@ void test01() ...@@ -37,14 +37,14 @@ void test01()
new codecvt<traits_type::char_type, char, new codecvt<traits_type::char_type, char,
traits_type::state_type>); traits_type::state_type>);
basic_filebuf<character> fb; basic_filebuf<pod_uchar> fb;
fb.pubimbue(loc); fb.pubimbue(loc);
fb.open(name, ios_base::in | ios_base::out | ios_base::trunc); fb.open(name, ios_base::in | ios_base::out | ios_base::trunc);
fb.sputc(character::from_char('b')); fb.sputc(pod_uchar::from<char>('b'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.sputc(character::from_char('c')); fb.sputc(pod_uchar::from<char>('c'));
fb.sputc(character::from_char(0xff)); fb.sputc(pod_uchar::from<char>(0xff));
fb.pubseekoff(0, ios_base::beg); fb.pubseekoff(0, ios_base::beg);
fb.sbumpc(); fb.sbumpc();
...@@ -56,18 +56,18 @@ void test01() ...@@ -56,18 +56,18 @@ void test01()
// Check that seekoff sets the current state for output // Check that seekoff sets the current state for output
fb.pubseekpos(pos); fb.pubseekpos(pos);
fb.sputc(character::from_char('a')); fb.sputc(pod_uchar::from<char>('a'));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.sputc(character::from_char(0)); fb.sputc(pod_uchar::from<char>(0));
fb.pubseekpos(pos); fb.pubseekpos(pos);
traits_type::int_type c = fb.sbumpc(); traits_type::int_type c = fb.sbumpc();
VERIFY( c != traits_type::eof() ); VERIFY( c != traits_type::eof() );
VERIFY( traits_type::eq(traits_type::to_char_type(c), VERIFY( traits_type::eq(traits_type::to_char_type(c),
character::from_char('a')) ); pod_uchar::from<char>('a')) );
fb.close(); fb.close();
} }
......
...@@ -35,134 +35,6 @@ ...@@ -35,134 +35,6 @@
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#include <testsuite_character.h> #include <testsuite_character.h>
namespace std
{
template<>
class ctype<__gnu_test::character>
: public locale::facet, public ctype_base
{
public:
typedef __gnu_test::character char_type;
explicit ctype(size_t refs = 0)
: locale::facet(refs) { }
bool
is(mask m, char_type c) const
{ return this->do_is(m, c); }
const char_type*
is(const char_type* low, const char_type* high, mask* vec) const
{ return this->do_is(low, high, vec); }
const char_type*
scan_is(mask m, const char_type* low, const char_type* high) const
{ return this->do_scan_is(m, low, high); }
const char_type*
scan_not(mask m, const char_type* low, const char_type* high) const
{ return this->do_scan_not(m, low, high); }
char_type
toupper(char_type c) const
{ return this->do_toupper(c); }
const char_type*
toupper(char_type* low, const char_type* high) const
{ return this->do_toupper(low, high); }
char_type
tolower(char_type c) const
{ return this->do_tolower(c); }
const char_type*
tolower(char_type* low, const char_type* high) const
{ return this->do_tolower(low, high); }
char_type
widen(char c) const
{ return this->do_widen(c); }
const char*
widen(const char* low, const char* high, char_type* to) const
{ return this->do_widen(low, high, to); }
char
narrow(char_type c, char dfault) const
{ return this->do_narrow(c, dfault); }
const char_type*
narrow(const char_type* low, const char_type* high,
char dfault, char* to) const
{ return this->do_narrow(low, high, dfault, to); }
static locale::id id;
protected:
~ctype()
{ }
virtual bool
do_is(mask m, char_type c) const
{ return false; }
virtual const char_type*
do_is(const char_type* low, const char_type* high, mask* vec) const
{
fill_n(vec, high - low, mask());
return high;
}
virtual const char_type*
do_scan_is(mask m, const char_type* low, const char_type* high) const
{ return high; }
virtual const char_type*
do_scan_not(mask m, const char_type* low, const char_type* high) const
{ return low; }
virtual char_type
do_toupper(char_type c) const
{ return c; }
virtual const char_type*
do_toupper(char_type* low, const char_type* high) const
{ return high; }
virtual char_type
do_tolower(char_type c) const
{ return c; }
virtual const char_type*
do_tolower(char_type* low, const char_type* high) const
{ return high; }
virtual char_type
do_widen(char c) const
{ return __gnu_test::character::from_char(c); }
virtual const char*
do_widen(const char* low, const char* high, char_type* dest) const
{
transform(low, high, dest, &__gnu_test::character::from_char);
return high;
}
virtual char
do_narrow(char_type, char dfault) const
{ return dfault; }
virtual const char_type*
do_narrow(const char_type* low, const char_type* high,
char dfault, char* dest) const
{
fill_n(dest, high - low, dfault);
return high;
}
};
locale::id ctype<__gnu_test::character>::id;
} // namespace std
// libstdc++/14072 // libstdc++/14072
void test01() void test01()
{ {
...@@ -170,12 +42,12 @@ void test01() ...@@ -170,12 +42,12 @@ void test01()
using namespace std; using namespace std;
locale loc; locale loc;
loc = locale(loc, new ctype<__gnu_test::character>()); loc = locale(loc, new ctype<__gnu_test::pod_uchar>());
loc = locale(loc, new num_get<__gnu_test::character>()); loc = locale(loc, new num_get<__gnu_test::pod_uchar>());
loc = locale(loc, new num_put<__gnu_test::character>()); loc = locale(loc, new num_put<__gnu_test::pod_uchar>());
locale::global(loc); locale::global(loc);
basic_stringstream<__gnu_test::character> s; basic_stringstream<__gnu_test::pod_uchar> s;
s << "10\n"; s << "10\n";
s.seekg(0, ios_base::beg); s.seekg(0, ios_base::beg);
s.imbue(locale::classic()); s.imbue(locale::classic());
......
...@@ -39,10 +39,9 @@ ...@@ -39,10 +39,9 @@
void test03() void test03()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
using __gnu_test::value_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_istream<pod_ushort> istream_type;
typedef basic_istream<pod_type> istream_type;
stringbuf_type strbuf01; stringbuf_type strbuf01;
istream_type iss(&strbuf01); istream_type iss(&strbuf01);
...@@ -63,12 +62,12 @@ void test03() ...@@ -63,12 +62,12 @@ void test03()
#if !__GXX_WEAK__ #if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support. // Explicitly instantiate for systems with no COMDAT or weak support.
template template
std::basic_string<__gnu_test::pod_type>::size_type std::basic_string<__gnu_test::pod_ushort>::size_type
std::basic_string<__gnu_test::pod_type>::_Rep::_S_max_size; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
template template
__gnu_test::pod_type __gnu_test::pod_ushort
std::basic_string<__gnu_test::pod_type>::_Rep::_S_terminal; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
#endif #endif
int main() int main()
......
...@@ -39,10 +39,10 @@ ...@@ -39,10 +39,10 @@
void test03() void test03()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
using __gnu_test::value_type; typedef pod_ushort::value_type value_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_istream<pod_type> istream_type; typedef basic_istream<pod_ushort> istream_type;
stringbuf_type strbuf01; stringbuf_type strbuf01;
istream_type iss(&strbuf01); istream_type iss(&strbuf01);
...@@ -50,7 +50,7 @@ void test03() ...@@ -50,7 +50,7 @@ void test03()
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
// input streams // input streams
pod_type arr[6] = { value_type('a'), value_type('b'), pod_ushort arr[6] = { value_type('a'), value_type('b'),
value_type('c'), value_type('d'), value_type('e') }; value_type('c'), value_type('d'), value_type('e') };
try try
...@@ -66,12 +66,12 @@ void test03() ...@@ -66,12 +66,12 @@ void test03()
#if !__GXX_WEAK__ #if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support. // Explicitly instantiate for systems with no COMDAT or weak support.
template template
std::basic_string<__gnu_test::pod_type>::size_type std::basic_string<__gnu_test::pod_ushort>::size_type
std::basic_string<__gnu_test::pod_type>::_Rep::_S_max_size; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
template template
__gnu_test::pod_type __gnu_test::pod_ushort
std::basic_string<__gnu_test::pod_type>::_Rep::_S_terminal; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
#endif #endif
int main() int main()
......
...@@ -39,10 +39,9 @@ ...@@ -39,10 +39,9 @@
void test03() void test03()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
using __gnu_test::value_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_istream<pod_ushort> istream_type;
typedef basic_istream<pod_type> istream_type;
stringbuf_type strbuf01; stringbuf_type strbuf01;
istream_type iss(&strbuf01); istream_type iss(&strbuf01);
...@@ -62,12 +61,12 @@ void test03() ...@@ -62,12 +61,12 @@ void test03()
#if !__GXX_WEAK__ #if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support. // Explicitly instantiate for systems with no COMDAT or weak support.
template template
std::basic_string<__gnu_test::pod_type>::size_type std::basic_string<__gnu_test::pod_ushort>::size_type
std::basic_string<__gnu_test::pod_type>::_Rep::_S_max_size; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
template template
__gnu_test::pod_type __gnu_test::pod_ushort
std::basic_string<__gnu_test::pod_type>::_Rep::_S_terminal; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
#endif #endif
int main() int main()
......
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
typedef basic_string<pod_type> string_type; typedef basic_string<pod_ushort> string_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_istream<pod_type> istream_type; typedef basic_istream<pod_ushort> istream_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -80,7 +80,7 @@ void test01() ...@@ -80,7 +80,7 @@ void test01()
} }
// imbued. // imbued.
const std::locale loc(std::locale::classic(), new std::ctype<pod_type>); const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
istr01.imbue(loc); istr01.imbue(loc);
try try
{ {
...@@ -158,12 +158,12 @@ void test01() ...@@ -158,12 +158,12 @@ void test01()
#if !__GXX_WEAK__ #if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support. // Explicitly instantiate for systems with no COMDAT or weak support.
template template
std::basic_string<__gnu_test::pod_type>::size_type std::basic_string<__gnu_test::pod_ushort>::size_type
std::basic_string<__gnu_test::pod_type>::_Rep::_S_max_size; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
template template
__gnu_test::pod_type __gnu_test::pod_ushort
std::basic_string<__gnu_test::pod_type>::_Rep::_S_terminal; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
#endif #endif
int main() int main()
......
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
void test01() void test01()
{ {
using namespace std; using namespace std;
using __gnu_test::pod_type; using __gnu_test::pod_ushort;
typedef basic_string<pod_type> string_type; typedef basic_string<pod_ushort> string_type;
typedef basic_stringbuf<pod_type> stringbuf_type; typedef basic_stringbuf<pod_ushort> stringbuf_type;
typedef basic_ostream<pod_type> ostream_type; typedef basic_ostream<pod_ushort> ostream_type;
bool test __attribute__((unused)) = true; bool test __attribute__((unused)) = true;
...@@ -69,7 +69,7 @@ void test01() ...@@ -69,7 +69,7 @@ void test01()
} }
// imbued. // imbued.
const std::locale loc(std::locale::classic(), new std::ctype<pod_type>); const std::locale loc(std::locale::classic(), new std::ctype<pod_ushort>);
ostr01.imbue(loc); ostr01.imbue(loc);
try try
{ {
...@@ -114,12 +114,12 @@ void test01() ...@@ -114,12 +114,12 @@ void test01()
#if !__GXX_WEAK__ #if !__GXX_WEAK__
// Explicitly instantiate for systems with no COMDAT or weak support. // Explicitly instantiate for systems with no COMDAT or weak support.
template template
std::basic_string<__gnu_test::pod_type>::size_type std::basic_string<__gnu_test::pod_ushort>::size_type
std::basic_string<__gnu_test::pod_type>::_Rep::_S_max_size; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_max_size;
template template
__gnu_test::pod_type __gnu_test::pod_ushort
std::basic_string<__gnu_test::pod_type>::_Rep::_S_terminal; std::basic_string<__gnu_test::pod_ushort>::_Rep::_S_terminal;
#endif #endif
int main() int main()
......
...@@ -34,65 +34,67 @@ ...@@ -34,65 +34,67 @@
namespace std namespace std
{ {
locale::id locale::id
codecvt<__gnu_test::character, char, __gnu_test::conversion_state>::id; codecvt<__gnu_test::pod_uchar, char, __gnu_test::pod_state>::id;
locale::id
ctype<__gnu_test::pod_uchar>::id;
// Member specializations for the existing facet classes. // Member specializations for the existing facet classes.
// NB: This isn't especially portable. Perhaps a better way would be // NB: This isn't especially portable. Perhaps a better way would be
// to just specialize all of numpunct and ctype. // to just specialize all of numpunct and ctype.
using __gnu_test::int_type; using __gnu_test::pod_ushort;
using __gnu_test::value_type; typedef pod_ushort::value_type value_type;
using __gnu_test::pod_type;
template<> template<>
bool bool
ctype<pod_type>:: ctype<pod_ushort>::
do_is(mask, char_type) const { return true; } do_is(mask, char_type) const { return true; }
template<> template<>
const pod_type* const pod_ushort*
ctype<pod_type>:: ctype<pod_ushort>::
do_is(const char_type* __lo, const char_type*, mask*) const do_is(const char_type* __lo, const char_type*, mask*) const
{ return __lo; } { return __lo; }
template<> template<>
const pod_type* const pod_ushort*
ctype<pod_type>:: ctype<pod_ushort>::
do_scan_is(mask, const char_type* __lo, const char_type*) const do_scan_is(mask, const char_type* __lo, const char_type*) const
{ return __lo; } { return __lo; }
template<> template<>
const pod_type* const pod_ushort*
ctype<pod_type>:: ctype<pod_ushort>::
do_scan_not(mask, const char_type* __lo, const char_type*) const do_scan_not(mask, const char_type* __lo, const char_type*) const
{ return __lo; } { return __lo; }
template<> template<>
pod_type pod_ushort
ctype<pod_type>:: ctype<pod_ushort>::
do_toupper(char_type __c) const do_toupper(char_type __c) const
{ return __c; } { return __c; }
template<> template<>
const pod_type* const pod_ushort*
ctype<pod_type>:: ctype<pod_ushort>::
do_toupper(char_type*, const char_type* __hi) const do_toupper(char_type*, const char_type* __hi) const
{ return __hi; } { return __hi; }
template<> template<>
pod_type pod_ushort
ctype<pod_type>:: ctype<pod_ushort>::
do_tolower(char_type __c) const do_tolower(char_type __c) const
{ return __c; } { return __c; }
template<> template<>
const pod_type* const pod_ushort*
ctype<pod_type>:: ctype<pod_ushort>::
do_tolower(char_type*, const char_type* __hi) const do_tolower(char_type*, const char_type* __hi) const
{ return __hi; } { return __hi; }
template<> template<>
pod_type pod_ushort
ctype<pod_type>:: ctype<pod_ushort>::
do_widen(char __c) const do_widen(char __c) const
{ {
char_type ret = { value_type(__c) }; char_type ret = { value_type(__c) };
...@@ -101,7 +103,7 @@ namespace std ...@@ -101,7 +103,7 @@ namespace std
template<> template<>
const char* const char*
ctype<pod_type>:: ctype<pod_ushort>::
do_widen(const char* __lo, const char* __hi, char_type* __dest) const do_widen(const char* __lo, const char* __hi, char_type* __dest) const
{ {
while (__lo < __hi) while (__lo < __hi)
...@@ -115,14 +117,14 @@ namespace std ...@@ -115,14 +117,14 @@ namespace std
template<> template<>
char char
ctype<pod_type>:: ctype<pod_ushort>::
do_narrow(char_type __wc, char) const do_narrow(char_type __wc, char) const
{ return static_cast<char>(__wc.value); } { return static_cast<char>(__wc.value); }
template<> template<>
const pod_type* const pod_ushort*
ctype<pod_type>:: ctype<pod_ushort>::
do_narrow(const pod_type* __lo, const pod_type* __hi, do_narrow(const pod_ushort* __lo, const pod_ushort* __hi,
char, char* __dest) const char, char* __dest) const
{ {
while (__lo < __hi) while (__lo < __hi)
...@@ -135,14 +137,14 @@ namespace std ...@@ -135,14 +137,14 @@ namespace std
} }
template<> template<>
ctype<pod_type>::~ctype() { } ctype<pod_ushort>::~ctype() { }
template<> template<>
void void
numpunct<pod_type>::_M_initialize_numpunct(__c_locale) numpunct<pod_ushort>::_M_initialize_numpunct(__c_locale)
{ {
if (!_M_data) if (!_M_data)
_M_data = new __numpunct_cache<pod_type>; _M_data = new __numpunct_cache<pod_ushort>;
_M_data->_M_grouping = ""; _M_data->_M_grouping = "";
_M_data->_M_use_grouping = false; _M_data->_M_use_grouping = false;
...@@ -155,33 +157,33 @@ namespace std ...@@ -155,33 +157,33 @@ namespace std
value_type v = __num_base::_S_atoms_out[i]; value_type v = __num_base::_S_atoms_out[i];
_M_data->_M_atoms_out[i].value = v; _M_data->_M_atoms_out[i].value = v;
} }
_M_data->_M_atoms_out[__num_base::_S_oend] = pod_type(); _M_data->_M_atoms_out[__num_base::_S_oend] = pod_ushort();
for (size_t j = 0; j < __num_base::_S_iend; ++j) for (size_t j = 0; j < __num_base::_S_iend; ++j)
_M_data->_M_atoms_in[j].value = value_type(__num_base::_S_atoms_in[j]); _M_data->_M_atoms_in[j].value = value_type(__num_base::_S_atoms_in[j]);
_M_data->_M_atoms_in[__num_base::_S_iend] = pod_type(); _M_data->_M_atoms_in[__num_base::_S_iend] = pod_ushort();
// "true" // "true"
pod_type* __truename = new pod_type[4 + 1]; pod_ushort* __truename = new pod_ushort[4 + 1];
__truename[0].value = value_type('t'); __truename[0].value = value_type('t');
__truename[1].value = value_type('r'); __truename[1].value = value_type('r');
__truename[2].value = value_type('u'); __truename[2].value = value_type('u');
__truename[3].value = value_type('e'); __truename[3].value = value_type('e');
__truename[4] = pod_type(); __truename[4] = pod_ushort();
_M_data->_M_truename = __truename; _M_data->_M_truename = __truename;
// "false" // "false"
pod_type* __falsename = new pod_type[5 + 1]; pod_ushort* __falsename = new pod_ushort[5 + 1];
__falsename[0].value = value_type('f'); __falsename[0].value = value_type('f');
__falsename[1].value = value_type('a'); __falsename[1].value = value_type('a');
__falsename[2].value = value_type('l'); __falsename[2].value = value_type('l');
__falsename[3].value = value_type('s'); __falsename[3].value = value_type('s');
__falsename[4].value = value_type('e'); __falsename[4].value = value_type('e');
__falsename[5] = pod_type(); __falsename[5] = pod_ushort();
_M_data->_M_falsename = __falsename; _M_data->_M_falsename = __falsename;
} }
template<> template<>
numpunct<pod_type>::~numpunct() numpunct<pod_ushort>::~numpunct()
{ delete _M_data; } { delete _M_data; }
} // namespace std } // namespace std
...@@ -40,176 +40,78 @@ ...@@ -40,176 +40,78 @@
namespace __gnu_test namespace __gnu_test
{ {
// Character type struct pod_int
struct character
{ {
unsigned char val; int value;
static character from_char(char c)
{
character ret;
ret.val = c;
return ret;
}
}; };
inline bool
operator==(const pod_int& lhs, const pod_int& rhs)
{ return lhs.value == rhs.value; }
inline bool inline bool
operator==(const character& lhs, const character& rhs) operator<(const pod_int& lhs, const pod_int& rhs)
{ return lhs.val == rhs.val; } { return lhs.value < rhs.value; }
// State type. struct pod_state
struct conversion_state
{ {
unsigned int state; unsigned long value;
}; };
// Test data types. inline bool
struct pod_char operator==(const pod_state& lhs, const pod_state& rhs)
{ { return lhs.value == rhs.value; }
unsigned char c;
};
inline bool inline bool
operator==(const pod_char& lhs, const pod_char& rhs) operator<(const pod_state& lhs, const pod_state& rhs)
{ return lhs.c == rhs.c; } { return lhs.value < rhs.value; }
struct pod_int
{
int i;
};
struct state
{
unsigned long l;
unsigned long l2;
};
typedef unsigned short value_type; // Alternate character types.
typedef unsigned int int_type; using __gnu_cxx::character;
typedef __gnu_cxx::character<value_type, int_type> pod_type; typedef character<unsigned char, pod_int, pod_state> pod_char;
}; // namespace __gnu_test typedef character<unsigned char, unsigned int, pod_state> pod_uchar;
typedef character<unsigned short, unsigned int> pod_ushort;
namespace std // Specializations.
{ // pod_char
// A std::char_traits specialization. Meets the additional
// requirements for basic_filebuf.
template<> template<>
struct char_traits<__gnu_test::character> template<typename V2>
{ inline pod_char::char_type
typedef __gnu_test::character char_type; pod_char::char_type::from(const V2& v)
typedef unsigned int int_type;
typedef __gnu_test::conversion_state state_type;
typedef streamoff off_type;
typedef fpos<state_type> pos_type;
static void
assign(char_type& c1, const char_type& c2)
{ c1 = c2; }
static bool
eq(const char_type& c1, const char_type& c2)
{ return c1.val == c2.val; }
static bool
lt(const char_type& c1, const char_type& c2)
{ return c1.val < c2.val; }
static int
compare(const char_type* s1, const char_type* s2, size_t n)
{ {
for (size_t i = 0; i < n; ++i) char_type ret = { static_cast<value_type>(v.value) };
{ return ret;
if (lt(s1[i], s2[i]))
return -1;
else if (lt(s2[i], s1[i]))
return 1;
}
return 0;
}
static size_t
length(const char_type* s)
{
size_t n = 0;
while (!eq(s[n], char_type()))
++n;
return n;
}
static const char_type*
find(const char_type* s, size_t n, const char_type& a)
{
for (size_t i = 0; i < n; ++i)
{
if (eq(s[i], a))
return s + i;
}
return NULL;
}
static char_type*
move(char_type* s1, const char_type* s2, size_t n)
{
if (s1 > s2)
{
for (size_t i = 0; i < n; ++i)
assign(s1[n - i - 1], s2[n - i - 1]);
}
else
{
for (size_t i = 0; i < n; ++i)
assign(s1[i], s2[i]);
}
return s1;
}
static char_type*
copy(char_type* s1, const char_type* s2, size_t n)
{
for (size_t i = 0; i < n; ++i)
assign(s1[i], s2[i]);
return s1;
}
static char_type*
assign(char_type* s, size_t n, char_type a)
{
for (size_t i = 0; i < n; ++i)
assign(s[i], a);
return s;
} }
static int_type template<>
not_eof(const int_type& c) template<typename V2>
inline V2
pod_char::char_type::to(const char_type& c)
{ {
if (eq_int_type(c, eof())) V2 ret = { c.value };
return 0; return ret;
return c;
} }
// Note non-trivial conversion to maximize chance of catching bugs // pod_uchar
static char_type template<>
to_char_type(const int_type& c) template<typename V2>
inline pod_uchar::char_type
pod_uchar::char_type::from(const V2& v)
{ {
char_type ret; char_type ret;
ret.val = (c >> 5); ret.value = (v >> 5);
return ret; return ret;
} }
static int_type template<>
to_int_type(const char_type& c) template<typename V2>
{ inline V2
return c.val << 5; pod_uchar::char_type::to(const char_type& c)
} { return static_cast<V2>(c.value << 5); }
}; // namespace __gnu_test
static bool
eq_int_type(const int_type& c1, const int_type& c2)
{ return c1 == c2; }
static int_type eof()
{ return 0xf; }
};
namespace std
{
// codecvt specialization // codecvt specialization
// //
// The conversion performed by the specialization is not supposed to // The conversion performed by the specialization is not supposed to
...@@ -227,58 +129,21 @@ namespace std ...@@ -227,58 +129,21 @@ namespace std
// state. Output those bytes. // state. Output those bytes.
// 3. tmp becomes the new value of state. // 3. tmp becomes the new value of state.
template<> template<>
class codecvt<__gnu_test::character, char, __gnu_test::conversion_state> class codecvt<__gnu_test::pod_uchar, char, __gnu_test::pod_state>
: public locale::facet, public codecvt_base : public __codecvt_abstract_base<__gnu_test::pod_uchar, char,
__gnu_test::pod_state>
{ {
public: public:
typedef __gnu_test::character intern_type; typedef codecvt_base::result result;
typedef char extern_type; typedef __gnu_test::pod_uchar intern_type;
typedef __gnu_test::conversion_state state_type; typedef char extern_type;
typedef __gnu_test::pod_state state_type;
explicit codecvt(size_t refs = 0) typedef __codecvt_abstract_base<intern_type, extern_type, state_type>
: locale::facet(refs) base_type;
explicit codecvt(size_t refs = 0) : base_type(refs)
{ } { }
result
out(state_type& state, const intern_type* from,
const intern_type* from_end, const intern_type*& from_next,
extern_type* to, extern_type* to_limit, extern_type*& to_next) const
{
return do_out(state, from, from_end, from_next,
to, to_limit, to_next);
}
result
unshift(state_type& state, extern_type* to, extern_type* to_limit,
extern_type*& to_next) const
{ return do_unshift(state, to, to_limit, to_next); }
result
in(state_type& state, const extern_type* from,
const extern_type* from_end, const extern_type*& from_next,
intern_type* to, intern_type* to_limit, intern_type*& to_next) const
{
return do_in(state, from, from_end, from_next,
to, to_limit, to_next);
}
int
encoding() const throw()
{ return do_encoding(); }
bool
always_noconv() const throw()
{ return do_always_noconv(); }
int
length(state_type& state, const extern_type* from,
const extern_type* end, size_t max) const
{ return do_length(state, from, end, max); }
int
max_length() const throw()
{ return do_max_length(); }
static locale::id id; static locale::id id;
protected: protected:
...@@ -293,8 +158,8 @@ namespace std ...@@ -293,8 +158,8 @@ namespace std
{ {
while (from < from_end && to < to_limit) while (from < from_end && to < to_limit)
{ {
unsigned char tmp = (state.state ^ from->val); unsigned char tmp = (state.value ^ from->value);
if (state.state & 0x8) if (state.value & 0x8)
{ {
if (to >= to_limit - 2) if (to >= to_limit - 2)
break; break;
...@@ -309,7 +174,7 @@ namespace std ...@@ -309,7 +174,7 @@ namespace std
*to++ = (tmp & 0xf); *to++ = (tmp & 0xf);
*to++ = ((tmp >> 4) & 0xf); *to++ = ((tmp >> 4) & 0xf);
} }
state.state = tmp; state.value = tmp;
++from; ++from;
} }
...@@ -330,13 +195,13 @@ namespace std ...@@ -330,13 +195,13 @@ namespace std
if (c & 0xc0) if (c & 0xc0)
{ {
// Unshift sequence // Unshift sequence
state.state &= c; state.value &= c;
++from; ++from;
continue; continue;
} }
unsigned char tmp; unsigned char tmp;
if (state.state & 0x8) if (state.value & 0x8)
{ {
if (from >= from_end - 2) if (from >= from_end - 2)
break; break;
...@@ -351,8 +216,8 @@ namespace std ...@@ -351,8 +216,8 @@ namespace std
tmp = (*from++ & 0xf); tmp = (*from++ & 0xf);
tmp |= ((*from++ << 4) & 0xf0); tmp |= ((*from++ << 4) & 0xf0);
} }
to->val = (tmp ^ state.state); to->value = (tmp ^ state.value);
state.state = tmp; state.value = tmp;
++to; ++to;
} }
...@@ -368,7 +233,7 @@ namespace std ...@@ -368,7 +233,7 @@ namespace std
for (unsigned int i = 0; i < CHAR_BIT; ++i) for (unsigned int i = 0; i < CHAR_BIT; ++i)
{ {
unsigned int mask = (1 << i); unsigned int mask = (1 << i);
if (state.state & mask) if (state.value & mask)
{ {
if (to == to_limit) if (to == to_limit)
{ {
...@@ -376,13 +241,13 @@ namespace std ...@@ -376,13 +241,13 @@ namespace std
return partial; return partial;
} }
state.state &= ~mask; state.value &= ~mask;
*to++ = static_cast<unsigned char>(~mask); *to++ = static_cast<unsigned char>(~mask);
} }
} }
to_next = to; to_next = to;
return state.state == 0 ? ok : error; return state.value == 0 ? ok : error;
} }
virtual int virtual int
...@@ -404,13 +269,13 @@ namespace std ...@@ -404,13 +269,13 @@ namespace std
if (c & 0xc0) if (c & 0xc0)
{ {
// Unshift sequence // Unshift sequence
state.state &= c; state.value &= c;
++from; ++from;
continue; continue;
} }
unsigned char tmp; unsigned char tmp;
if (state.state & 0x8) if (state.value & 0x8)
{ {
if (from >= end - 2) if (from >= end - 2)
break; break;
...@@ -425,7 +290,7 @@ namespace std ...@@ -425,7 +290,7 @@ namespace std
tmp = (*from++ & 0xf); tmp = (*from++ & 0xf);
tmp |= ((*from++ << 4) & 0xf0); tmp |= ((*from++ << 4) & 0xf0);
} }
state.state = tmp; state.value = tmp;
--max; --max;
} }
return from - beg; return from - beg;
...@@ -438,97 +303,78 @@ namespace std ...@@ -438,97 +303,78 @@ namespace std
{ return 11; } { return 11; }
}; };
// A std::char_traits specialization with POD types for char_type,
// int_type, and state_type.
template<> template<>
struct char_traits<__gnu_test::pod_char> class ctype<__gnu_test::pod_uchar>
: public __ctype_abstract_base<__gnu_test::pod_uchar>
{ {
typedef __gnu_test::pod_char char_type; public:
typedef __gnu_test::pod_int int_type; typedef __gnu_test::pod_uchar char_type;
typedef __gnu_test::state state_type;
typedef fpos<state_type> pos_type;
typedef streamoff off_type;
static void
assign(char_type& c1, const char_type& c2)
{ c1.c = c2.c; }
static bool
eq(const char_type& c1, const char_type& c2)
{ return c1.c == c2.c; }
static bool
lt(const char_type& c1, const char_type& c2)
{ return c1.c < c2.c; }
static int
compare(const char_type* s1, const char_type* s2, size_t n)
{ return memcmp(s1, s2, n); }
static size_t
length(const char_type* s)
{ return strlen(reinterpret_cast<const char*>(s)); }
static const char_type*
find(const char_type* s, size_t n, const char_type& a)
{ return static_cast<const char_type*>(memchr(s, a.c, n)); }
static char_type*
move(char_type* s1, const char_type* s2, size_t n)
{
memmove(s1, s2, n);
return s1;
}
static char_type* explicit ctype(size_t refs = 0)
copy(char_type* s1, const char_type* s2, size_t n) : __ctype_abstract_base<__gnu_test::pod_uchar>(refs) { }
{
memcpy(s1, s2, n);
return s1;
}
static char_type* static locale::id id;
assign(char_type* s, size_t n, char_type a)
{
memset(s, a.c, n);
return s;
}
static char_type protected:
to_char_type(const int_type& c) ~ctype()
{ { }
char_type ret;
ret.c = static_cast<unsigned char>(c.i);
return ret;
}
static int_type virtual bool
to_int_type(const char_type& c) do_is(mask m, char_type c) const
{ return false; }
virtual const char_type*
do_is(const char_type* low, const char_type* high, mask* vec) const
{ {
int_type ret; fill_n(vec, high - low, mask());
ret.i = c.c; return high;
return ret;
} }
static bool virtual const char_type*
eq_int_type(const int_type& c1, const int_type& c2) do_scan_is(mask m, const char_type* low, const char_type* high) const
{ return c1.i == c2.i; } { return high; }
virtual const char_type*
do_scan_not(mask m, const char_type* low, const char_type* high) const
{ return low; }
virtual char_type
do_toupper(char_type c) const
{ return c; }
static int_type virtual const char_type*
eof() do_toupper(char_type* low, const char_type* high) const
{ return high; }
virtual char_type
do_tolower(char_type c) const
{ return c; }
virtual const char_type*
do_tolower(char_type* low, const char_type* high) const
{ return high; }
virtual char_type
do_widen(char c) const
{ return __gnu_test::pod_uchar::from<char>(c); }
virtual const char*
do_widen(const char* low, const char* high, char_type* dest) const
{ {
int_type n; transform(low, high, dest, &__gnu_test::pod_uchar::from<char>);
n.i = -10; return high;
return n;
} }
static int_type virtual char
not_eof(const int_type& c) do_narrow(char_type, char dfault) const
{ return dfault; }
virtual const char_type*
do_narrow(const char_type* low, const char_type* high,
char dfault, char* dest) const
{ {
if (eq_int_type(c, eof())) fill_n(dest, high - low, dfault);
return int_type(); return high;
return c;
} }
}; };
} // namespace std } // namespace std
......
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