diff --git a/src/search.cpp b/src/search.cpp index ddc227c..9cbdbf5 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -136,6 +136,8 @@ void cleanup_text(string &text) size_t pos{}; while ((pos = text.find('<', pos)) != string::npos) { + auto endpos{text.find('>', pos) + 1}; + // Mark headlines. We need them later on. string replacement; if (boost::regex_match(text.substr(pos, 3), re_header_start)) @@ -148,13 +150,11 @@ void cleanup_text(string &text) } else if (text.substr(pos, 6) == "')}; - boost::match_results match; using it_size_t = string::const_iterator::difference_type; string::const_iterator begin{text.begin() + static_cast(pos)}; - string::const_iterator end{text.end() + string::const_iterator end{text.begin() + static_cast(endpos)}; if (boost::regex_search(begin, end, match, re_pagebreak)) @@ -168,7 +168,7 @@ void cleanup_text(string &text) pos = text.find('>', pos) + 1; } - text.replace(pos, text.find('>', pos) + 1 - pos, replacement); + text.replace(pos, endpos - pos, replacement); pos += replacement.length(); }