From 9067b387ef8ff6d70d79513865b26adc6a9f85fd Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 6 Jun 2021 15:50:13 +0200 Subject: [PATCH] Fix pagebreak-iterators. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Oopsie! 😄 --- src/search.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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(); }