re PR libstdc++/8258 (basic_istream::readsome() with default buffer change stream state to ios_base::eofbit)
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. From-SVN: r58840
This commit is contained in:
parent
81646a3157
commit
112615e7d3
@ -1,3 +1,13 @@
|
||||
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.
|
||||
|
||||
2002-11-05 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
PR libstdc++/8466
|
||||
@ -11,7 +21,7 @@
|
||||
|
||||
* configure.target (hppa*): Define cpu_include_dir.
|
||||
* config/os/hpux/os_defines.h (_GLIBCPP_INST_ATOMICITY_LOCK): Define.
|
||||
* src/misc-inst.cc (std): Instantiate atomicity lock when
|
||||
* src/misc-inst.cc: Instantiate atomicity lock when
|
||||
_GLIBCPP_INST_ATOMICITY_LOCK is defined.
|
||||
* config/cpu/hppa/atomicity.h: New file.
|
||||
|
||||
|
@ -811,8 +811,9 @@ namespace std
|
||||
{
|
||||
try
|
||||
{
|
||||
// Cannot compare int_type with streamsize generically.
|
||||
streamsize __num = this->rdbuf()->in_avail();
|
||||
if (__num > 0)
|
||||
if (__num >= 0)
|
||||
{
|
||||
__num = min(__num, __n);
|
||||
if (__num)
|
||||
@ -1034,13 +1035,14 @@ namespace std
|
||||
int_type __c = __sb->sgetc();
|
||||
|
||||
while (__extracted < __num - 1
|
||||
&& __c != __eof && !__ctype.is(ctype_base::space, __c))
|
||||
&& !_Traits::eq_int_type(__c, __eof)
|
||||
&& !__ctype.is(ctype_base::space, __c))
|
||||
{
|
||||
*__s++ = __c;
|
||||
++__extracted;
|
||||
__c = __sb->snextc();
|
||||
}
|
||||
if (__c == __eof)
|
||||
if (_Traits::eq_int_type(__c, __eof))
|
||||
__in.setstate(ios_base::eofbit);
|
||||
|
||||
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
||||
@ -1078,9 +1080,11 @@ namespace std
|
||||
__streambuf_type* __sb = __in.rdbuf();
|
||||
__int_type __c = __sb->sgetc();
|
||||
|
||||
while (__c != __eof && __ctype.is(ctype_base::space, __c))
|
||||
while (!_Traits::eq_int_type(__c, __eof)
|
||||
&& __ctype.is(ctype_base::space, __c))
|
||||
__c = __sb->snextc();
|
||||
if (__c == __eof)
|
||||
|
||||
if (_Traits::eq_int_type(__c, __eof))
|
||||
__in.setstate(ios_base::eofbit);
|
||||
|
||||
return __in;
|
||||
@ -1114,13 +1118,14 @@ namespace std
|
||||
__int_type __c = __sb->sgetc();
|
||||
|
||||
while (__extracted < __n
|
||||
&& __c != __eof && !__ctype.is(ctype_base::space, __c))
|
||||
&& !_Traits::eq_int_type(__c, __eof)
|
||||
&& !__ctype.is(ctype_base::space, __c))
|
||||
{
|
||||
__str += _Traits::to_char_type(__c);
|
||||
++__extracted;
|
||||
__c = __sb->snextc();
|
||||
}
|
||||
if (__c == __eof)
|
||||
if (_Traits::eq_int_type(__c, __eof))
|
||||
__in.setstate(ios_base::eofbit);
|
||||
__in.width(0);
|
||||
}
|
||||
|
@ -551,6 +551,25 @@ test10()
|
||||
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()
|
||||
{
|
||||
@ -564,6 +583,6 @@ main()
|
||||
test08();
|
||||
test09();
|
||||
test10();
|
||||
|
||||
test11();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user