diff options
author | Andrey Nazarov <skuller@skuller.net> | 2009-09-08 12:23:21 +0000 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2009-09-08 12:23:21 +0000 |
commit | 1b987015a2a336706b8be83f592b5162b949e1cd (patch) | |
tree | 905e31593b165d25d661466134965563141fbe7e /source/q_shared.c | |
parent | 501e3f64fecc492e6de4b7a1242760cbb1f6c75d (diff) |
Moved some more stuff from q_shared.c into common.c
Diffstat (limited to 'source/q_shared.c')
-rw-r--r-- | source/q_shared.c | 82 |
1 files changed, 3 insertions, 79 deletions
diff --git a/source/q_shared.c b/source/q_shared.c index 9a4aea0..e1112ea 100644 --- a/source/q_shared.c +++ b/source/q_shared.c @@ -158,7 +158,7 @@ char *COM_SkipPath( const char *pathname ) { char *last; if( !pathname ) { - Com_Error( ERR_FATAL, "COM_SkipPath: NULL" ); + Com_Error( ERR_FATAL, "%s: NULL", __func__ ); } last = (char *)pathname; @@ -371,88 +371,12 @@ unsigned COM_ParseHex( const char *s ) { return result; } -/* -================= -SortStrcmp -================= -*/ int QDECL SortStrcmp( const void *p1, const void *p2 ) { - const char *s1 = *( const char ** )p1; - const char *s2 = *( const char ** )p2; - - return strcmp( s1, s2 ); + return strcmp( *( const char ** )p1, *( const char ** )p2 ); } int QDECL SortStricmp( const void *p1, const void *p2 ) { - const char *s1 = *( const char ** )p1; - const char *s2 = *( const char ** )p2; - - return Q_stricmp( s1, s2 ); -} - -/* -================= -Com_WildCmp - -Wildcard compare. -Returns non-zero if matches, zero otherwise. -================= -*/ -int Com_WildCmp( const char *filter, const char *string, qboolean ignoreCase ) { - switch( *filter ) { - case '\0': - return !*string; - - case '*': - return Com_WildCmp( filter + 1, string, ignoreCase ) || (*string && Com_WildCmp( filter, string + 1, ignoreCase )); - - case '?': - return *string && Com_WildCmp( filter + 1, string + 1, ignoreCase ); - - default: - return ((*filter == *string) || (ignoreCase && (Q_toupper( *filter ) == Q_toupper( *string )))) && Com_WildCmp( filter + 1, string + 1, ignoreCase ); - } -} - -/* -================ -Com_HashString -================ -*/ -unsigned Com_HashString( const char *string, int hashSize ) { - unsigned hash, c; - - hash = 0; - while( *string ) { - c = *string++; - hash = 127 * hash + c; - } - - hash = ( hash >> 20 ) ^ ( hash >> 10 ) ^ hash; - return hash & ( hashSize - 1 ); -} - -/* -================ -Com_HashPath -================ -*/ -unsigned Com_HashPath( const char *string, int hashSize ) { - unsigned hash, c; - - hash = 0; - while( *string ) { - c = *string++; - if( c == '\\' ) { - c = '/'; - } else { - c = Q_tolower( c ); - } - hash = 127 * hash + c; - } - - hash = ( hash >> 20 ) ^ ( hash >> 10 ) ^ hash; - return hash & ( hashSize - 1 ); + return Q_stricmp( *( const char ** )p1, *( const char ** )p2 ); } /* |