Opened 10 years ago
Closed 9 years ago
#7784 closed Bugs (invalid)
[PATCH] Overlapping strings are not properly handled by string::algo::find_all
Reported by: | Owned by: | Marshall Clow | |
---|---|---|---|
Milestone: | To Be Determined | Component: | string_algo |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Cc: |
Description
See attached test case. There should be two matches in the following test case, one at index 0 and one at index 1, but boost::string::algorithm::find_all only finds one at index 0. I suspect the bug is that the string match erroneously restarts from the end of the previous match, not from beginning of the previous match + 1.
Attachments (1)
Change History (8)
by , 10 years ago
Attachment: | OverlappingStringTest.cpp added |
---|
comment:1 by , 10 years ago
Patch which I believe fixes this:
Index: boost-trunk/boost/algorithm/string/find_iterator.hpp =================================================================== --- boost-trunk/boost/algorithm/string/find_iterator.hpp (revision 82112) +++ boost-trunk/boost/algorithm/string/find_iterator.hpp (working copy) @@ -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
comment:2 by , 10 years ago
Summary: | Overlapping strings are not properly handled by string::algo::find_all → [PATCH] Overlapping strings are not properly handled by string::algo::find_all |
---|
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
In [82238] merge fix to release.
comment:5 by , 10 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Marshall, I don't think that this patch should have been applied. I believe that the library is intended to return non-overlapping matches. Rationale: (1) find_all is in split.hpp, the documentation says: "Split algorithms can be used to divide a string into several parts...." (2) For the sake of consistency, find_all, replace_all, and erase_all, should all use the same set of matches. The patch breaks this. (3) boost::regex_iterator also finds non-overlapping matches.
comment:6 by , 9 years ago
This fix broke other stuff. See #9063.
I'm considering reverting it.
If you have objections, now would be a good time to speak up.
comment:7 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
No one complained.
Reverting this.
Overlapping String Test Case