예제 #1
0
void t4p::FinderActionClass::BackgroundWork() {
    if (!Finder.Prepare()) {
        return;
    }
    Code = t4p::CharToIcu(Utf8Buf);
    int32_t nextIndex(0);
    bool found = Finder.FindNext(Code, nextIndex);
    int32_t matchStart(0);
    int32_t matchLength(0);
    while (found) {
        if (Finder.GetLastMatch(matchStart, matchLength)) {
            // convert match back to UTF-8 ugh
            int utf8Start = t4p::CharToUtf8Pos(Utf8Buf, BufferLength, matchStart);
            int utf8End = t4p::CharToUtf8Pos(Utf8Buf, BufferLength, matchStart + matchLength);

            t4p::FinderHitEventClass hit(GetEventId(), utf8Start, utf8End - utf8Start);
            PostEvent(hit);
            nextIndex = matchStart + matchLength + 1;  // prevent infinite find next's
        } else {
            break;
        }
        found = Finder.FindNext(Code, nextIndex);
    }
    delete[] Utf8Buf;
}
예제 #2
0
void
RegexScan::matchInfo(
  ssize_t & start,
  ssize_t & len,
  unsigned short regNum ) const
{
  start = matchStart( regNum );
  len = matchLength( regNum );
}