This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[Patch] FIx libstdc++/9826


Hi!

This one too, seems quite uncontroversial: we where passing
an int_type to __ctype.is.

Unrelated, spotted a case where we assigned an int_type to
a char_type.

Tested x86-linux.

Ok trunk and 3.3?

Paolo.

/////////
2003-02-25  Paolo Carlini  <pcarlini at unitus dot it>

	PR libstdc++/9826
	* include/bits/istream.tcc (operator>>(_CharT*),
	operator>>(basic_string&), ws): Pass a char_type to __ctype.is.
	* testsuite/27_io/stringstream.cc (test02): Add.

	* include/bits/istream.tcc (operator>>(_CharT*)):
	Assign a char_type to *__s.

diff -urN libstdc++-v3-orig/include/bits/istream.tcc libstdc++-v3/include/bits/istream.tcc
--- libstdc++-v3-orig/include/bits/istream.tcc	2003-02-16 12:22:29.000000000 +0100
+++ libstdc++-v3/include/bits/istream.tcc	2003-02-25 20:58:45.000000000 +0100
@@ -1036,9 +1036,9 @@
 	      
 	      while (__extracted < __num - 1 
 		     && !_Traits::eq_int_type(__c, __eof)
-		     && !__ctype.is(ctype_base::space, __c))
+		     && !__ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
 		{
-		  *__s++ = __c;
+		  *__s++ = _Traits::to_char_type(__c);
 		  ++__extracted;
 		  __c = __sb->snextc();
 		}
@@ -1081,7 +1081,7 @@
       __int_type __c = __sb->sgetc();
 
       while (!_Traits::eq_int_type(__c, __eof) 
-	     && __ctype.is(ctype_base::space, __c))
+	     && __ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
 	__c = __sb->snextc();
 
        if (_Traits::eq_int_type(__c, __eof))
@@ -1119,7 +1119,7 @@
 	  
 	  while (__extracted < __n 
 		 && !_Traits::eq_int_type(__c, __eof)
-		 && !__ctype.is(ctype_base::space, __c))
+		 && !__ctype.is(ctype_base::space, _Traits::to_char_type(__c)))
 	    {
 	      __str += _Traits::to_char_type(__c);
 	      ++__extracted;
diff -urN libstdc++-v3-orig/testsuite/27_io/stringstream.cc libstdc++-v3/testsuite/27_io/stringstream.cc
--- libstdc++-v3-orig/testsuite/27_io/stringstream.cc	2003-01-14 05:56:55.000000000 +0100
+++ libstdc++-v3/testsuite/27_io/stringstream.cc	2003-02-25 20:48:37.000000000 +0100
@@ -56,8 +56,26 @@
   template class basic_stringstream<pod_char, char_traits<pod_char> >;
 } // test
 
+// libstdc++/9826
+void test02()
+{
+  using namespace std;
+  using __gnu_cxx_test::pod_char;
+
+  basic_stringstream<pod_char, char_traits<pod_char> > sstream;
+  // 1
+  basic_string<pod_char, char_traits<pod_char> > str;
+  sstream >> str;
+  // 2
+  pod_char chr;
+  sstream >> chr;
+  // 3
+  sstream >> ws;
+}
+
 int main() 
 {
   test01();
+  test02();
   return 0;
 }

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