Fixed nasty C-style string conversion to upper/lower-case.

This commit is contained in:
Stephen Anthony 2019-01-01 15:22:30 -03:30
parent 3e85ae4d47
commit ebfff85cb6
3 changed files with 15 additions and 17 deletions

View File

@ -123,6 +123,18 @@ namespace BSPF
if(val < lower || val > upper) val = setVal;
}
// Convert string to given case
inline const string& toUpperCase(string& s)
{
transform(s.begin(), s.end(), s.begin(), ::toupper);
return s;
}
inline const string& toLowerCase(string& s)
{
transform(s.begin(), s.end(), s.begin(), ::tolower);
return s;
}
// Compare two strings, ignoring case
inline int compareIgnoreCase(const string& s1, const string& s2)
{

View File

@ -992,21 +992,10 @@ string TIADebug::audFreq(uInt8 div)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::booleanWithLabel(string label, bool value)
{
char buf[64];
string ret;
if(value)
{
char *p = buf;
const char *q = label.c_str();
while((*p++ = toupper(*q++)))
;
ret += "+";
ret += buf;
return ret;
}
return "+" + BSPF::toUpperCase(label);
else
return "-" + label;
return "-" + BSPF::toLowerCase(label);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -15,8 +15,6 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include <cctype>
#include <algorithm>
#include <sstream>
#include "bspf.hxx"
@ -58,8 +56,7 @@ void Properties::set(PropertyType key, const string& value)
case Controller_MouseAxis:
case Display_Phosphor:
{
transform(myProperties[key].begin(), myProperties[key].end(),
myProperties[key].begin(), ::toupper);
BSPF::toUpperCase(myProperties[key]);
break;
}