diff options
Diffstat (limited to 'tier0/tier0_strtools.cpp')
| -rw-r--r-- | tier0/tier0_strtools.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tier0/tier0_strtools.cpp b/tier0/tier0_strtools.cpp new file mode 100644 index 0000000..72bf6e5 --- /dev/null +++ b/tier0/tier0_strtools.cpp @@ -0,0 +1,53 @@ +//========= 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; + } + } + } +} |