tier1/strtools.cpp
const char* V_stristr( const char* pStr, const char* pSearch )
{
	Assert( pStr );
	Assert( pSearch );
	if (!pStr || !pSearch) 
		return 0;

	const char* pLetter = pStr;

	// Check the entire string
	while (*pLetter != 0)
	{
		// Skip over non-matches
		if ( FastASCIIToLower( *pLetter ) == FastASCIIToLower( *pSearch) )
		{
			// Check for match
			const char* pMatch = pLetter + 1;
			const char* pTest = pSearch + 1;
			while (*pTest != 0)
			{
				// We've run off the end; don't bother.
				if (*pMatch == 0)
					return 0;

				if ( FastASCIIToLower( *pMatch) != FastASCIIToLower( *pTest ) )
					break;

				++pMatch;
				++pTest;
			}

			// Found a match!
			if ( *pTest == 0 )
				return pLetter;
		}

		++pLetter;
	}

	return 0;
}
//-----------------------------------------------------------------------------
// Finds a string in another string with a case insensitive test
//-----------------------------------------------------------------------------
Finds a string in another string with a case insensitive test
Finds a string in another string with a case insensitive test
const char* V_stristr( const char* pStr, const char* pSearch )
{
	Assert( pStr );
	Assert( pSearch );
	if (!pStr || !pSearch) 
		return 0;
	const char* pLetter = pStr;
	while (*pLetter != 0)
	{
		if ( FastASCIIToLower( *pLetter ) == FastASCIIToLower( *pSearch) )
		{
			const char* pMatch = pLetter + 1;
			const char* pTest = pSearch + 1;
			while (*pTest != 0)
			{
				if (*pMatch == 0)
					return 0;
				if ( FastASCIIToLower( *pMatch) != FastASCIIToLower( *pTest ) )
					break;
				++pMatch;
				++pTest;
			}
			if ( *pTest == 0 )
				return pLetter;
		}
		++pLetter;
	}
	return 0;
}
const char * V_stristr ( const char * pStr , const char * pSearch ) { Assert ( pStr ) ; Assert ( pSearch ) ; if ( ! pStr || ! pSearch ) return 0 ; const char * pLetter = pStr ; while ( * pLetter != 0 ) { if ( FastASCIIToLower ( * pLetter ) == FastASCIIToLower ( * pSearch ) ) { const char * pMatch = pLetter + 1 ; const char * pTest = pSearch + 1 ; while ( * pTest != 0 ) { if ( * pMatch == 0 ) return 0 ; if ( FastASCIIToLower ( * pMatch ) != FastASCIIToLower ( * pTest ) ) break ; ++ pMatch ; ++ pTest ; } if ( * pTest == 0 ) return pLetter ; } ++ pLetter ; } return 0 ; }
Finds a string in another string with a case insensitive test
Finds a string in another string with a case insensitive test
// Check the entire string // Skip over non-matches // Check for match // We've run off the end; don't bother. // Found a match!