diff options
author | Paolo Carlini <pcarlini@unitus.it> | 2003-02-11 10:59:19 +0100 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2003-02-11 09:59:19 +0000 |
commit | da61d02231ca20ebc788ad86655952cff1781171 (patch) | |
tree | 7fc5c517ef72ddb7d4172de8884f02ee3a4943e2 | |
parent | 194ea9ced6f547f5a6922ff9ac1dfb895262f1a2 (diff) | |
download | gcc-da61d02231ca20ebc788ad86655952cff1781171.zip gcc-da61d02231ca20ebc788ad86655952cff1781171.tar.gz gcc-da61d02231ca20ebc788ad86655952cff1781171.tar.bz2 |
re PR libstdc++/9318 (i/ostream::operator>>/<<(streambuf*) broken)
2003-02-11 Paolo Carlini <pcarlini@unitus.it>
Petur Runolfsson <peturr02@ru.is>
PR libstdc++/9318
* include/bits/streambuf.tcc (__copy_streambufs):
Don't conditionalize the copy to __testput.
* testsuite/27_io/streambuf_members.cc (test09, test10): Add.
Co-Authored-By: Petur Runolfsson <peturr02@ru.is>
From-SVN: r62689
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/streambuf.tcc | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/streambuf_members.cc | 50 |
3 files changed, 58 insertions, 3 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2712b3a..9816498 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2003-02-11 Paolo Carlini <pcarlini@unitus.it> + Petur Runolfsson <peturr02@ru.is> + + PR libstdc++/9318 + * include/bits/streambuf.tcc (__copy_streambufs): + Don't conditionalize the copy to __testput. + * testsuite/27_io/streambuf_members.cc (test09, test10): Add. + 2002-02-11 DJ Delorie <dj@redhat.com> * acinclude.m4: Check for native targets that can't link at diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc index cb6f95d..44ba1d9 100644 --- a/libstdc++-v3/include/bits/streambuf.tcc +++ b/libstdc++-v3/include/bits/streambuf.tcc @@ -203,10 +203,9 @@ namespace std streamsize __ret = 0; streamsize __bufsize = __sbin->in_avail(); streamsize __xtrct; - bool __testput = __sbout->_M_mode & ios_base::out; try { - while (__testput && __bufsize != -1) + while (__bufsize != -1) { if (__bufsize != 0 && __sbin->gptr() != NULL && __sbin->gptr() + __bufsize <= __sbin->egptr()) diff --git a/libstdc++-v3/testsuite/27_io/streambuf_members.cc b/libstdc++-v3/testsuite/27_io/streambuf_members.cc index aaad07d..80f569d 100644 --- a/libstdc++-v3/testsuite/27_io/streambuf_members.cc +++ b/libstdc++-v3/testsuite/27_io/streambuf_members.cc @@ -31,7 +31,7 @@ #include <cstring> // for memset, memcmp #include <streambuf> -#include <string> +#include <sstream> #include <ostream> #include <testsuite_hooks.h> @@ -386,6 +386,51 @@ void test08() VERIFY( ob.getloc() == loc_de ); } +// libstdc++/9318 +class Outbuf : public std::streambuf +{ +public: + typedef std::streambuf::traits_type traits_type; + + std::string result() const { return str; } + +protected: + virtual int_type overflow(int_type c = traits_type::eof()) + { + if (!traits_type::eq_int_type(c, traits_type::eof())) + str.push_back(traits_type::to_char_type(c)); + return traits_type::not_eof(c); + } + +private: + std::string str; +}; + +// <1> +void test09() +{ + bool test = true; + + std::istringstream stream("Bad Moon Rising"); + Outbuf buf; + stream >> &buf; + + VERIFY( buf.result() == "Bad Moon Rising" ); +} + +// <2> +void test10() +{ + bool test = true; + + std::stringbuf sbuf("Bad Moon Rising", std::ios::in); + Outbuf buf; + std::ostream stream(&buf); + stream << &sbuf; + + VERIFY( buf.result() == "Bad Moon Rising" ); +} + int main() { test01(); @@ -397,5 +442,8 @@ int main() test07(); test08(); + + test09(); + test10(); return 0; } |