Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68779 - in trunk: boost/iostreams/detail/adapter libs/iostreams/test
From: steven_at_[hidden]
Date: 2011-02-11 11:18:34


Author: steven_watanabe
Date: 2011-02-11 11:18:33 EST (Fri, 11 Feb 2011)
New Revision: 68779
URL: http://svn.boost.org/trac/boost/changeset/68779

Log:
Fix flush regression. Fixes #4590.
Added:
   trunk/libs/iostreams/test/filtering_stream_flush_test.hpp (contents, props changed)
Text files modified:
   trunk/boost/iostreams/detail/adapter/concept_adapter.hpp | 5 ++++-
   trunk/libs/iostreams/test/filtering_stream_test.cpp | 2 ++
   2 files changed, 6 insertions(+), 1 deletions(-)

Modified: trunk/boost/iostreams/detail/adapter/concept_adapter.hpp
==============================================================================
--- trunk/boost/iostreams/detail/adapter/concept_adapter.hpp (original)
+++ trunk/boost/iostreams/detail/adapter/concept_adapter.hpp 2011-02-11 11:18:33 EST (Fri, 11 Feb 2011)
@@ -106,7 +106,10 @@
     template<typename Device>
     bool flush( Device* dev )
     {
- return any_impl::flush(t_, dev);
+ bool result = any_impl::flush(t_, dev);
+ if (dev && dev->BOOST_IOSTREAMS_PUBSYNC() == -1)
+ result = false;
+ return result;
     }
 
     template<typename Locale> // Avoid dependency on <locale>

Added: trunk/libs/iostreams/test/filtering_stream_flush_test.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/iostreams/test/filtering_stream_flush_test.hpp 2011-02-11 11:18:33 EST (Fri, 11 Feb 2011)
@@ -0,0 +1,36 @@
+// (C) Copyright 2011 Steven Watanabe
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+
+// See http://www.boost.org/libs/iostreams for documentation.
+
+#include <fstream>
+#include <boost/iostreams/filtering_stream.hpp>
+#include <boost/test/test_tools.hpp>
+#include "detail/sequence.hpp"
+#include "detail/temp_file.hpp"
+#include "detail/verification.hpp"
+
+void test_filtering_ostream_flush()
+{
+ using namespace std;
+ using namespace boost;
+ using namespace boost::iostreams;
+ using namespace boost::iostreams::test;
+
+ lowercase_file lower;
+
+ {
+ temp_file dest;
+ filtering_ostream out;
+ out.push(tolower_filter());
+ out.push(file_sink(dest.name(), out_mode));
+ write_data_in_chars(out);
+ out.flush();
+ BOOST_CHECK_MESSAGE(
+ compare_files(dest.name(), lower.name()),
+ "failed writing to a filtering_ostream in chars with an "
+ "output filter"
+ );
+ }
+}

Modified: trunk/libs/iostreams/test/filtering_stream_test.cpp
==============================================================================
--- trunk/libs/iostreams/test/filtering_stream_test.cpp (original)
+++ trunk/libs/iostreams/test/filtering_stream_test.cpp 2011-02-11 11:18:33 EST (Fri, 11 Feb 2011)
@@ -23,6 +23,7 @@
 #include "write_bidir_filter_test.hpp"
 #include "seek_test.hpp"
 #include "putback_test.hpp"
+#include "filtering_stream_flush_test.hpp"
 
 using boost::unit_test::test_suite;
 
@@ -46,5 +47,6 @@
     test->add(BOOST_TEST_CASE(&write_bidirectional_filter_test));
     test->add(BOOST_TEST_CASE(&seek_test));
     test->add(BOOST_TEST_CASE(&putback_test));
+ test->add(BOOST_TEST_CASE(&test_filtering_ostream_flush));
     return test;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk