Commit 2a81fe20 by Paolo Carlini Committed by Paolo Carlini

locale_facets.tcc (num_get<>::do_get(iter_type, iter_type, ios_base&,…

locale_facets.tcc (num_get<>::do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&): Tidy.

2008-11-03  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/locale_facets.tcc (num_get<>::do_get(iter_type,
	iter_type, ios_base&, ios_base::iostate&, bool&): Tidy.
	* testsuite/22_locale/num_get/get/char/37958.cc: Extend.
	* testsuite/22_locale/num_get/get/wchar_t/37958.cc: Likewise.

From-SVN: r141546
parent 6f1fe305
2008-11-03 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/locale_facets.tcc (num_get<>::do_get(iter_type,
iter_type, ios_base&, ios_base::iostate&, bool&): Tidy.
* testsuite/22_locale/num_get/get/char/37958.cc: Extend.
* testsuite/22_locale/num_get/get/wchar_t/37958.cc: Likewise.
2008-11-01 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/37958 (cont again)
......
......@@ -623,14 +623,16 @@ _GLIBCXX_BEGIN_LDBL_NAMESPACE
if (!__donef)
__testf = __c == __lc->_M_falsename[__n];
if (!__testf && __donet)
break;
if (!__donet)
__testt = __c == __lc->_M_truename[__n];
if (!__testt && !__testf)
if (!__testt && __donef)
break;
if ((!__testt && __n >= __lc->_M_falsename_size)
|| (!__testf && __n >= __lc->_M_truename_size))
if (!__testt && !__testf)
break;
++__n;
......
......@@ -42,6 +42,12 @@ struct Punct3: std::numpunct<char>
std::string do_falsename() const { return ""; }
};
struct Punct4: std::numpunct<char>
{
std::string do_truename() const { return "one"; }
std::string do_falsename() const { return "two"; }
};
// libstdc++/37958
void test01()
{
......@@ -50,14 +56,16 @@ void test01()
bool test __attribute__((unused)) = true;
istringstream iss0, iss1, iss2, iss3;
istringstream iss0, iss1, iss2, iss3, iss4;
iss1.imbue(locale(iss1.getloc(), new Punct1));
iss2.imbue(locale(iss2.getloc(), new Punct2));
iss3.imbue(locale(iss3.getloc(), new Punct3));
iss4.imbue(locale(iss4.getloc(), new Punct4));
const num_get<char>& ng0 = use_facet<num_get<char> >(iss0.getloc());
const num_get<char>& ng1 = use_facet<num_get<char> >(iss1.getloc());
const num_get<char>& ng2 = use_facet<num_get<char> >(iss2.getloc());
const num_get<char>& ng3 = use_facet<num_get<char> >(iss3.getloc());
const num_get<char>& ng4 = use_facet<num_get<char> >(iss4.getloc());
ios_base::iostate err = ios_base::goodbit;
iterator_type end;
......@@ -65,6 +73,7 @@ void test01()
bool b1 = false;
bool b2 = false;
bool b3 = true;
bool b4 = false;
iss0.str("true");
iss0.setf(ios_base::boolalpha);
......@@ -102,6 +111,14 @@ void test01()
VERIFY( b1 == false );
VERIFY( *end == 'c' );
iss1.str("ab");
iss1.clear();
b1 = true;
err = ios_base::goodbit;
end = ng1.get(iss1.rdbuf(), 0, iss1, err, b1);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
VERIFY( b1 == false );
iss2.str("1");
iss2.setf(ios_base::boolalpha);
err = ios_base::goodbit;
......@@ -116,6 +133,15 @@ void test01()
VERIFY( err == ios_base::goodbit );
VERIFY( b2 == false );
iss2.str("2");
iss2.clear();
b2 = true;
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, b2);
VERIFY( err == ios_base::failbit );
VERIFY( b2 == false );
VERIFY( *end == '2' );
iss3.str("blah");
iss3.setf(ios_base::boolalpha);
err = ios_base::goodbit;
......@@ -131,6 +157,37 @@ void test01()
end = ng3.get(iss3.rdbuf(), 0, iss3, err, b3);
VERIFY( err == ios_base::failbit );
VERIFY( b3 == false );
iss4.str("one");
iss4.setf(ios_base::boolalpha);
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == ios_base::goodbit );
VERIFY( b4 == true );
iss4.str("two");
iss4.clear();
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == ios_base::goodbit );
VERIFY( b4 == false );
iss4.str("three");
iss4.clear();
b4 = true;
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == ios_base::failbit );
VERIFY( b4 == false );
VERIFY( *end == 'h' );
iss4.str("on");
iss4.clear();
b4 = true;
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
VERIFY( b4 == false );
}
int main()
......
......@@ -42,6 +42,12 @@ struct Punct3: std::numpunct<wchar_t>
std::wstring do_falsename() const { return L""; }
};
struct Punct4: std::numpunct<wchar_t>
{
std::wstring do_truename() const { return L"one"; }
std::wstring do_falsename() const { return L"two"; }
};
// libstdc++/37958
void test01()
{
......@@ -50,14 +56,16 @@ void test01()
bool test __attribute__((unused)) = true;
wistringstream iss0, iss1, iss2, iss3;
wistringstream iss0, iss1, iss2, iss3, iss4;
iss1.imbue(locale(iss1.getloc(), new Punct1));
iss2.imbue(locale(iss2.getloc(), new Punct2));
iss3.imbue(locale(iss3.getloc(), new Punct3));
iss4.imbue(locale(iss4.getloc(), new Punct4));
const num_get<wchar_t>& ng0 = use_facet<num_get<wchar_t> >(iss0.getloc());
const num_get<wchar_t>& ng1 = use_facet<num_get<wchar_t> >(iss1.getloc());
const num_get<wchar_t>& ng2 = use_facet<num_get<wchar_t> >(iss2.getloc());
const num_get<wchar_t>& ng3 = use_facet<num_get<wchar_t> >(iss3.getloc());
const num_get<wchar_t>& ng4 = use_facet<num_get<wchar_t> >(iss4.getloc());
ios_base::iostate err = ios_base::goodbit;
iterator_type end;
......@@ -65,6 +73,7 @@ void test01()
bool b1 = false;
bool b2 = false;
bool b3 = true;
bool b4 = false;
iss0.str(L"true");
iss0.setf(ios_base::boolalpha);
......@@ -102,6 +111,14 @@ void test01()
VERIFY( b1 == false );
VERIFY( *end == L'c' );
iss1.str(L"ab");
iss1.clear();
b1 = true;
err = ios_base::goodbit;
end = ng1.get(iss1.rdbuf(), 0, iss1, err, b1);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
VERIFY( b1 == false );
iss2.str(L"1");
iss2.setf(ios_base::boolalpha);
err = ios_base::goodbit;
......@@ -116,6 +133,15 @@ void test01()
VERIFY( err == ios_base::goodbit );
VERIFY( b2 == false );
iss2.str(L"2");
iss2.clear();
b2 = true;
err = ios_base::goodbit;
end = ng2.get(iss2.rdbuf(), 0, iss2, err, b2);
VERIFY( err == ios_base::failbit );
VERIFY( b2 == false );
VERIFY( *end == L'2' );
iss3.str(L"blah");
iss3.setf(ios_base::boolalpha);
err = ios_base::goodbit;
......@@ -131,6 +157,37 @@ void test01()
end = ng3.get(iss3.rdbuf(), 0, iss3, err, b3);
VERIFY( err == ios_base::failbit );
VERIFY( b3 == false );
iss4.str(L"one");
iss4.setf(ios_base::boolalpha);
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == ios_base::goodbit );
VERIFY( b4 == true );
iss4.str(L"two");
iss4.clear();
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == ios_base::goodbit );
VERIFY( b4 == false );
iss4.str(L"three");
iss4.clear();
b4 = true;
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == ios_base::failbit );
VERIFY( b4 == false );
VERIFY( *end == L'h' );
iss4.str(L"on");
iss4.clear();
b4 = true;
err = ios_base::goodbit;
end = ng4.get(iss4.rdbuf(), 0, iss4, err, b4);
VERIFY( err == (ios_base::failbit | ios_base::eofbit) );
VERIFY( b4 == false );
}
int main()
......
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