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
This commit is contained in:
Udo Hoffmann 2020-10-14 14:47:00 +02:00 committed by Don HO
parent d62221fd7f
commit 08190bbe96
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
3 changed files with 9 additions and 16 deletions

View File

@ -16,13 +16,13 @@
commentExpr="(?s:'''.*?''')|(?m-s:#.*?$)"
>
<classRange
mainExpr ="(?&lt;=^class\x20).*?(?=\n\S|\Z)"
mainExpr ="^class\x20\K.*?(?=\n\S|\Z)"
>
<className>
<nameExpr expr="\w+(?=\s*[\(|:])" />
</className>
<function
mainExpr="(?&lt;=\sdef\x20).+?(?=:)"
mainExpr="\sdef\x20\K.+?(?=:)"
>
<functionName>
<funcNameExpr expr=".*" />
@ -30,7 +30,7 @@
</function>
</classRange>
<function
mainExpr="(?&lt;=\sdef\x20).+?(?=:)"
mainExpr="\sdef\x20\K.+?(?=:)"
>
<functionName>
<nameExpr expr=".*" />

View File

@ -16,7 +16,7 @@
>
<!-- within a class-->
<classRange
mainExpr ="(?&lt;=^class\x20).*?(?=\n\S|\Z)"
mainExpr ="^class\x20\K.*?(?=\n\S|\Z)"
>
<className>
<nameExpr expr="\w+" />
@ -25,7 +25,7 @@
mainExpr="^\s*def\s+\w+"
>
<functionName>
<funcNameExpr expr="(?&lt;=def\s)\w+" />
<funcNameExpr expr="def\s\K\w+" />
</functionName>
</function>
</classRange>
@ -34,7 +34,7 @@
mainExpr="^\s*def\s+\w+"
>
<functionName>
<nameExpr expr="(?&lt;=def\s)\w+" />
<nameExpr expr="def\s\K\w+" />
</functionName>
</function>
</parser>

View File

@ -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 <class CharT, class CharacterIterator>
BoostRegexSearch::Match BoostRegexSearch::EncodingDependent<CharT, CharacterIterator>::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;