diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2002-07-25 23:20:49 +0000 |
---|---|---|
committer | Benjamin Kosnik <bkoz@gcc.gnu.org> | 2002-07-25 23:20:49 +0000 |
commit | 325fceb395f8d9bdb1970f378c5a6aed4c36b968 (patch) | |
tree | 4baf9c9e5bf3144ee21fc7a11b360f9bdc080478 | |
parent | e179e7d78e128c13034808a3688f04435294da92 (diff) | |
download | gcc-325fceb395f8d9bdb1970f378c5a6aed4c36b968.zip gcc-325fceb395f8d9bdb1970f378c5a6aed4c36b968.tar.gz gcc-325fceb395f8d9bdb1970f378c5a6aed4c36b968.tar.bz2 |
re PR libstdc++/7220 (g++ 3.1: basic_istream::ignore(0,delimiter) issue.)
2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/istream.tcc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/istream_unformatted.cc | 38 |
3 files changed, 46 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d2e5e26..b3c52e4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2002-07-25 Benjamin Kosnik <bkoz@redhat.com> + 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 <bkoz@redhat.com> + * testsuite/27_io/ios_base_type.cc: Move to... * testsuite/27_io/ios_base_types.cc: ...here. diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 2658866..fc0adea 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 da2cdeb..0e98dce 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; } |