From 08190bbe9665b75c73453e75bd61579b18532634 Mon Sep 17 00:00:00 2001 From: Udo Hoffmann Date: Wed, 14 Oct 2020 14:47:00 +0200 Subject: [PATCH] Fix RegEx look behind operations and \A and and \b and \z Fix #713, fix #1870, fix #2216, fix #2360, fix #9004, fix #4855, close #8926, close #9008 --- PowerEditor/installer/functionList/python.xml | 6 +++--- PowerEditor/installer/functionList/ruby.xml | 6 +++--- scintilla/boostregex/BoostRegExSearch.cxx | 13 +++---------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/PowerEditor/installer/functionList/python.xml b/PowerEditor/installer/functionList/python.xml index a0123534..3941bb94 100644 --- a/PowerEditor/installer/functionList/python.xml +++ b/PowerEditor/installer/functionList/python.xml @@ -16,13 +16,13 @@ commentExpr="(?s:'''.*?''')|(?m-s:#.*?$)" > @@ -30,7 +30,7 @@ diff --git a/PowerEditor/installer/functionList/ruby.xml b/PowerEditor/installer/functionList/ruby.xml index 14b8e8d1..f901a5b7 100644 --- a/PowerEditor/installer/functionList/ruby.xml +++ b/PowerEditor/installer/functionList/ruby.xml @@ -16,7 +16,7 @@ > @@ -25,7 +25,7 @@ mainExpr="^\s*def\s+\w+" > - + @@ -34,7 +34,7 @@ mainExpr="^\s*def\s+\w+" > - + diff --git a/scintilla/boostregex/BoostRegExSearch.cxx b/scintilla/boostregex/BoostRegExSearch.cxx index d4c9641b..40f60c2c 100644 --- a/scintilla/boostregex/BoostRegExSearch.cxx +++ b/scintilla/boostregex/BoostRegExSearch.cxx @@ -288,13 +288,8 @@ Sci::Position BoostRegexSearch::FindText(Document* doc, Sci::Position startPosit regex_constants::ECMAScript | (caseSensitive ? 0 : regex_constants::icase); search._regexString = regexString; - - const bool starts_at_line_start = search.isLineStart(search._startPosition); - const bool ends_at_line_end = search.isLineEnd(search._endPosition); search._boostRegexFlags = - (starts_at_line_start ? regex_constants::match_default : regex_constants::match_not_bol) - | (ends_at_line_end ? regex_constants::match_default : regex_constants::match_not_eol) - | ((sciSearchFlags & SCFIND_REGEXP_DOTMATCHESNL) ? regex_constants::match_default : regex_constants::match_not_dot_newline); + ((sciSearchFlags & SCFIND_REGEXP_DOTMATCHESNL) ? regex_constants::match_default : regex_constants::match_not_dot_newline); const int empty_match_style = sciSearchFlags & SCFIND_REGEXP_EMPTYMATCH_MASK; const int allow_empty_at_start = sciSearchFlags & SCFIND_REGEXP_EMPTYMATCH_ALLOWATSTART; @@ -344,15 +339,13 @@ template BoostRegexSearch::Match BoostRegexSearch::EncodingDependent::FindTextForward(SearchParameters& search) { CharacterIterator endIterator(search._document, search._endPosition, search._endPosition); + CharacterIterator baseIterator(search._document, 0, search._endPosition); Sci::Position next_search_from_position = search._startPosition; bool found = false; bool match_is_valid = false; do { - search._boostRegexFlags = search.isLineStart(next_search_from_position) - ? search._boostRegexFlags & ~regex_constants::match_not_bol - : search._boostRegexFlags | regex_constants::match_not_bol; const bool end_reached = next_search_from_position > search._endPosition; - found = !end_reached && boost::regex_search(CharacterIterator(search._document, next_search_from_position, search._endPosition), endIterator, _match, _regex, search._boostRegexFlags); + found = !end_reached && boost::regex_search(CharacterIterator(search._document, next_search_from_position, search._endPosition), endIterator, _match, _regex, search._boostRegexFlags, baseIterator); if (found) { const Sci::Position position = _match[0].first.pos(); const Sci::Position length = _match[0].second.pos() - position;