QVector<QString> IndexedEdictFile::findMatches( const QString &query ) const { QVector<QString> results; if( ! m_valid ) { return results; } QTextCodec *codec = QTextCodec::codecForName( "eucJP" ); if( ! codec ) { return results; } QByteArray searchString = codec->fromUnicode( query ); int indexSize = m_indexFile.size() / sizeof( uint32_t ); int dictSize = m_dictFile.size() / sizeof( unsigned char ); int matchLocation = findFirstMatch( searchString ); QByteArray currentWord = lookupDictLine( ++matchLocation ); if( matchLocation == 0 ) { return results; } QVector<uint32_t> possibleHits; do { currentWord = lookupDictLine( ++matchLocation ); int i = 0; while( lookupDictChar( m_indexPtr[ matchLocation - 1 ] + i - 2 ) != 0x0A ) { --i; } possibleHits.push_back( m_indexPtr[ matchLocation - 1 ] + i - 1 ); } while( matchLocation < indexSize && 0 == equalOrSubstring( searchString, currentWord ) ); if( possibleHits.size() <= 0 ) { return results; } qSort( possibleHits ); uint32_t last = 0; foreach( uint32_t it, possibleHits ) { if(last != it) { last = it; results.push_back( codec->toUnicode( lookupFullLine( it ) ) ); } } return results; }
std::vector<uint64_t> findAllMatches(char const * c) const { int64_t r = 0; char const * d = c; std::vector<uint64_t> V; while ( (r = findFirstMatch(d)) >= 0 ) { V.push_back( (d-c)+r ); d = d+r+1; } return V; }
bool Matcher::findNextMatch() { int s = starts[0], e = ends[0]; if (!matchedSomething) return findFirstMatch(); if (s == e) ++e; flags = 0; clearGroups(); starts[0] = e; if (e >= (int)str.size()) return 0; start = e; lm = e; ends[0] = pat->head->match(str, this, e); return ends[0] >= 0; }
/* The getNextEntry function search the next file which is specified DIR */ int pcsl_file_getnextentry(void *handle, const pcsl_string * string, pcsl_string * result) { PCSLFileIterator* pIterator = (PCSLFileIterator *)handle; if (pIterator == NULL) { return -1; } if (pIterator->iteratorHandle == INVALID_HANDLE_VALUE) { return findFirstMatch(pIterator, string, result); } return findNextMatch(pIterator, string, result); }
int expandWildcards (argLink **ppArgLink) { argLink *pFirstNewLink = NULL; argLink **wppPrev = &pFirstNewLink; argLink *pArgLink = *ppArgLink; argLink *pTmp; int nNew = 0; int x; char temp[MAX_NAMELEN]; while (pArgLink != NULL) { #ifdef MSWIN if (strchr (pArgLink->pString, '*') != NULL || strchr (pArgLink->pString, '?') != NULL || strchr (pArgLink->pString, '~') != NULL) #else if (strchr (pArgLink->pString, '*') != NULL || strchr (pArgLink->pString, '?') != NULL) #endif { x = findFirstMatch (pArgLink->pString, temp); while (x) { pTmp = insertStringInArgLink (wppPrev, temp); wppPrev = &pTmp->psNext; nNew++; x = findNextMatch (pArgLink->pString, temp); } pTmp = pArgLink; pArgLink = pArgLink->psNext; free (pTmp); } else { *wppPrev = pArgLink; wppPrev = &pArgLink->psNext; pArgLink = pArgLink->psNext; } } *wppPrev = NULL; *ppArgLink = pFirstNewLink; return nNew; }