From 3943c0780cdf0da0d12bbf8b26710a6e1a907f9c Mon Sep 17 00:00:00 2001 From: bkoz Date: Mon, 22 Apr 2002 19:10:02 +0000 Subject: [PATCH] 2002-04-22 Benjamin Kosnik * include/bits/istream.tcc (istream::read): Fix. * testsuite/27_io/istream_unformatted.cc (main): Add. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52628 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/bits/istream.tcc | 13 ++----------- libstdc++-v3/testsuite/27_io/istream_unformatted.cc | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6550006a583..3ac23e5fcf2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2002-04-22 Benjamin Kosnik + + * include/bits/istream.tcc (istream::read): Fix. + * testsuite/27_io/istream_unformatted.cc (main): Add. + 2002-04-20 Benjamin Kosnik PR libstdc++/6360 diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index a55e9063268..636a7386359 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -777,17 +777,8 @@ namespace std { try { - const int_type __eof = traits_type::eof(); - __streambuf_type* __sb = this->rdbuf(); - int_type __c = __sb->sgetc(); - - while (_M_gcount < __n && __c != __eof) - { - *__s++ = traits_type::to_char_type(__c); - ++_M_gcount; - __c = __sb->snextc(); - } - if (__c == __eof) + _M_gcount = this->rdbuf()->sgetn(__s, __n); + if (_M_gcount != __n) this->setstate(ios_base::eofbit | ios_base::failbit); } catch(exception& __fail) diff --git a/libstdc++-v3/testsuite/27_io/istream_unformatted.cc b/libstdc++-v3/testsuite/27_io/istream_unformatted.cc index bf25be8992a..da2cdeb739e 100644 --- a/libstdc++-v3/testsuite/27_io/istream_unformatted.cc +++ b/libstdc++-v3/testsuite/27_io/istream_unformatted.cc @@ -499,6 +499,20 @@ test08() VERIFY( c == 'i' ); } +// Theodore Papadopoulo +void +test09() +{ + using namespace std; + bool test = true; + + istringstream iss("Juana Briones"); + char tab[13]; + iss.read(tab, 13); + if (!iss) + test = false; + VERIFY( test ); +} int main() @@ -511,6 +525,7 @@ main() test06(); test07(); test08(); + test09(); return 0; } -- 2.11.4.GIT