From 37b8790ed92a09896f9a8ad06bddf8a3d156ca0e Mon Sep 17 00:00:00 2001 From: paolo Date: Tue, 11 Jan 2005 23:35:43 +0000 Subject: 2005-01-11 Paolo Carlini Benjamin Kosnik * src/istream.cc (basic_istream::ignore(streamsize), basic_istream::ignore(streamsize, int_type), basic_istream::ignore(streamsize), basic_istream::ignore(streamsize, int_type)): In case more than numeric_limits::max() chars are skipped, set _M_gcount = max(). * include/bits/istream.tcc (ignore(streamsize), ignore(streamsize, int_type)): Likewise; keep simple, don't forward. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@93208 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/src/istream.cc | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'libstdc++-v3/src') diff --git a/libstdc++-v3/src/istream.cc b/libstdc++-v3/src/istream.cc index e3a36490283..2ecd948585a 100644 --- a/libstdc++-v3/src/istream.cc +++ b/libstdc++-v3/src/istream.cc @@ -125,6 +125,7 @@ namespace std int_type __c = __sb->sgetc(); // See comment in istream.tcc. + bool __large_ignore = false; while (true) { while (_M_gcount < __n @@ -147,11 +148,17 @@ namespace std } if (__n == numeric_limits::max() && !traits_type::eq_int_type(__c, __eof)) - _M_gcount = numeric_limits::min(); + { + _M_gcount = numeric_limits::min(); + __large_ignore = true; + } else break; } + if (__large_ignore) + _M_gcount = numeric_limits::max(); + if (traits_type::eq_int_type(__c, __eof)) __err |= ios_base::eofbit; } @@ -183,6 +190,7 @@ namespace std __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); + bool __large_ignore = false; while (true) { while (_M_gcount < __n @@ -212,16 +220,23 @@ namespace std if (__n == numeric_limits::max() && !traits_type::eq_int_type(__c, __eof) && !traits_type::eq_int_type(__c, __delim)) - _M_gcount = numeric_limits::min(); + { + _M_gcount = numeric_limits::min(); + __large_ignore = true; + } else break; } + if (__large_ignore) + _M_gcount = numeric_limits::max(); + if (traits_type::eq_int_type(__c, __eof)) __err |= ios_base::eofbit; else if (traits_type::eq_int_type(__c, __delim)) { - ++_M_gcount; + if (_M_gcount < numeric_limits::max()) + ++_M_gcount; __sb->sbumpc(); } } @@ -403,6 +418,7 @@ namespace std __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); + bool __large_ignore = false; while (true) { while (_M_gcount < __n @@ -425,11 +441,17 @@ namespace std } if (__n == numeric_limits::max() && !traits_type::eq_int_type(__c, __eof)) - _M_gcount = numeric_limits::min(); + { + _M_gcount = numeric_limits::min(); + __large_ignore = true; + } else break; } + if (__large_ignore) + _M_gcount = numeric_limits::max(); + if (traits_type::eq_int_type(__c, __eof)) __err |= ios_base::eofbit; } @@ -461,6 +483,7 @@ namespace std __streambuf_type* __sb = this->rdbuf(); int_type __c = __sb->sgetc(); + bool __large_ignore = false; while (true) { while (_M_gcount < __n @@ -490,16 +513,23 @@ namespace std if (__n == numeric_limits::max() && !traits_type::eq_int_type(__c, __eof) && !traits_type::eq_int_type(__c, __delim)) - _M_gcount = numeric_limits::min(); + { + _M_gcount = numeric_limits::min(); + __large_ignore = true; + } else break; } + if (__large_ignore) + _M_gcount = numeric_limits::max(); + if (traits_type::eq_int_type(__c, __eof)) __err |= ios_base::eofbit; else if (traits_type::eq_int_type(__c, __delim)) { - ++_M_gcount; + if (_M_gcount < numeric_limits::max()) + ++_M_gcount; __sb->sbumpc(); } } -- cgit v1.2.1