From 5c941d29f14409697040b5b3001001f9a9d7c8c3 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Thu, 25 Apr 2013 15:38:43 +1000 Subject: [PATCH] strnicmp -> Q_strnicmp --- codemp/client/snd_mem.cpp | 4 ++-- codemp/game/q_shared.h | 7 +++++++ codemp/qcommon/files.cpp | 2 +- codemp/ui/ui_main.c | 6 +++--- codemp/win32/win_glimp.cpp | 4 ++-- codemp/win32/win_main.cpp | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/codemp/client/snd_mem.cpp b/codemp/client/snd_mem.cpp index 56bde11..0b3a511 100644 --- a/codemp/client/snd_mem.cpp +++ b/codemp/client/snd_mem.cpp @@ -702,7 +702,7 @@ static sboolean S_LoadSound_DirIsAllowedToKeepMP3s(const char *psFilename) int i; for (i=0; i< (sizeof(psAllowedDirs) / sizeof(psAllowedDirs[0])); i++) { - if (strnicmp(psFilename, psAllowedDirs[i], strlen(psAllowedDirs[i]))==0) + if (Q_strnicmp(psFilename, psAllowedDirs[i], strlen(psAllowedDirs[i]))==0) return qtrue; // found a dir that's allowed to keep MP3s } @@ -765,7 +765,7 @@ static sboolean S_LoadSound_Actual( sfx_t *sfx ) SND_TouchSFX(sfx); //========= - if (strnicmp(psExt,".mp3",4)==0) + if (Q_strnicmp(psExt,".mp3",4)==0) { // load MP3 file instead... // diff --git a/codemp/game/q_shared.h b/codemp/game/q_shared.h index 593cc21..73f50b8 100644 --- a/codemp/game/q_shared.h +++ b/codemp/game/q_shared.h @@ -1751,6 +1751,13 @@ char *Q_strlwr( char *s1 ); char *Q_strupr( char *s1 ); char *Q_strrchr( const char* string, int c ); +// NON-portable (but faster) versions +#ifdef _WIN32 +inline int Q_strnicmp (const char *s1, const char *s2, int n) { return strnicmp(s1, s2, n); } +#else +inline int Q_strnicmp (const char *s1, const char *s2, int n) { return strncasecmp(s1, s2, n); } +#endif + // buffer size safe library replacements void Q_strncpyz( char *dest, const char *src, int destsize ); void Q_strcat( char *dest, int size, const char *src ); diff --git a/codemp/qcommon/files.cpp b/codemp/qcommon/files.cpp index 68493de..8ac91be 100644 --- a/codemp/qcommon/files.cpp +++ b/codemp/qcommon/files.cpp @@ -1038,7 +1038,7 @@ static bool Sys_FileOutOfDate( LPCSTR psFinalFileName /* dest */, LPCSTR psDataF static bool FS_FileCacheable(const char* const filename) { - return( strchr(filename, '/') && strnicmp(filename, "ext_data/", 9) ); + return( strchr(filename, '/') && Q_strnicmp(filename, "ext_data/", 9) ); } /* diff --git a/codemp/ui/ui_main.c b/codemp/ui/ui_main.c index fb0f62b..72d59c2 100644 --- a/codemp/ui/ui_main.c +++ b/codemp/ui/ui_main.c @@ -10589,7 +10589,7 @@ static void UI_BuildPlayerModel_List( qboolean inGameLoad ) if (bIsImageFile(dirptr, skinname)) { //if it exists - if (strnicmp(skinname,"head_",5) == 0) + if (Q_strnicmp(skinname,"head_",5) == 0) { if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinHeadCount < MAX_PLAYERMODELS) { @@ -10601,7 +10601,7 @@ static void UI_BuildPlayerModel_List( qboolean inGameLoad ) iSkinParts |= 1<<0; } } else - if (strnicmp(skinname,"torso_",6) == 0) + if (Q_strnicmp(skinname,"torso_",6) == 0) { if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinTorsoCount < MAX_PLAYERMODELS) { @@ -10612,7 +10612,7 @@ static void UI_BuildPlayerModel_List( qboolean inGameLoad ) iSkinParts |= 1<<1; } } else - if (strnicmp(skinname,"lower_",6) == 0) + if (Q_strnicmp(skinname,"lower_",6) == 0) { if (uiInfo.playerSpecies[uiInfo.playerSpeciesCount].SkinLegCount < MAX_PLAYERMODELS) { diff --git a/codemp/win32/win_glimp.cpp b/codemp/win32/win_glimp.cpp index 496eee8..65f9b7f 100644 --- a/codemp/win32/win_glimp.cpp +++ b/codemp/win32/win_glimp.cpp @@ -1361,8 +1361,8 @@ static void GLW_InitExtensions( void ) // Figure out which texture rectangle extension to use. bool bTexRectSupported = false; - if ( strnicmp( glConfig.vendor_string, "ATI Technologies",16 )==0 - && strnicmp( glConfig.version_string, "1.3.3",5 )==0 + if ( Q_strnicmp( glConfig.vendor_string, "ATI Technologies",16 )==0 + && Q_strnicmp( glConfig.version_string, "1.3.3",5 )==0 && glConfig.version_string[5] < '9' ) //1.3.34 and 1.3.37 and 1.3.38 are broken for sure, 1.3.39 is not { g_bTextureRectangleHack = true; diff --git a/codemp/win32/win_main.cpp b/codemp/win32/win_main.cpp index 78155e1..d2fd85a 100644 --- a/codemp/win32/win_main.cpp +++ b/codemp/win32/win_main.cpp @@ -666,7 +666,7 @@ static qboolean Sys_ScanForCD( void ) { Result = GetVolumeInformation(drive,VolumeName,sizeof(VolumeName),&VolumeSerialNumber, &MaximumComponentLength,&FileSystemFlags,FileSystemName,sizeof(FileSystemName)); - if (Result && (strnicmp(VolumeName,CD_VOLUME,8) == 0 ) ) + if (Result && (Q_strnicmp(VolumeName,CD_VOLUME,8) == 0 ) ) { sprintf (test, "%s%s\\%s",drive, CD_BASEDIR, CD_EXE); f = fopen( test, "r" );