source-engine/tier0/tier0_strtools.cpp
FluorescentCIAAfricanAmerican 3bf9df6b27 1
2020-04-22 12:56:21 -04:00

54 lines
869 B
C++

//========= Copyright Valve Corporation, All rights reserved. ============//
#include "pch_tier0.h"
#include "tier0_strtools.h"
#define TOLOWERC( x ) (( ( x >= 'A' ) && ( x <= 'Z' ) )?( x + 32 ) : x )
extern "C"
int V_tier0_stricmp(const char *s1, const char *s2 )
{
uint8 const *pS1 = ( uint8 const * ) s1;
uint8 const *pS2 = ( uint8 const * ) s2;
for(;;)
{
int c1 = *( pS1++ );
int c2 = *( pS2++ );
if ( c1 == c2 )
{
if ( !c1 ) return 0;
}
else
{
if ( ! c2 )
{
return c1 - c2;
}
c1 = TOLOWERC( c1 );
c2 = TOLOWERC( c2 );
if ( c1 != c2 )
{
return c1 - c2;
}
}
c1 = *( pS1++ );
c2 = *( pS2++ );
if ( c1 == c2 )
{
if ( !c1 ) return 0;
}
else
{
if ( ! c2 )
{
return c1 - c2;
}
c1 = TOLOWERC( c1 );
c2 = TOLOWERC( c2 );
if ( c1 != c2 )
{
return c1 - c2;
}
}
}
}