예제 #1
0
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;
}
예제 #2
0
파일: PosixRegex.hpp 프로젝트: gt1/libmaus2
			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;
			}
예제 #3
0
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;
}
예제 #4
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);

}
예제 #5
0
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;
}