|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82117 - in trunk: boost/algorithm/string libs/algorithm/string/test
From: marshall_at_[hidden]
Date: 2012-12-20 10:53:00
Author: marshall
Date: 2012-12-20 10:52:59 EST (Thu, 20 Dec 2012)
New Revision: 82117
URL: http://svn.boost.org/trac/boost/changeset/82117
Log:
Fixed bug in boost::algorithm::find_all with overlapping results; thanks to cedstrom for the report and the patch; Refs #7784
Text files modified:
trunk/boost/algorithm/string/find_iterator.hpp | 5 ++++-
trunk/libs/algorithm/string/test/find_test.cpp | 15 +++++++++++++++
2 files changed, 19 insertions(+), 1 deletions(-)
Modified: trunk/boost/algorithm/string/find_iterator.hpp
==============================================================================
--- trunk/boost/algorithm/string/find_iterator.hpp (original)
+++ trunk/boost/algorithm/string/find_iterator.hpp 2012-12-20 10:52:59 EST (Thu, 20 Dec 2012)
@@ -132,7 +132,10 @@
// increment
void increment()
{
- m_Match=this->do_find(m_Match.end(),m_End);
+ if(m_Match.begin() == m_Match.end())
+ m_Match=this->do_find(m_Match.end(),m_End);
+ else
+ m_Match=this->do_find(m_Match.begin()+1,m_End);
}
// comparison
Modified: trunk/libs/algorithm/string/test/find_test.cpp
==============================================================================
--- trunk/libs/algorithm/string/test/find_test.cpp (original)
+++ trunk/libs/algorithm/string/test/find_test.cpp 2012-12-20 10:52:59 EST (Thu, 20 Dec 2012)
@@ -9,6 +9,7 @@
#include <boost/algorithm/string/find.hpp>
#include <boost/algorithm/string/classification.hpp>
+#include <boost/algorithm/string/split.hpp>
// Include unit test framework
#include <boost/test/included/test_exec_monitor.hpp>
@@ -248,6 +249,20 @@
ostringstream osstr;
osstr << find_first( str1, "abc" );
BOOST_CHECK( osstr.str()=="abc" );
+
+ // Empty string test
+ BOOST_CHECKPOINT( "overlapping" );
+
+ std::string overlap_target("aaaa");
+ std::vector<boost::iterator_range<std::string::iterator> > overlap_results;
+ boost::algorithm::find_all(overlap_results, overlap_target, string("aaa"));
+ BOOST_CHECK( overlap_results.size() == 2 );
+
+ std::string overlap_target2("aaaabbbbaaaa");
+ boost::algorithm::find_all(overlap_results, overlap_target2, string("bb"));
+ BOOST_CHECK( overlap_results.size() == 3 );
+ boost::algorithm::find_all(overlap_results, overlap_target2, string("aa"));
+ BOOST_CHECK( overlap_results.size() == 6 );
}
// test main
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