aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/bits/locale_facets.tcc8
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get_members_char.cc62
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc86
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put_members_char.cc76
-rw-r--r--libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc73
6 files changed, 298 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 43f74f8..a73de4f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,4 +1,14 @@
2002-01-15 Benjamin Kosnik <bkoz@redhat.com>
+
+ * include/bits/locale_facets.tcc (num_put::do_put(bool): Fix.
+ (num_put::do_put(void*)): Fix.
+ * testsuite/22_locale/num_put_members_char.cc (test02): Add.
+ * testsuite/22_locale/num_put_members_wchar_t.cc (test02): Add.
+ * testsuite/22_locale/num_get_members_char.cc (test02): Add
+ long double, void, bool types.
+ * testsuite/22_locale/num_get_members_wchar_t.cc (test02): Add.
+
+2002-01-15 Benjamin Kosnik <bkoz@redhat.com>
Alexandre Oliva <aoliva@redhat.com>
* libmath/Makefile.am (LINK): Add --tag CC.
diff --git a/libstdc++-v3/include/bits/locale_facets.tcc b/libstdc++-v3/include/bits/locale_facets.tcc
index 57cab78..083cb63 100644
--- a/libstdc++-v3/include/bits/locale_facets.tcc
+++ b/libstdc++-v3/include/bits/locale_facets.tcc
@@ -939,7 +939,7 @@ namespace std
if ((__flags & ios_base::boolalpha) == 0)
{
unsigned long __uv = __v;
- _M_convert_int(__s, __io, __fill, 'u', char_type(), __uv);
+ __s = _M_convert_int(__s, __io, __fill, 'u', char_type(), __uv);
}
else
{
@@ -957,7 +957,7 @@ namespace std
__ws = __np.falsename().c_str();
__len = __np.falsename().size();
}
- _M_insert(__s, __io, __fill, __ws, __len);
+ __s = _M_insert(__s, __io, __fill, __ws, __len);
}
return __s;
}
@@ -1015,8 +1015,8 @@ namespace std
__io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
try
{
- _M_convert_int(__s, __io, __fill, 'u', char_type(),
- reinterpret_cast<unsigned long>(__v));
+ __s = _M_convert_int(__s, __io, __fill, 'u', char_type(),
+ reinterpret_cast<unsigned long>(__v));
__io.flags(__flags);
}
catch (...)
diff --git a/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc b/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc
index 5ff1196..04824b0 100644
--- a/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc
+++ b/libstdc++-v3/testsuite/22_locale/num_get_members_char.cc
@@ -1,6 +1,6 @@
// 2001-11-21 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001-2002 Free Software Foundation
+// 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
@@ -242,27 +242,75 @@ void test02()
using namespace std;
bool test = true;
- // Num_get works with other iterators besides streambuf output iterators
+ // Check num_get works with other iterators besides streambuf
+ // output iterators. (As long as output_iterator requirements are met.)
typedef string::const_iterator iter_type;
typedef num_get<char, iter_type> num_get_type;
const ios_base::iostate goodbit = ios_base::goodbit;
const ios_base::iostate eofbit = ios_base::eofbit;
ios_base::iostate err = ios_base::goodbit;
const locale loc_c = locale::classic();
+ const string str("20000106 Elizabeth Durack");
+ const string str2("0 true 0xbffff74c Durack");
- long i = 0;
- const string str = "20000106 Elizabeth Durack";
istringstream iss; // need an ios, add my num_get facet
iss.imbue(locale(loc_c, new num_get_type));
// Iterator advanced, state, output.
const num_get_type& ng = use_facet<num_get_type>(iss.getloc());
- iter_type end = ng.get(str.begin(), str.end(), iss, err, i);
- string rem(end, str.end());
+ // 01 get(long)
+ // 02 get(long double)
+ // 03 get(bool)
+ // 04 get(void*)
+
+ // 01 get(long)
+ long i = 0;
+ err = goodbit;
+ iter_type end1 = ng.get(str.begin(), str.end(), iss, err, i);
+ string rem1(end1, str.end());
VERIFY( err == goodbit );
VERIFY( i == 20000106);
- VERIFY( rem == " Elizabeth Durack" );
+ VERIFY( rem1 == " Elizabeth Durack" );
+
+ // 02 get(long double)
+ long double ld = 0;
+ err = goodbit;
+ iter_type end2 = ng.get(str.begin(), str.end(), iss, err, ld);
+ string rem2(end2, str.end());
+ VERIFY( err == goodbit );
+ VERIFY( ld == 20000106);
+ VERIFY( rem2 == " Elizabeth Durack" );
+
+ // 03 get(bool)
+ bool b = 1;
+ iss.clear();
+ err = goodbit;
+ iter_type end3 = ng.get(str2.begin(), str2.end(), iss, err, b);
+ string rem3(end3, str2.end());
+ VERIFY( err == goodbit );
+ VERIFY( b == 0 );
+ VERIFY( rem3 == " true 0xbffff74c Durack" );
+
+ iss.clear();
+ err = goodbit;
+ iss.setf(ios_base::boolalpha);
+ iter_type end4 = ng.get(++end3, str2.end(), iss, err, b);
+ string rem4(end4, str2.end());
+ VERIFY( err == goodbit );
+ VERIFY( b == true );
+ VERIFY( rem4 == " 0xbffff74c Durack" );
+
+ // 04 get(void*)
+ void* v;
+ iss.clear();
+ err = goodbit;
+ iss.setf(ios_base::fixed, ios_base::floatfield);
+ iter_type end5 = ng.get(++end4, str2.end(), iss, err, v);
+ string rem5(end5, str2.end());
+ VERIFY( err == goodbit );
+ VERIFY( b == true );
+ VERIFY( rem5 == " Durack" );
}
int main()
diff --git a/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc
index e8d2353..cbb27cc 100644
--- a/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc
+++ b/libstdc++-v3/testsuite/22_locale/num_get_members_wchar_t.cc
@@ -1,6 +1,6 @@
// 2001-11-26 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001 Free Software Foundation
+// Copyright (C) 2001, 2002 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -235,12 +235,92 @@ void test01()
VERIFY( err == eofbit );
#endif
}
+
+// 2002-01-10 David Seymour <seymour_dj@yahoo.com>
+// libstdc++/5331
+void test02()
+{
+ using namespace std;
+ bool test = true;
+
+ // Check num_get works with other iterators besides streambuf
+ // output iterators. (As long as output_iterator requirements are met.)
+ typedef wstring::const_iterator iter_type;
+ typedef num_get<wchar_t, iter_type> num_get_type;
+ const ios_base::iostate goodbit = ios_base::goodbit;
+ const ios_base::iostate eofbit = ios_base::eofbit;
+ ios_base::iostate err = ios_base::goodbit;
+ const locale loc_c = locale::classic();
+ const wstring str(L"20000106 Elizabeth Durack");
+ const wstring str2(L"0 true 0xbffff74c Durack");
+
+ istringstream iss; // need an ios, add my num_get facet
+ iss.imbue(locale(loc_c, new num_get_type));
+
+ // Iterator advanced, state, output.
+ const num_get_type& ng = use_facet<num_get_type>(iss.getloc());
+
+ // 01 get(long)
+ // 02 get(long double)
+ // 03 get(bool)
+ // 04 get(void*)
+
+ // 01 get(long)
+ long i = 0;
+ err = goodbit;
+ iter_type end1 = ng.get(str.begin(), str.end(), iss, err, i);
+ wstring rem1(end1, str.end());
+ VERIFY( err == goodbit );
+ VERIFY( i == 20000106);
+ VERIFY( rem1 == L" Elizabeth Durack" );
+
+ // 02 get(long double)
+ long double ld = 0;
+ err = goodbit;
+ iter_type end2 = ng.get(str.begin(), str.end(), iss, err, ld);
+ wstring rem2(end2, str.end());
+ VERIFY( err == goodbit );
+ VERIFY( ld == 20000106);
+ VERIFY( rem2 == L" Elizabeth Durack" );
+
+ // 03 get(bool)
+ // const string str2("0 true 0xbffff74c Durack");
+ bool b = 1;
+ iss.clear();
+ err = goodbit;
+ iter_type end3 = ng.get(str2.begin(), str2.end(), iss, err, b);
+ wstring rem3(end3, str2.end());
+ VERIFY( err == goodbit );
+ VERIFY( b == 0 );
+ VERIFY( rem3 == L" true 0xbffff74c Durack" );
+
+ iss.clear();
+ err = goodbit;
+ iss.setf(ios_base::boolalpha);
+ iter_type end4 = ng.get(++end3, str2.end(), iss, err, b);
+ wstring rem4(end4, str2.end());
+ VERIFY( err == goodbit );
+ VERIFY( b == true );
+ VERIFY( rem4 == L" 0xbffff74c Durack" );
+
+ // 04 get(void*)
+ void* v;
+ iss.clear();
+ err = goodbit;
+ iss.setf(ios_base::fixed, ios_base::floatfield);
+ iter_type end5 = ng.get(++end4, str2.end(), iss, err, v);
+ wstring rem5(end5, str2.end());
+ VERIFY( err == goodbit );
+ VERIFY( b == true );
+ VERIFY( rem5 == L" Durack" );
+}
#endif
int main()
{
#ifdef _GLIBCPP_USE_WCHAR_T
test01();
+ test02();
#endif
return 0;
}
@@ -248,3 +328,7 @@ int main()
// Kathleen Hannah, humanitarian, woman, art-thief
+
+
+
+
diff --git a/libstdc++-v3/testsuite/22_locale/num_put_members_char.cc b/libstdc++-v3/testsuite/22_locale/num_put_members_char.cc
index 9bc5dce..1ca5163 100644
--- a/libstdc++-v3/testsuite/22_locale/num_put_members_char.cc
+++ b/libstdc++-v3/testsuite/22_locale/num_put_members_char.cc
@@ -1,6 +1,6 @@
// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001 Free Software Foundation
+// Copyright (C) 2001, 2002 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -219,12 +219,80 @@ void test01()
#endif
}
+void test02()
+{
+ using namespace std;
+ bool test = true;
+
+ // Check num_put works with other iterators besides streambuf
+ // output iterators. (As long as output_iterator requirements are met.)
+ typedef string::iterator iter_type;
+ typedef char_traits<char> traits;
+ typedef num_put<char, iter_type> num_put_type;
+ const ios_base::iostate goodbit = ios_base::goodbit;
+ const ios_base::iostate eofbit = ios_base::eofbit;
+ const locale loc_c = locale::classic();
+ const string str("1798 Lady Elgin");
+ const string str2("0 true 0xbffff74c Mary Nisbet");
+ const string x(15, 'x'); // have to have allocated string!
+ string res;
+
+ ostringstream oss;
+ oss.imbue(locale(loc_c, new num_put_type));
+
+ // Iterator advanced, state, output.
+ const num_put_type& tp = use_facet<num_put_type>(oss.getloc());
+
+ // 01 put(long)
+ // 02 put(long double)
+ // 03 put(bool)
+ // 04 put(void*)
+
+ // 01 put(long)
+ const long l = 1798;
+ res = x;
+ iter_type ret1 = tp.put(res.begin(), oss, ' ', l);
+ string sanity1(res.begin(), ret1);
+ VERIFY( res == "1798xxxxxxxxxxx" );
+ VERIFY( sanity1 == "1798" );
+
+ // 02 put(long double)
+ const long double ld = 1798;
+ res = x;
+ iter_type ret2 = tp.put(res.begin(), oss, ' ', ld);
+ string sanity2(res.begin(), ret2);
+ VERIFY( res == "1798xxxxxxxxxxx" );
+ VERIFY( sanity2 == "1798" );
+
+ // 03 put(bool)
+ bool b = 1;
+ res = x;
+ iter_type ret3 = tp.put(res.begin(), oss, ' ', b);
+ string sanity3(res.begin(), ret3);
+ VERIFY( res == "1xxxxxxxxxxxxxx" );
+ VERIFY( sanity3 == "1" );
+
+ b = 0;
+ res = x;
+ oss.setf(ios_base::boolalpha);
+ iter_type ret4 = tp.put(res.begin(), oss, ' ', b);
+ string sanity4(res.begin(), ret4);
+ VERIFY( res == "falsexxxxxxxxxx" );
+ VERIFY( sanity4 == "false" );
+
+ // 04 put(void*)
+ oss.clear();
+ const void* cv = &ld;
+ res = x;
+ oss.setf(ios_base::fixed, ios_base::floatfield);
+ iter_type ret5 = tp.put(res.begin(), oss, ' ', cv);
+ string sanity5(res.begin(), ret5);
+ VERIFY( !char_traits<char>::find(sanity5.c_str(), 'x', sanity5.size()) );
+}
int main()
{
test01();
+ test02();
return 0;
}
-
-
-
diff --git a/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc b/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc
index 885df82..d502ee4 100644
--- a/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc
+++ b/libstdc++-v3/testsuite/22_locale/num_put_members_wchar_t.cc
@@ -1,6 +1,6 @@
// 2001-11-19 Benjamin Kosnik <bkoz@redhat.com>
-// Copyright (C) 2001 Free Software Foundation
+// Copyright (C) 2001, 2002 Free Software Foundation
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -219,12 +219,83 @@ void test01()
VERIFY( result1 == L"9.223.372.036.854.775.807" );
#endif
}
+void test02()
+{
+ using namespace std;
+ bool test = true;
+
+ // Check num_put works with other iterators besides streambuf
+ // output iterators. (As long as output_iterator requirements are met.)
+ typedef wstring::iterator iter_type;
+ typedef char_traits<wchar_t> traits;
+ typedef num_put<wchar_t, iter_type> num_put_type;
+ const ios_base::iostate goodbit = ios_base::goodbit;
+ const ios_base::iostate eofbit = ios_base::eofbit;
+ const locale loc_c = locale::classic();
+ const wstring str(L"1798 Lady Elgin");
+ const wstring str2(L"0 true 0xbffff74c Mary Nisbet");
+ const wstring x(15, L'x'); // have to have allocated string!
+ wstring res;
+
+ wostringstream oss;
+ oss.imbue(locale(loc_c, new num_put_type));
+
+ // Iterator advanced, state, output.
+ const num_put_type& tp = use_facet<num_put_type>(oss.getloc());
+
+ // 01 put(long)
+ // 02 put(long double)
+ // 03 put(bool)
+ // 04 put(void*)
+
+ // 01 put(long)
+ const long l = 1798;
+ res = x;
+ iter_type ret1 = tp.put(res.begin(), oss, L' ', l);
+ wstring sanity1(res.begin(), ret1);
+ VERIFY( res == L"1798xxxxxxxxxxx" );
+ VERIFY( sanity1 == L"1798" );
+
+ // 02 put(long double)
+ const long double ld = 1798;
+ res = x;
+ iter_type ret2 = tp.put(res.begin(), oss, L' ', ld);
+ wstring sanity2(res.begin(), ret2);
+ VERIFY( res == L"1798xxxxxxxxxxx" );
+ VERIFY( sanity2 == L"1798" );
+
+ // 03 put(bool)
+ bool b = 1;
+ res = x;
+ iter_type ret3 = tp.put(res.begin(), oss, L' ', b);
+ wstring sanity3(res.begin(), ret3);
+ VERIFY( res == L"1xxxxxxxxxxxxxx" );
+ VERIFY( sanity3 == L"1" );
+
+ b = 0;
+ res = x;
+ oss.setf(ios_base::boolalpha);
+ iter_type ret4 = tp.put(res.begin(), oss, L' ', b);
+ wstring sanity4(res.begin(), ret4);
+ VERIFY( res == L"falsexxxxxxxxxx" );
+ VERIFY( sanity4 == L"false" );
+
+ // 04 put(void*)
+ oss.clear();
+ const void* cv = &ld;
+ res = x;
+ oss.setf(ios_base::fixed, ios_base::floatfield);
+ iter_type ret5 = tp.put(res.begin(), oss, L' ', cv);
+ wstring sanity5(res.begin(), ret5);
+ VERIFY( !char_traits<wchar_t>::find(sanity5.c_str(), L'x', sanity5.size()) );
+}
#endif
int main()
{
#ifdef _GLIBCPP_USE_WCHAR_T
test01();
+ test02();
#endif
return 0;
}