diff --git a/scintilla/src/RESearch.cxx b/scintilla/src/RESearch.cxx index bb849584ef..7ae77df65d 100644 --- a/scintilla/src/RESearch.cxx +++ b/scintilla/src/RESearch.cxx @@ -264,7 +264,6 @@ RESearch::RESearch(const CharClassify *charClassTable) { lineStartPos = 0; lineEndPos = 0; sta = NOP; /* status of lastpat */ - failure = 0; previousFlags = FindOption::None; constexpr unsigned char nul = 0; std::fill(bittab, std::end(bittab), nul); @@ -758,8 +757,6 @@ int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Positio Sci::Position ep = NOTFOUND; const char * const ap = nfa; - failure = 0; - Clear(); switch (*ap) { @@ -787,8 +784,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; @@ -809,7 +813,6 @@ int RESearch::Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Positio } } - lp = ci.MovePositionOutsideChar(lp, -1); ep = ci.MovePositionOutsideChar(ep, 1); bopat[0] = lp; eopat[0] = ep; @@ -885,7 +888,9 @@ Sci::Position RESearch::PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci return NOTFOUND; break; case BOT: - lp = ci.MovePositionOutsideChar(lp, -1); + if (lp != ci.MovePositionOutsideChar(lp, -1)) { + return NOTFOUND; + } bopat[static_cast(*ap++)] = lp; break; case EOT: @@ -944,7 +949,6 @@ Sci::Position RESearch::PMatch(const CharacterIndexer &ci, Sci::Position lp, Sci n = CCLSKIP; break; default: - failure = true; //re_fail("closure: bad nfa.", *ap); return NOTFOUND; } diff --git a/scintilla/src/RESearch.h b/scintilla/src/RESearch.h index 82ad481d65..0a8359b145 100644 --- a/scintilla/src/RESearch.h +++ b/scintilla/src/RESearch.h @@ -51,7 +51,6 @@ class RESearch { Sci::Position tagstk[MAXTAG]; /* subpat tag stack */ char nfa[MAXNFA]; /* automaton */ int sta; - int failure; // cache for previous pattern to avoid recompile Scintilla::FindOption previousFlags;