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]

Re: [v3] libstdc++/37958 (again)


... and again, humpf! ;)

Paolo.

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

	PR libstdc++/37958 (cont again)
	* include/bits/locale_facets.tcc (num_get<>::do_get(iter_type,
	iter_type, ios_base&, ios_base::iostate&, bool&): Fix again.
	* 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 141520)
--- include/bits/locale_facets.tcc	(working copy)
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 606,616 ****
  
  	  bool __testf = true;
  	  bool __testt = true;
  	  bool __testeof = false;
! 	  size_t __n;
! 	  const size_t __lim = std::max(__lc->_M_falsename_size,
! 					__lc->_M_truename_size);
! 	  for (__n = 0; __n < __lim; ++__n, ++__beg)
  	    {
  	      if (__beg == __end)
  		{
--- 606,616 ----
  
  	  bool __testf = true;
  	  bool __testt = true;
+ 	  bool __donef = __lc->_M_falsename_size == 0;
+ 	  bool __donet = __lc->_M_truename_size == 0;
  	  bool __testeof = false;
! 	  size_t __n = 0;
! 	  while (!__donef || !__donet)
  	    {
  	      if (__beg == __end)
  		{
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 620,629 ****
  
  	      const char_type __c = *__beg;
  
! 	      if (__testf && __n < __lc->_M_falsename_size)
  		__testf = __c == __lc->_M_falsename[__n];
  
! 	      if (__testt && __n < __lc->_M_truename_size)
  		__testt = __c == __lc->_M_truename[__n];
  
  	      if (!__testt && !__testf)
--- 620,629 ----
  
  	      const char_type __c = *__beg;
  
! 	      if (!__donef)
  		__testf = __c == __lc->_M_falsename[__n];
  
! 	      if (!__donet)
  		__testt = __c == __lc->_M_truename[__n];
  
  	      if (!__testt && !__testf)
*************** _GLIBCXX_BEGIN_LDBL_NAMESPACE
*** 632,637 ****
--- 632,643 ----
  	      if ((!__testt && __n >= __lc->_M_falsename_size)
  		  || (!__testf && __n >= __lc->_M_truename_size))
  		break;
+ 
+ 	      ++__n;
+ 	      ++__beg;
+ 
+ 	      __donef = !__testf || __n >= __lc->_M_falsename_size;
+ 	      __donet = !__testt || __n >= __lc->_M_truename_size;
  	    }
  	  if (__testf && __n == __lc->_M_falsename_size && __n)
  	    {
Index: testsuite/22_locale/num_get/get/wchar_t/37958.cc
===================================================================
*** testsuite/22_locale/num_get/get/wchar_t/37958.cc	(revision 141517)
--- testsuite/22_locale/num_get/get/wchar_t/37958.cc	(working copy)
*************** void test01()
*** 50,69 ****
    
    bool test __attribute__((unused)) = true;
  
!   wistringstream 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>& 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;
    bool b1 = false;
    bool b2 = false;
    bool b3 = true;
  
    iss1.str(L"a");
    iss1.setf(ios_base::boolalpha);
    err = ios_base::goodbit;
--- 50,85 ----
    
    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;
+   bool b0 = false;
    bool b1 = false;
    bool b2 = false;
    bool b3 = true;
  
+   iss0.str(L"true");
+   iss0.setf(ios_base::boolalpha);
+   err = ios_base::goodbit;
+   end = ng0.get(iss0.rdbuf(), 0, iss0, err, b0);
+   VERIFY( err == ios_base::goodbit );
+   VERIFY( b0 == true );
+ 
+   iss0.str(L"false");
+   iss0.clear();
+   err = ios_base::goodbit;
+   end = ng0.get(iss0.rdbuf(), 0, iss0, err, b0);
+   VERIFY( err == ios_base::goodbit );
+   VERIFY( b0 == false );
+ 
    iss1.str(L"a");
    iss1.setf(ios_base::boolalpha);
    err = ios_base::goodbit;
*************** void test01()
*** 93,98 ****
--- 109,121 ----
    VERIFY( err == ios_base::goodbit );
    VERIFY( b2 == true );
  
+   iss2.str(L"0");
+   iss2.clear();
+   err = ios_base::goodbit;
+   end = ng2.get(iss2.rdbuf(), 0, iss2, err, b2);
+   VERIFY( err == ios_base::goodbit );
+   VERIFY( b2 == false );
+ 
    iss3.str(L"blah");
    iss3.setf(ios_base::boolalpha);
    err = ios_base::goodbit;
*************** void test01()
*** 100,105 ****
--- 123,136 ----
    VERIFY( err == ios_base::failbit );
    VERIFY( b3 == false );
    VERIFY( *end == L'b' );
+ 
+   iss3.str(L"");
+   iss3.clear();
+   b3 = true;
+   err = ios_base::goodbit;
+   end = ng3.get(iss3.rdbuf(), 0, iss3, err, b3);
+   VERIFY( err == ios_base::failbit );
+   VERIFY( b3 == false );
  }
  
  int main()
Index: testsuite/22_locale/num_get/get/char/37958.cc
===================================================================
*** testsuite/22_locale/num_get/get/char/37958.cc	(revision 141517)
--- testsuite/22_locale/num_get/get/char/37958.cc	(working copy)
*************** void test01()
*** 50,69 ****
    
    bool test __attribute__((unused)) = true;
  
!   istringstream 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>& 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;
    bool b1 = false;
    bool b2 = false;
    bool b3 = true;
  
    iss1.str("a");
    iss1.setf(ios_base::boolalpha);
    err = ios_base::goodbit;
--- 50,85 ----
    
    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;
+   bool b0 = false;
    bool b1 = false;
    bool b2 = false;
    bool b3 = true;
  
+   iss0.str("true");
+   iss0.setf(ios_base::boolalpha);
+   err = ios_base::goodbit;
+   end = ng0.get(iss0.rdbuf(), 0, iss0, err, b0);
+   VERIFY( err == ios_base::goodbit );
+   VERIFY( b0 == true );
+ 
+   iss0.str("false");
+   iss0.clear();
+   err = ios_base::goodbit;
+   end = ng0.get(iss0.rdbuf(), 0, iss0, err, b0);
+   VERIFY( err == ios_base::goodbit );
+   VERIFY( b0 == false );
+ 
    iss1.str("a");
    iss1.setf(ios_base::boolalpha);
    err = ios_base::goodbit;
*************** void test01()
*** 93,98 ****
--- 109,121 ----
    VERIFY( err == ios_base::goodbit );
    VERIFY( b2 == true );
  
+   iss2.str("0");
+   iss2.clear();
+   err = ios_base::goodbit;
+   end = ng2.get(iss2.rdbuf(), 0, iss2, err, b2);
+   VERIFY( err == ios_base::goodbit );
+   VERIFY( b2 == false );
+ 
    iss3.str("blah");
    iss3.setf(ios_base::boolalpha);
    err = ios_base::goodbit;
*************** void test01()
*** 100,105 ****
--- 123,136 ----
    VERIFY( err == ios_base::failbit );
    VERIFY( b3 == false );
    VERIFY( *end == 'b' );
+ 
+   iss3.str("");
+   iss3.clear();
+   b3 = true;
+   err = ios_base::goodbit;
+   end = ng3.get(iss3.rdbuf(), 0, iss3, err, b3);
+   VERIFY( err == ios_base::failbit );
+   VERIFY( b3 == false );
  }
  
  int main()

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]