]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
locale_facets.tcc (num_get<>::do_get(iter_type, iter_type, ios_base&, ios_base::iosta...
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 3 Nov 2008 10:23:38 +0000 (10:23 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 3 Nov 2008 10:23:38 +0000 (10:23 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/testsuite/22_locale/num_get/get/char/37958.cc
libstdc++-v3/testsuite/22_locale/num_get/get/wchar_t/37958.cc

index 18fd23283d3efde7a72f2cde82f0c0e7e9c31f02..47ffacc35cea3c6343bf11a200f5922ca95b9ece 100644 (file)
@@ -1,3 +1,10 @@
+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)
index 36a2d9b80c4a649cebd3246efd62e24aa7d43103..9a44007e451feccccfc0f06d9c925eac8c2d1e4e 100644 (file)
@@ -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;
index 9f7a43c4c1e98e75f9dd090efcd16eb317eed12f..fe8161c31d537207424e649c401943c7239e58d0 100644 (file)
@@ -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()
index b36573697a400c561f491dc8e03bc46f5714297a..e48024510e0593f22aec3c4d14ec013aac455275 100644 (file)
@@ -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()