This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] Fix libstdc++/9826
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Paolo Carlini <pcarlini at unitus dot it>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, bkoz <bkoz at redhat dot com>
- Date: Tue, 25 Feb 2003 22:04:52 +0100
- Subject: Re: [Patch] Fix libstdc++/9826
- References: <3E5BD089.7050902@unitus.it>
... sorry: the previous patch has a typo in the 3rd testcase.
The below is the right one.
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 22:00:40.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;
}