diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index d51d79492..d3cd6dafd 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -57,7 +57,7 @@ typedef __int64 Int64; typedef unsigned __int64 uInt64; #else - #error Update BSPF.hxx for datatypes + #error Update src/common/bspf.hxx for datatypes #endif @@ -74,31 +74,12 @@ using namespace std; // Defines to help with path handling -#if defined BSPF_UNIX +#if (defined(BSPF_UNIX) || defined(BSPF_MAC_OSX)) #define BSPF_PATH_SEPARATOR "/" #elif (defined(BSPF_DOS) || defined(BSPF_WIN32) || defined(BSPF_OS2)) #define BSPF_PATH_SEPARATOR "\\" -#elif defined BSPF_MAC_OSX - #define BSPF_PATH_SEPARATOR "/" -#elif defined BSPF_GP2X - #define BSPF_PATH_SEPARATOR "/" -#endif - -// I wish Windows had a complete POSIX layer -#if defined BSPF_WIN32 && !defined __GNUG__ - #define BSPF_strcasecmp _stricmp - #define BSPF_strncasecmp _strnicmp - #define BSPF_isblank(c) ((c == ' ') || (c == '\t')) - #define BSPF_snprintf _snprintf - #define BSPF_vsnprintf _vsnprintf #else - #define HAVE_UNISTD_H // needed for building zlib - #include - #define BSPF_strcasecmp strcasecmp - #define BSPF_strncasecmp strncasecmp - #define BSPF_isblank(c) isblank(c) - #define BSPF_snprintf snprintf - #define BSPF_vsnprintf vsnprintf + #error Update src/common/bspf.hxx for path separator #endif // CPU architecture type @@ -113,7 +94,22 @@ using namespace std; #define BSPF_ARCH "NOARCH" #endif +// I wish Windows had a complete POSIX layer +#if defined BSPF_WIN32 && !defined __GNUG__ + #define BSPF_snprintf _snprintf + #define BSPF_vsnprintf _vsnprintf +#else + #define HAVE_UNISTD_H // needed for building zlib + #include + #define BSPF_snprintf snprintf + #define BSPF_vsnprintf vsnprintf +#endif + +static const string EmptyString(""); + +////////////////////////////////////////////////////////////////////// // Some convenience functions + template inline void BSPF_swap(T& a, T& b) { T tmp = a; a = b; b = tmp; } template inline T BSPF_abs (T x) { return (x>=0) ? x : -x; } template inline T BSPF_min (T a, T b) { return (afirst.c_str(); - if(BSPF_strncasecmp(l, in, strlen(in)) == 0) + if(BSPF_equalsIgnoreCase(l, in)) list.push_back(l); } for(int i = 0; pseudo_registers[i][0] != 0; ++i) - if(BSPF_strncasecmp(pseudo_registers[i][0], in, strlen(in)) == 0) + if(BSPF_equalsIgnoreCase(pseudo_registers[i][0], in)) list.push_back(pseudo_registers[i][0]); } diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index e5b51af78..157e0e378 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -715,12 +715,12 @@ bool Cartridge::isProbablyEF(const uInt8* image, uInt32 size, const char*& type) // This signature is attributed to "RevEng" of AtariAge uInt8 efef[] = { 'E', 'F', 'E', 'F' }; uInt8 efsc[] = { 'E', 'F', 'S', 'C' }; - if(searchForBytes(image+size-8, 8, efef, 4, 1) > 0) + if(searchForBytes(image+size-8, 8, efef, 4, 1)) { type = "EF"; return true; } - else if(searchForBytes(image+size-8, 8, efsc, 4, 1) > 0) + else if(searchForBytes(image+size-8, 8, efsc, 4, 1)) { type = "EFSC"; return true; diff --git a/src/emucore/FSNode.hxx b/src/emucore/FSNode.hxx index 834c5bc00..46e5e47c5 100644 --- a/src/emucore/FSNode.hxx +++ b/src/emucore/FSNode.hxx @@ -105,7 +105,7 @@ class FilesystemNode if (isDirectory() != node.isDirectory()) return isDirectory(); - return BSPF_strcasecmp(getName().c_str(), node.getName().c_str()) < 0; + return BSPF_compareIgnoreCase(getName(), node.getName()) < 0; } /** @@ -114,7 +114,7 @@ class FilesystemNode */ inline bool operator==(const FilesystemNode& node) const { - return BSPF_strcasecmp(getName().c_str(), node.getName().c_str()) == 0; + return BSPF_compareIgnoreCase(getName(), node.getName()) == 0; } /** diff --git a/src/emucore/PropsSet.cxx b/src/emucore/PropsSet.cxx index 68e9fe3eb..724935be2 100644 --- a/src/emucore/PropsSet.cxx +++ b/src/emucore/PropsSet.cxx @@ -126,7 +126,7 @@ bool PropertiesSet::getMD5(const string& md5, Properties& properties, while(low <= high) { int i = (low + high) / 2; - int cmp = BSPF_strncasecmp(md5.c_str(), DefProps[i][Cartridge_MD5], 32); + int cmp = BSPF_compareIgnoreCase(md5, DefProps[i][Cartridge_MD5]); if(cmp == 0) // found it { diff --git a/src/gui/ListWidget.cxx b/src/gui/ListWidget.cxx index 85e1d277c..2d4aeb96d 100644 --- a/src/gui/ListWidget.cxx +++ b/src/gui/ListWidget.cxx @@ -271,8 +271,7 @@ bool ListWidget::handleKeyDown(StellaKey key, StellaMod mod, char ascii) int newSelectedItem = 0; for (StringList::const_iterator i = _list.begin(); i != _list.end(); ++i) { - if(BSPF_strncasecmp((*i).c_str(), _quickSelectStr.c_str(), - _quickSelectStr.length()) == 0) + if(BSPF_startsWithIgnoreCase(*i, _quickSelectStr)) { _selectedItem = newSelectedItem; break;