From 96cbf48b356f055114db997b653cf08cdf8a7535 Mon Sep 17 00:00:00 2001 From: Brent Verner Date: Tue, 13 Jun 2000 22:20:56 +0000 Subject: [PATCH] streambuf.tcc: repaired _S_copy_streambufs() 2000-06-13 Brent Verner * bits/streambuf.tcc: repaired _S_copy_streambufs() * testsuite/27_io/ostream_inserter_other.cc (test03): Added testcase. From-SVN: r34528 --- libstdc++-v3/ChangeLog | 5 ++ libstdc++-v3/bits/streambuf.tcc | 1 + .../testsuite/27_io/ostream_inserter_other.cc | 49 +++++++++++++++++-- 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c0b73b61946..688b84b675a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2000-06-13 Brent Verner + + * bits/streambuf.tcc: repaired _S_copy_streambufs() + * testsuite/27_io/ostream_inserter_other.cc (test03): Added testcase. + 2000-06-12 Benjamin Kosnik * bits/locale_facets.h (ctype): Remove unnecessary data diff --git a/libstdc++-v3/bits/streambuf.tcc b/libstdc++-v3/bits/streambuf.tcc index 924ddb0bcc8..d5ed76db67a 100644 --- a/libstdc++-v3/bits/streambuf.tcc +++ b/libstdc++-v3/bits/streambuf.tcc @@ -239,6 +239,7 @@ namespace std { __ios.setstate(ios_base::eofbit); break; } + __bufsize = __sbin->in_avail(); } else break; diff --git a/libstdc++-v3/testsuite/27_io/ostream_inserter_other.cc b/libstdc++-v3/testsuite/27_io/ostream_inserter_other.cc index cbe99ede2cc..12c9e8bd039 100644 --- a/libstdc++-v3/testsuite/27_io/ostream_inserter_other.cc +++ b/libstdc++-v3/testsuite/27_io/ostream_inserter_other.cc @@ -1,7 +1,7 @@ // 1999-08-16 bkoz // 1999-11-01 bkoz -// Copyright (C) 1999 Free Software Foundation +// Copyright (C) 1999, 2000 Free Software Foundation // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -90,10 +90,51 @@ bool test02() { return test; } -int main() +// via Brent Verner +// http://sourceware.cygnus.com/ml/libstdc++/2000-06/msg00005.html +int +test03(void) { - test01(); - test02(); + using namespace std; + + typedef ios::pos_type pos_type; + + const char* TEST_IN = "testsuite/ostream_inserter_other_in"; + const char* TEST_OUT = "testsuite/ostream_inserter_other_out"; + pos_type i_read, i_wrote, rs, ws; + double tf_size = BUFSIZ * 2.5; + ofstream testfile(TEST_IN); + + for ( int i=0; i < tf_size; ++i ) + testfile.put('.'); + testfile.close(); + + ifstream in(TEST_IN); + ofstream out(TEST_OUT); + out << in.rdbuf(); + in.seekg(0,ios_base::beg); + out.seekp(0,ios_base::beg); + rs = in.tellg(); + ws = out.tellp(); + in.seekg(0,ios_base::end); + out.seekp(0,ios_base::end); + i_read = in.tellg() - rs; + i_wrote = out.tellp() - ws; + in.close(); + out.close(); + +#ifdef DEBUG_ASSERT + assert(i_read == i_wrote); +#endif + + return 0; +} + +int main() +{ + test01(); + test02(); + test03(); return 0; }