This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Tidy num_get::do_get(bool&)


Hi,

tested x86_64-linux, committed to mainline.

Paolo.

///////////////
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.
Index: include/bits/locale_facets.tcc
===================================================================
*** include/bits/locale_facets.tcc	(revision 141531)
--- include/bits/locale_facets.tcc	(working copy)
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 623,636 ****
  	      if (!__donef)
  		__testf = __c == __lc->_M_falsename[__n];
  
  	      if (!__donet)
  		__testt = __c == __lc->_M_truename[__n];
  
! 	      if (!__testt && !__testf)
  		break;
  
! 	      if ((!__testt && __n >= __lc->_M_falsename_size)
! 		  || (!__testf && __n >= __lc->_M_truename_size))
  		break;
  
  	      ++__n;
--- 623,638 ----
  	      if (!__donef)
  		__testf = __c == __lc->_M_falsename[__n];
  
+ 	      if (!__testf && __donet)
+ 		break;
+ 
  	      if (!__donet)
  		__testt = __c == __lc->_M_truename[__n];
  
! 	      if (!__testt && __donef)
  		break;
  
! 	      if (!__testt && !__testf)
  		break;
  
  	      ++__n;
Index: testsuite/22_locale/num_get/get/wchar_t/37958.cc
===================================================================
*** testsuite/22_locale/num_get/get/wchar_t/37958.cc	(revision 141531)
--- testsuite/22_locale/num_get/get/wchar_t/37958.cc	(working copy)
*************** struct Punct3: std::numpunct<wchar_t>
*** 42,47 ****
--- 42,53 ----
    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()
  {
*************** void test01()
*** 50,63 ****
    
    bool test __attribute__((unused)) = true;
  
!   wistringstream iss0, iss1, iss2, iss3;
    iss1.imbue(locale(iss1.getloc(), new Punct1));
    iss2.imbue(locale(iss2.getloc(), new Punct2));
    iss3.imbue(locale(iss3.getloc(), new Punct3));
    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());
  
    ios_base::iostate err = ios_base::goodbit;
    iterator_type end;
--- 56,71 ----
    
    bool test __attribute__((unused)) = true;
  
!   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;
*************** void test01()
*** 65,70 ****
--- 73,79 ----
    bool b1 = false;
    bool b2 = false;
    bool b3 = true;
+   bool b4 = false;
  
    iss0.str(L"true");
    iss0.setf(ios_base::boolalpha);
*************** void test01()
*** 102,107 ****
--- 111,124 ----
    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;
*************** void test01()
*** 116,121 ****
--- 133,147 ----
    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;
*************** void test01()
*** 131,136 ****
--- 157,193 ----
    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()
Index: testsuite/22_locale/num_get/get/char/37958.cc
===================================================================
*** testsuite/22_locale/num_get/get/char/37958.cc	(revision 141531)
--- testsuite/22_locale/num_get/get/char/37958.cc	(working copy)
*************** struct Punct3: std::numpunct<char>
*** 42,47 ****
--- 42,53 ----
    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()
  {
*************** void test01()
*** 50,63 ****
    
    bool test __attribute__((unused)) = true;
  
!   istringstream iss0, iss1, iss2, iss3;
    iss1.imbue(locale(iss1.getloc(), new Punct1));
    iss2.imbue(locale(iss2.getloc(), new Punct2));
    iss3.imbue(locale(iss3.getloc(), new Punct3));
    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());
  
    ios_base::iostate err = ios_base::goodbit;
    iterator_type end;
--- 56,71 ----
    
    bool test __attribute__((unused)) = true;
  
!   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;
*************** void test01()
*** 65,70 ****
--- 73,79 ----
    bool b1 = false;
    bool b2 = false;
    bool b3 = true;
+   bool b4 = false;
  
    iss0.str("true");
    iss0.setf(ios_base::boolalpha);
*************** void test01()
*** 102,107 ****
--- 111,124 ----
    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;
*************** void test01()
*** 116,121 ****
--- 133,147 ----
    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;
*************** void test01()
*** 131,136 ****
--- 157,193 ----
    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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]