diff options
author | Zufu Liu <unknown> | 2023-12-21 16:00:00 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2023-12-21 16:00:00 +1100 |
commit | 8e55cc0c973cc2fbaac8cca1505524b86ce58dff (patch) | |
tree | 0cf01d056b0c92de62b811466495a42d82a7879b /src/RESearch.cxx | |
parent | 1b153f8d8d4b2f09afc2d039256c958e94bd3b05 (diff) | |
download | scintilla-mirror-8e55cc0c973cc2fbaac8cca1505524b86ce58dff.tar.gz |
Bug [#2405]. Avoid character fragments in regular expression search results.
Diffstat (limited to 'src/RESearch.cxx')
-rw-r--r-- | src/RESearch.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/RESearch.cxx b/src/RESearch.cxx index 7b2701aba..5a509ab6e 100644 --- a/src/RESearch.cxx +++ b/src/RESearch.cxx @@ -769,8 +769,15 @@ int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Positio default: /* regular matching all the way. */ while (lp < endp) { ep = PMatch(ci, lp, endp, ap); - if (ep != NOTFOUND) - break; + if (ep != NOTFOUND) { + // fix match started from middle of character like DBCS trailing ASCII byte + const Sci::Position pos = ci.MovePositionOutsideChar(lp, -1); + if (pos != lp) { + ep = NOTFOUND; + } else { + break; + } + } lp++; } break; @@ -791,6 +798,7 @@ int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Positio } } + ep = ci.MovePositionOutsideChar(ep, 1); bopat[0] = lp; eopat[0] = ep; return 1; @@ -865,9 +873,13 @@ Sci::Position RESearch::PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci return NOTFOUND; break; case BOT: + if (lp != ci.MovePositionOutsideChar(lp, -1)) { + return NOTFOUND; + } bopat[static_cast<unsigned char>(*ap++)] = lp; break; case EOT: + lp = ci.MovePositionOutsideChar(lp, 1); eopat[static_cast<unsigned char>(*ap++)] = lp; break; case BOW: |