diff --git a/src/regex.hh b/src/regex.hh index 7fda8f0b1..01d6bc79d 100644 --- a/src/regex.hh +++ b/src/regex.hh @@ -136,6 +136,13 @@ bool regex_search(It begin, It end, MatchResults& res, const Regex& re, return regex_search(begin, end, res.values(), *re.impl(), flags); } +template +bool backward_regex_search(It begin, It end, MatchResults& res, const Regex& re, + RegexExecFlags flags = RegexExecFlags::None) +{ + return regex_search(std::move(begin), std::move(end), res, re, flags); +} + String option_to_string(const Regex& re); void option_from_string(StringView str, Regex& re); @@ -204,8 +211,8 @@ private: } else { - if (not regex_search(m_begin, m_next_pos, m_results, *m_regex, - m_flags | additional_flags)) + if (not backward_regex_search(m_begin, m_next_pos, m_results, *m_regex, + m_flags | additional_flags)) m_regex = nullptr; else m_next_pos = m_results[0].first; diff --git a/src/selectors.cc b/src/selectors.cc index 6074e38cd..63f874da7 100644 --- a/src/selectors.cc +++ b/src/selectors.cc @@ -862,14 +862,14 @@ static bool find_prev(const Buffer& buffer, const BufferIterator& pos, const Regex& ex, bool& wrapped) { if (pos != buffer.begin() and - regex_search( - buffer.begin(), pos, matches, ex, - match_flags(buffer, buffer.begin(), pos) | RegexExecFlags::NotInitialNull)) + backward_regex_search(buffer.begin(), pos, matches, ex, + match_flags(buffer, buffer.begin(), pos) | + RegexExecFlags::NotInitialNull)) return true; wrapped = true; - return regex_search( - buffer.begin(), buffer.end(), matches, ex, - match_flags(buffer, buffer.begin(), buffer.end()) | RegexExecFlags::NotInitialNull); + return backward_regex_search(buffer.begin(), buffer.end(), matches, ex, + match_flags(buffer, buffer.begin(), buffer.end()) | + RegexExecFlags::NotInitialNull); } template