Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2008-01-24 19:43:56


Author: turkanis
Date: 2008-01-24 19:43:55 EST (Thu, 24 Jan 2008)
New Revision: 42959
URL: http://svn.boost.org/trac/boost/changeset/42959

Log:
fixed Ticket #1139
Text files modified:
   branches/iostreams_dev/boost/iostreams/filter/regex.hpp | 8 ++++++--
   branches/iostreams_dev/libs/iostreams/test/regex_filter_test.cpp | 20 ++++++++++++++++++++
   2 files changed, 26 insertions(+), 2 deletions(-)

Modified: branches/iostreams_dev/boost/iostreams/filter/regex.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/filter/regex.hpp (original)
+++ branches/iostreams_dev/boost/iostreams/filter/regex.hpp 2008-01-24 19:43:55 EST (Thu, 24 Jan 2008)
@@ -57,7 +57,7 @@
                 return;
             iterator first(&src[0], &src[0] + src.size(), re_, flags_);
             iterator last;
- const Ch* suffix = 0; // Prevent GCC 2.95 warning.
+ const Ch* suffix = 0;
             for (; first != last; ++first) {
                 dest.insert( dest.end(),
                              first->prefix().first,
@@ -68,7 +68,11 @@
                              replacement.end() );
                 suffix = first->suffix().first;
             }
- dest.insert(dest.end(), suffix, &src[0] + src.size());
+ if (suffix) {
+ dest.insert(dest.end(), suffix, &src[0] + src.size());
+ } else {
+ dest.insert(dest.end(), &src[0], &src[0] + src.size());
+ }
         }
     struct simple_formatter {
         simple_formatter(const string_type& fmt, flag_type fmt_flags)

Modified: branches/iostreams_dev/libs/iostreams/test/regex_filter_test.cpp
==============================================================================
--- branches/iostreams_dev/libs/iostreams/test/regex_filter_test.cpp (original)
+++ branches/iostreams_dev/libs/iostreams/test/regex_filter_test.cpp 2008-01-24 19:43:55 EST (Thu, 24 Jan 2008)
@@ -144,6 +144,26 @@
             "failed writing to format-string-based regex_filter in chunks"
         );
     }
+
+ {
+ // Note: the ifstream second is placed in a nested scope because
+ // closing and reopening a single ifstream failed for CW 9.4 on Windows.
+
+ // Test reading from a regex filter with no matches; this checks that
+ // Ticket #1139 is fixed
+ boost::regex match_xxx("xxx");
+ test_file test2;
+ filtering_istream
+ first(boost::iostreams::regex_filter(match_xxx, replace_lower()));
+ first.push(file_source(test.name(), in_mode));
+ {
+ ifstream second(test2.name().c_str(), in_mode);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chars(first, second),
+ "failed reading from a regex filter with no matches"
+ );
+ }
+ }
 }
 
 test_suite* init_unit_test_suite(int, char* [])


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