From 325fceb395f8d9bdb1970f378c5a6aed4c36b968 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Thu, 25 Jul 2002 23:20:49 +0000 Subject: [PATCH] re PR libstdc++/7220 (g++ 3.1: basic_istream::ignore(0,delimiter) issue.) 2002-07-25 Benjamin Kosnik PR libstdc++/7220 * include/bits/istream.tcc (istream::ignore): Don't extract on zero. * testsuite/27_io/istream_unformatted.cc (test10): Add. From-SVN: r55763 --- libstdc++-v3/ChangeLog | 7 ++++ libstdc++-v3/include/bits/istream.tcc | 2 +- .../testsuite/27_io/istream_unformatted.cc | 38 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d2e5e268078..b3c52e445f5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2002-07-25 Benjamin Kosnik + + PR libstdc++/7220 + * include/bits/istream.tcc (istream::ignore): Don't extract on + zero. + * testsuite/27_io/istream_unformatted.cc (test10): Add. + 2002-07-25 Benjamin Kosnik * testsuite/27_io/ios_base_type.cc: Move to... diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 2658866ec57..fc0adea69e3 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -708,7 +708,7 @@ namespace std { _M_gcount = 0; sentry __cerb(*this, true); - if (__cerb) + if (__cerb && __n > 0) { try { diff --git a/libstdc++-v3/testsuite/27_io/istream_unformatted.cc b/libstdc++-v3/testsuite/27_io/istream_unformatted.cc index da2cdeb739e..0e98dced108 100644 --- a/libstdc++-v3/testsuite/27_io/istream_unformatted.cc +++ b/libstdc++-v3/testsuite/27_io/istream_unformatted.cc @@ -514,6 +514,43 @@ test09() VERIFY( test ); } +// libstdc++/70220 +void +test10() +{ + using namespace std; + bool test = true; + typedef string string_type; + typedef stringbuf stringbuf_type; + typedef istream istream_type; + + int res = 0; + streamsize n; + string_type input("abcdefg\n"); + stringbuf_type sbuf(input); + istream_type istr(&sbuf); + + istr.ignore(0); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(0, 'b'); + if (istr.gcount() != 0) + test = false; + VERIFY( test ); + + istr.ignore(); // Advance to next position. + istr.ignore(0, 'b'); + if ((n=istr.gcount()) != 0) + test = false; + VERIFY( test ); + + if (istr.peek() != 'b') + test = false; + VERIFY( test ); +} + int main() { @@ -526,6 +563,7 @@ main() test07(); test08(); test09(); + test10(); return 0; } -- 2.30.2