mirror of https://github.com/stella-emu/stella.git
Updated the case-insensitive string comparison functions to be more
efficient, and use macros that have already been defined. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2047 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
1cdd4c9508
commit
a9f91c0e44
|
@ -66,10 +66,9 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
using namespace std;
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// Defines to help with path handling
|
||||
#if defined BSPF_UNIX
|
||||
#define BSPF_PATH_SEPARATOR "/"
|
||||
|
@ -78,7 +77,7 @@ using namespace std;
|
|||
#elif defined BSPF_MAC_OSX
|
||||
#define BSPF_PATH_SEPARATOR "/"
|
||||
#elif defined BSPF_GP2X
|
||||
#define BSPF_PATH_SEPARATOR "/"
|
||||
#define BSPF_PATH_SEPARATOR "/"
|
||||
#endif
|
||||
|
||||
// I wish Windows had a complete POSIX layer
|
||||
|
@ -110,15 +109,17 @@ using namespace std;
|
|||
#endif
|
||||
|
||||
// Some convenience functions
|
||||
template<typename T> inline void BSPF_swap(T &a, T &b) { T tmp = a; a = b; b = tmp; }
|
||||
template<typename T> inline void BSPF_swap(T& a, T& b) { T tmp = a; a = b; b = tmp; }
|
||||
template<typename T> inline T BSPF_abs (T x) { return (x>=0) ? x : -x; }
|
||||
template<typename T> inline T BSPF_min (T a, T b) { return (a<b) ? a : b; }
|
||||
template<typename T> inline T BSPF_max (T a, T b) { return (a>b) ? a : b; }
|
||||
inline string BSPF_tolower(const string& s)
|
||||
inline bool BSPF_equalsIgnoreCase(const string& s1, const string& s2)
|
||||
{
|
||||
string t = s;
|
||||
transform(t.begin(), t.end(), t.begin(), (int(*)(int)) tolower);
|
||||
return t;
|
||||
return BSPF_strcasecmp(s1.c_str(), s2.c_str()) == 0;
|
||||
}
|
||||
inline bool BSPF_equalsIgnoreCase(const char* s1, const char* s2)
|
||||
{
|
||||
return BSPF_strcasecmp(s1, s2) == 0;
|
||||
}
|
||||
|
||||
static const string EmptyString("");
|
||||
|
|
|
@ -1027,7 +1027,7 @@ const FrameBuffer::VideoMode FrameBuffer::
|
|||
// If it's 'auto', we just use the mode as already previously defined
|
||||
// If it's not 'auto', attempt to fit the mode into the resolution
|
||||
// specified by 'fullres' (if possible)
|
||||
if(isFullscreen && BSPF_tolower(settings.getString("fullres")) != "auto")
|
||||
if(isFullscreen && !BSPF_equalsIgnoreCase(settings.getString("fullres"), "auto"))
|
||||
{
|
||||
// Only use 'fullres' if it's *bigger* than the requested mode
|
||||
int w, h;
|
||||
|
@ -1085,8 +1085,8 @@ void FrameBuffer::VideoModeList::setByGfxMode(const string& name)
|
|||
GraphicsMode gfxmode;
|
||||
for(uInt32 i = 0; i < GFX_NumModes; ++i)
|
||||
{
|
||||
if(ourGraphicsModes[i].name == BSPF_tolower(name) ||
|
||||
ourGraphicsModes[i].description == BSPF_tolower(name))
|
||||
if(BSPF_equalsIgnoreCase(ourGraphicsModes[i].name, name) ||
|
||||
BSPF_equalsIgnoreCase(ourGraphicsModes[i].description, name))
|
||||
{
|
||||
gfxmode = ourGraphicsModes[i];
|
||||
found = true;
|
||||
|
|
|
@ -755,8 +755,8 @@ uInt8* OSystem::openROM(string file, string& md5, uInt32& size)
|
|||
// Grab 3-character extension
|
||||
char* ext = filename + strlen(filename) - 4;
|
||||
|
||||
if(!BSPF_strcasecmp(ext, ".a26") || !BSPF_strcasecmp(ext, ".bin") ||
|
||||
!BSPF_strcasecmp(ext, ".rom"))
|
||||
if(BSPF_equalsIgnoreCase(ext, ".a26") || BSPF_equalsIgnoreCase(ext, ".bin") ||
|
||||
BSPF_equalsIgnoreCase(ext, ".rom"))
|
||||
{
|
||||
file = filename;
|
||||
break;
|
||||
|
|
|
@ -134,7 +134,7 @@ void ContextMenu::setSelected(const string& tag, const string& defaultTag)
|
|||
{
|
||||
for(unsigned int item = 0; item < _entries.size(); ++item)
|
||||
{
|
||||
if(BSPF_strcasecmp(_entries[item].second.c_str(), tag.c_str()) == 0)
|
||||
if(BSPF_equalsIgnoreCase(_entries[item].second, tag) == 0)
|
||||
{
|
||||
setSelected(item);
|
||||
return;
|
||||
|
@ -144,7 +144,7 @@ void ContextMenu::setSelected(const string& tag, const string& defaultTag)
|
|||
// If we get this far, the value wasn't found; use the default value
|
||||
for(unsigned int item = 0; item < _entries.size(); ++item)
|
||||
{
|
||||
if(BSPF_strcasecmp(_entries[item].second.c_str(), defaultTag.c_str()) == 0)
|
||||
if(BSPF_equalsIgnoreCase(_entries[item].second, defaultTag) == 0)
|
||||
{
|
||||
setSelected(item);
|
||||
return;
|
||||
|
|
|
@ -136,7 +136,7 @@ bool LauncherFilterDialog::isValidRomName(const string& name,
|
|||
const char* ext = name.c_str() + idx + 1;
|
||||
|
||||
for(uInt32 i = 0; i < exts.size(); ++i)
|
||||
if(BSPF_strcasecmp(ext, exts[i].c_str()) == 0)
|
||||
if(BSPF_equalsIgnoreCase(ext, exts[i]))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ bool LauncherFilterDialog::isValidRomName(const string& name, string& ext)
|
|||
|
||||
for(uInt32 i = 0; i < 5; ++i)
|
||||
{
|
||||
if(BSPF_strcasecmp(e, ourRomTypes[1][i]) == 0)
|
||||
if(BSPF_equalsIgnoreCase(e, ourRomTypes[1][i]))
|
||||
{
|
||||
ext = e;
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue