From 1e156882fad89fc2661abdf85e64a62d51815668 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 5 Jan 2005 11:11:48 +0000 Subject: istream.cc (basic_istream::ignore(streamsize), [...]): At the end, first check _M_gcount vs __n. 2005-01-05 Paolo Carlini * src/istream.cc (basic_istream::ignore(streamsize), basic_istream::ignore(streamsize, int_type), basic_istream::ignore(streamsize), basic_istream::ignore(streamsize, int_type)): At the end, first check _M_gcount vs __n. * include/bits/istream.tcc (ignore(streamsize), ignore(streamsize, int_type)): Likewise. * testsuite/27_io/basic_istream/ignore/char/4.cc: New. * testsuite/27_io/basic_istream/ignore/wchar_t/4.cc: Likewise. From-SVN: r92947 --- libstdc++-v3/src/istream.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'libstdc++-v3/src') diff --git a/libstdc++-v3/src/istream.cc b/libstdc++-v3/src/istream.cc index 5bdcaaf..dc99051 100644 --- a/libstdc++-v3/src/istream.cc +++ b/libstdc++-v3/src/istream.cc @@ -123,7 +123,8 @@ namespace std const int_type __eof = traits_type::eof(); __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); - + + // See comment in istream.tcc. while (true) { while (_M_gcount < __n @@ -151,7 +152,7 @@ namespace std break; } - if (traits_type::eq_int_type(__c, __eof)) + if (_M_gcount < __n) __err |= ios_base::eofbit; } catch(...) @@ -216,9 +217,11 @@ namespace std break; } - if (traits_type::eq_int_type(__c, __eof)) + if (_M_gcount == __n) + ; + else if (traits_type::eq_int_type(__c, __eof)) __err |= ios_base::eofbit; - else if (traits_type::eq_int_type(__c, __delim)) + else { ++_M_gcount; __sb->sbumpc(); @@ -429,7 +432,7 @@ namespace std break; } - if (traits_type::eq_int_type(__c, __eof)) + if (_M_gcount < __n) __err |= ios_base::eofbit; } catch(...) @@ -494,9 +497,11 @@ namespace std break; } - if (traits_type::eq_int_type(__c, __eof)) + if (_M_gcount == __n) + ; + else if (traits_type::eq_int_type(__c, __eof)) __err |= ios_base::eofbit; - else if (traits_type::eq_int_type(__c, __delim)) + else { ++_M_gcount; __sb->sbumpc(); -- cgit v1.1