From b44dff3a5bd07a534aa9885b64b80e9fcc57338b Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 8 Oct 2013 17:59:44 +0000 Subject: [PATCH] Revert to old behavior for find_iterator; will not find overlapping matches. Fixes #9063 [SVN r86206] --- .../boost/algorithm/string/find_iterator.hpp | 7 +---- string/test/find_test.cpp | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/include/boost/algorithm/string/find_iterator.hpp b/include/boost/algorithm/string/find_iterator.hpp index bba1748..1502c7d 100644 --- a/include/boost/algorithm/string/find_iterator.hpp +++ b/include/boost/algorithm/string/find_iterator.hpp @@ -132,12 +132,7 @@ namespace boost { // increment void increment() { - if(m_Match.begin() == m_Match.end()) - m_Match=this->do_find(m_Match.end(),m_End); - else { - input_iterator_type last = m_Match.begin(); - m_Match=this->do_find(++last,m_End); - } + m_Match=this->do_find(m_Match.end(),m_End); } // comparison diff --git a/string/test/find_test.cpp b/string/test/find_test.cpp index 85facb0..66d9337 100644 --- a/string/test/find_test.cpp +++ b/string/test/find_test.cpp @@ -181,6 +181,21 @@ void find_test() ( (cv_result.begin()-str1.begin()) == 3) && ( (cv_result.end()-str1.begin()) == 6) ); + string s1("abc def ghi jkl"); + find_iterator fEnd; + + find_iterator fxIt = make_find_iterator(s1, + token_finder(is_alnum(), token_compress_on)); + BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("abc"))); + ++fxIt; + BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("def"))); + ++fxIt; + BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("ghi"))); + ++fxIt; + BOOST_CHECK((fxIt != fEnd) && (*fxIt == string("jkl"))); + ++fxIt; + BOOST_CHECK(fxIt == fEnd); + nc_result=find_token( str1, is_any_of("abc"), token_compress_off ); BOOST_CHECK( ( (nc_result.begin()-str1.begin()) == 3) && @@ -251,19 +266,6 @@ void find_test() osstr << find_first( str1, "abc" ); BOOST_CHECK( osstr.str()=="abc" ); - // Empty string test - BOOST_TEST_CHECKPOINT( "overlapping" ); - - std::string overlap_target("aaaa"); - std::vector > 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