Beispiel #1
0
static tagResult find(tagFile * const file, tagEntry * const entry,
                      const char *const name, const int options)
{
	tagResult result = TagFailure;
	file->search.name = name;
	file->search.nameLength = strlen(name);
	file->search.partial = (options & TAG_PARTIALMATCH) != 0;
	file->search.ignorecase = (options & TAG_IGNORECASE) != 0;
	fseek(file->fp, 0, SEEK_END);
	file->size = ftell(file->fp);
	rewind(file->fp);
	if ((file->sortMethod == TAG_SORTED && !file->search.ignorecase) ||
	        (file->sortMethod == TAG_FOLDSORTED && file->search.ignorecase))
		result = findBinary(file);
	else
		result = findSequential(file);

	if (result != TagSuccess)
		file->search.pos = file->size;
	else
	{
		file->search.pos = file->pos;
		if (entry != NULL)
			parseTagLine(file, entry);
	}
	return result;
}
static tagResult findNext (tagFile *const file, tagEntry *const entry)
{
	tagResult result = TagFailure;
	if ((file->sortMethod == TAG_SORTED      && !file->search.ignorecase) ||
		(file->sortMethod == TAG_FOLDSORTED  &&  file->search.ignorecase))
	{
		result = tagsNext (file, entry);
		if (result == TagSuccess  && nameComparison (file) != 0)
			result = TagFailure;
	}
	else
	{
		result = findSequential (file);
		if (result == TagSuccess  &&  entry != NULL)
			parseTagLine (file, entry);
	}
	return result;
}
Beispiel #3
0
static tagResult find (tagFile *const file, tagEntry *const entry,
					   const char *const name, const int options)
{
	tagResult result;
	if (file->search.name != NULL)
		free (file->search.name);
	file->search.name = duplicate (name);
	file->search.nameLength = strlen (name);
	file->search.partial = (options & TAG_PARTIALMATCH) != 0;
	file->search.ignorecase = (options & TAG_IGNORECASE) != 0;
	fseek (file->fp, 0, SEEK_END);
	file->size = ftell (file->fp);
	rewind (file->fp);
	if ((file->sortMethod == TAG_SORTED      && !file->search.ignorecase) ||
		(file->sortMethod == TAG_FOLDSORTED  &&  file->search.ignorecase))
	{
#ifdef DEBUG
		printf ("<performing binary search>\n");
#endif
		result = findBinary (file);
	}
	else
	{
#ifdef DEBUG
		printf ("<performing sequential search>\n");
#endif
		result = findSequential (file);
	}

	if (result != TagSuccess)
		file->search.pos = file->size;
	else
	{
		file->search.pos = file->pos;
		if (entry != NULL)
			parseTagLine (file, entry);
	}
	return result;
}