diff --git a/StepmaniaCore.cmake b/StepmaniaCore.cmake index cb49a14674..ab74097c5a 100644 --- a/StepmaniaCore.cmake +++ b/StepmaniaCore.cmake @@ -87,14 +87,15 @@ include(CheckCXXSymbolExists) # Mostly Windows functions. check_function_exists(_mkdir HAVE__MKDIR) check_cxx_symbol_exists(_snprintf cstdio HAVE__SNPRINTF) -#check_function_exists(_snprintf HAVE__SNPRINTF) +check_cxx_symbol_exists(stricmp cstring HAVE_STRICMP) +check_cxx_symbol_exists(_stricmp cstring HAVE__STRICMP) # Mostly non-Windows functions. check_function_exists(fcntl HAVE_FCNTL) check_function_exists(fork HAVE_FORK) check_function_exists(mkdir HAVE_MKDIR) -#check_function_exists(snprintf HAVE_SNPRINTF) check_cxx_symbol_exists(snprintf cstdio HAVE_SNPRINTF) +check_cxx_symbol_exists(strcasecmp cstring HAVE_STRCASECMP) check_function_exists(waitpid HAVE_WAITPID) diff --git a/src/AnnouncerManager.cpp b/src/AnnouncerManager.cpp index ab6e9ff17b..7d5576e2ec 100644 --- a/src/AnnouncerManager.cpp +++ b/src/AnnouncerManager.cpp @@ -38,7 +38,7 @@ void AnnouncerManager::GetAnnouncerNames( vector& AddTo ) // strip out the empty announcer folder for( int i=AddTo.size()-1; i>=0; i-- ) - if( !stricmp( AddTo[i], EMPTY_ANNOUNCER_NAME ) ) + if( !strcasecmp( AddTo[i], EMPTY_ANNOUNCER_NAME ) ) AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 ); } @@ -50,7 +50,7 @@ bool AnnouncerManager::DoesAnnouncerExist( RString sAnnouncerName ) vector asAnnouncerNames; GetAnnouncerNames( asAnnouncerNames ); for( unsigned i=0; i nam { for(size_t i= 0; i < name_list.size(); ++i) { - if(0 == stricmp(name, name_list[i])) + if(0 == strcasecmp(name, name_list[i])) { return true; } diff --git a/src/ScreenOptionsMasterPrefs.cpp b/src/ScreenOptionsMasterPrefs.cpp index 8209f04861..115d6b45da 100644 --- a/src/ScreenOptionsMasterPrefs.cpp +++ b/src/ScreenOptionsMasterPrefs.cpp @@ -183,7 +183,7 @@ static void GameSel( int &sel, bool ToSel, const ConfOption *pConfOption ) sel = 0; for(unsigned i = 0; i < choices.size(); ++i) - if( !stricmp(choices[i], sCurGameName) ) + if( !strcasecmp(choices[i], sCurGameName) ) sel = i; } else { vector aGames; @@ -218,12 +218,12 @@ static void Language( int &sel, bool ToSel, const ConfOption *pConfOption ) { sel = -1; for( unsigned i=0; sel == -1 && i < vs.size(); ++i ) - if( !stricmp(vs[i], THEME->GetCurLanguage()) ) + if( !strcasecmp(vs[i], THEME->GetCurLanguage()) ) sel = i; // If the current language doesn't exist, we'll show BASE_LANGUAGE, so select that. for( unsigned i=0; sel == -1 && i < vs.size(); ++i ) - if( !stricmp(vs[i], SpecialFiles::BASE_LANGUAGE) ) + if( !strcasecmp(vs[i], SpecialFiles::BASE_LANGUAGE) ) sel = i; if( sel == -1 ) @@ -272,7 +272,7 @@ static void RequestedTheme( int &sel, bool ToSel, const ConfOption *pConfOption { sel = 0; for( unsigned i=1; im_sTheme.Get()) ) + if( !strcasecmp(vsThemeNames[i], PREFSMAN->m_sTheme.Get()) ) sel = i; } else @@ -298,7 +298,7 @@ static void Announcer( int &sel, bool ToSel, const ConfOption *pConfOption ) { sel = 0; for( unsigned i=1; iGetCurAnnouncerName()) ) + if( !strcasecmp(choices[i], ANNOUNCER->GetCurAnnouncerName()) ) sel = i; } else @@ -325,7 +325,7 @@ static void DefaultNoteSkin( int &sel, bool ToSel, const ConfOption *pConfOption po.FromString( PREFSMAN->m_sDefaultModifiers ); sel = 0; for( unsigned i=0; i < choices.size(); i++ ) - if( !stricmp(choices[i], po.m_sNoteSkin) ) + if( !strcasecmp(choices[i], po.m_sNoteSkin) ) sel = i; } else diff --git a/src/archutils/Win32/arch_setup.h b/src/archutils/Win32/arch_setup.h index ec5c3932f1..3815210f13 100644 --- a/src/archutils/Win32/arch_setup.h +++ b/src/archutils/Win32/arch_setup.h @@ -20,7 +20,6 @@ #if defined(_MSC_VER) #if _MSC_VER == 1400 // VC8 specific warnings -#pragma warning (disable : 4996) // deprecated functions vs "ISO C++ conformant names". (stricmp vs _stricmp) #pragma warning (disable : 4005) // macro redefinitions (ARRAYSIZE) #endif diff --git a/src/config.in.hpp b/src/config.in.hpp index 9fcc5b4954..060f16de62 100644 --- a/src/config.in.hpp +++ b/src/config.in.hpp @@ -48,6 +48,15 @@ /* Defined to 1 if the underlying system provides the snprintf function. */ #cmakedefine HAVE_SNPRINTF 1 +/* Defined to 1 if the underlying system provides the stricmp function. */ +#cmakedefine HAVE_STRICMP 1 + +/* Defined to 1 if the underlying system provides the _stricmp function. */ +#cmakedefine HAVE__STRICMP 1 + +/* Defined to 1 if the underlying system provides the strcasecmp function. */ +#cmakedefine HAVE_STRCASECMP 1 + /* Defined to 1 if the underlying system provides the powf function. */ #cmakedefine HAVE_POWF 1 @@ -164,6 +173,16 @@ typedef long ssize_t; #error "No size limited sprintf function available. Aborting." #endif +/* Ensure we have a function that acts like a case insensitive string comparison. */ +#if defined(HAVE_STRCASECMP) +#elif defined(HAVE__STRICMP) +#define strcasecmp _stricmp +#elif defined(HAVE_STRICMP) +#define strcasecmp stricmp +#else +#error "No case insensitive string comparison function available. Aborting." +#endif + /* Ensure we have a function that can create a directory on the file system. */ #if defined(HAVE__MKDIR) #include diff --git a/src/global.h b/src/global.h index 67f4156d0b..a96690653e 100644 --- a/src/global.h +++ b/src/global.h @@ -147,13 +147,6 @@ template struct CompileAssertDecl { }; /** @brief Use RStrings throughout the program. */ typedef StdString::CStdString RString; -#if !defined(WIN32) -/** @brief Define stricmp to be strcasecmp. */ -#define stricmp strcasecmp -/** @brief Define strnicmp to be strncasecmp. */ -#define strnicmp strncasecmp -#endif - #include "RageException.h" /* Define a few functions if necessary */