* libstdc++/8258
@ 2002-11-05 15:33 Benjamin Kosnik
0 siblings, 0 replies; only message in thread
From: Benjamin Kosnik @ 2002-11-05 15:33 UTC (permalink / raw)
To: gcc-patches
Ugh. This is the first time that the new 27_io testcases bit me for
making a change that foiled the generic templates. This is a good
thing.
I updated some of the istream bits that had resisted the first
conversion to traits_type::eq_int_type().
tested x86/linux
2002-11-05 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/8258
* include/bits/istream.tcc (istream::readsome): Don't set eofbit
for null buffer.
(istream::operator>>(_CharT*)): Use traits_type.
(istream::ws): Same.
(istream::operator>>(string)): Same.
* testsuite/27_io/istream_unformatted.cc (test11): Add.
Index: include/bits/istream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/istream.tcc,v
retrieving revision 1.35
diff -c -p -r1.35 istream.tcc
*** include/bits/istream.tcc 1 Nov 2002 05:38:27 -0000 1.35
--- include/bits/istream.tcc 5 Nov 2002 23:26:14 -0000
*************** namespace std
*** 811,818 ****
{
try
{
streamsize __num = this->rdbuf()->in_avail();
! if (__num > 0)
{
__num = min(__num, __n);
if (__num)
--- 811,819 ----
{
try
{
+ // Cannot compare int_type with streamsize generically.
streamsize __num = this->rdbuf()->in_avail();
! if (__num >= 0)
{
__num = min(__num, __n);
if (__num)
*************** namespace std
*** 1034,1046 ****
int_type __c = __sb->sgetc();
while (__extracted < __num - 1
! && __c != __eof && !__ctype.is(ctype_base::space, __c))
{
*__s++ = __c;
++__extracted;
__c = __sb->snextc();
}
! if (__c == __eof)
__in.setstate(ios_base::eofbit);
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
--- 1035,1048 ----
int_type __c = __sb->sgetc();
while (__extracted < __num - 1
! && !_Traits::eq_int_type(__c, __eof)
! && !__ctype.is(ctype_base::space, __c))
{
*__s++ = __c;
++__extracted;
__c = __sb->snextc();
}
! if (_Traits::eq_int_type(__c, __eof))
__in.setstate(ios_base::eofbit);
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
*************** namespace std
*** 1078,1086 ****
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
! while (__c != __eof && __ctype.is(ctype_base::space, __c))
__c = __sb->snextc();
! if (__c == __eof)
__in.setstate(ios_base::eofbit);
return __in;
--- 1080,1090 ----
__streambuf_type* __sb = __in.rdbuf();
__int_type __c = __sb->sgetc();
! while (!_Traits::eq_int_type(__c, __eof)
! && __ctype.is(ctype_base::space, __c))
__c = __sb->snextc();
!
! if (_Traits::eq_int_type(__c, __eof))
__in.setstate(ios_base::eofbit);
return __in;
*************** namespace std
*** 1114,1126 ****
__int_type __c = __sb->sgetc();
while (__extracted < __n
! && __c != __eof && !__ctype.is(ctype_base::space, __c))
{
__str += _Traits::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
! if (__c == __eof)
__in.setstate(ios_base::eofbit);
__in.width(0);
}
--- 1118,1131 ----
__int_type __c = __sb->sgetc();
while (__extracted < __n
! && !_Traits::eq_int_type(__c, __eof)
! && !__ctype.is(ctype_base::space, __c))
{
__str += _Traits::to_char_type(__c);
++__extracted;
__c = __sb->snextc();
}
! if (_Traits::eq_int_type(__c, __eof))
__in.setstate(ios_base::eofbit);
__in.width(0);
}
Index: testsuite/27_io/istream_unformatted.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/istream_unformatted.cc,v
retrieving revision 1.18
diff -c -p -r1.18 istream_unformatted.cc
*** testsuite/27_io/istream_unformatted.cc 25 Jul 2002 23:20:49 -0000 1.18
--- testsuite/27_io/istream_unformatted.cc 5 Nov 2002 23:26:14 -0000
*************** test10()
*** 551,556 ****
--- 551,575 ----
VERIFY( test );
}
+
+ // libstdc++/8258
+ class mybuf : public std::basic_streambuf<char>
+ { };
+
+ void test11()
+ {
+ bool test = true;
+ using namespace std;
+ char arr[10];
+ mybuf sbuf;
+ basic_istream<char, char_traits<char> > istr(&sbuf);
+
+ VERIFY(istr.rdstate() == ios_base::goodbit);
+ VERIFY(istr.readsome(arr, 10) == 0);
+ VERIFY(istr.rdstate() == ios_base::goodbit);
+ }
+
+
int
main()
{
*************** main()
*** 564,569 ****
test08();
test09();
test10();
!
return 0;
}
--- 583,588 ----
test08();
test09();
test10();
! test11();
return 0;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-05 23:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-05 15:33 libstdc++/8258 Benjamin Kosnik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).