Beispiel #1
0
bool CAtomTable::FindAtom (const CString &sString, int *retiAtom)

//	FindAtom
//
//	Returns TRUE if the atom exists, FALSE otherwise

	{
	//	Hash the string

	int iHash = (utlHashFunctionCase((BYTE *)sString.GetASCIIZ(), sString.GetLength()) % ctHashTableSize);

	//	See if we've found it

	int iNext = m_HashTable[iHash];
	while (iNext != -1)
		{
		SEntry *pEntry = GetEntry(iNext);
		if (strEqualsCase(sString, pEntry->GetString()))
			{
			if (retiAtom)
				*retiAtom = (m_iBaseAtom + iNext);
			return true;
			}

		iNext = pEntry->iNext;
		}

	//	We did not find the atom

	return false;
	}
Beispiel #2
0
int CAtomTable::AddAtomWithData (const CString &sString, void *pData, int iDataLen)

//	AddAtomWithData
//
//	Adds an atom. If the atom does not exist, adds the given data also

	{
	//	Hash the string

	int iHash = (utlHashFunctionCase((BYTE *)sString.GetASCIIZ(), sString.GetLength()) % ctHashTableSize);

	//	See if we've found it

	int iNext = m_HashTable[iHash];
	while (iNext != -1)
		{
		SEntry *pEntry = GetEntry(iNext);
		if (strEqualsCase(sString, pEntry->GetString()))
			return (m_iBaseAtom + iNext);

		iNext = pEntry->iNext;
		}

	//	We did not find the atom, so add it

	return (m_iBaseAtom + AllocAtom(sString, iHash, pData, iDataLen));
	}
void CCommandLineDisplay::AppendHistory (const CString &sLine)

//	AppendHistory
//
//	Append a line of input to the history buffer

	{
	//	Use case-sensitive compare because sometimes commands differ only
	//	by case.

	if (!strEqualsCase(sLine, GetHistory(0)))
		{
		m_iHistoryStart = (m_iHistoryStart + (MAX_LINES + 1) - 1) % (MAX_LINES + 1);
		if (m_iHistoryStart == m_iHistoryEnd)
			m_iHistoryEnd = (m_iHistoryEnd + (MAX_LINES + 1) - 1) % (MAX_LINES + 1);

		m_History[m_iHistoryStart] = sLine;
		}

	m_iHistoryIndex = -1;
	}