diff options
author | Mattes D <github@xoft.cz> | 2014-08-04 12:02:57 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-08-04 12:02:57 +0200 |
commit | 7b986e65d2b7d7cad6768599ba4298b62b16c35f (patch) | |
tree | dd627e5e467d4bf0f3ed47aa1201b6ab94e9c35a /src/StringUtils.cpp | |
parent | Merge pull request #1283 from Howaner/GlobalFixes (diff) | |
parent | Refactored case-conversion functions. (diff) | |
download | cuberite-7b986e65d2b7d7cad6768599ba4298b62b16c35f.tar cuberite-7b986e65d2b7d7cad6768599ba4298b62b16c35f.tar.gz cuberite-7b986e65d2b7d7cad6768599ba4298b62b16c35f.tar.bz2 cuberite-7b986e65d2b7d7cad6768599ba4298b62b16c35f.tar.lz cuberite-7b986e65d2b7d7cad6768599ba4298b62b16c35f.tar.xz cuberite-7b986e65d2b7d7cad6768599ba4298b62b16c35f.tar.zst cuberite-7b986e65d2b7d7cad6768599ba4298b62b16c35f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/StringUtils.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 0e30e8ebb..5f88cbf64 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -196,9 +196,9 @@ AString TrimString(const AString & str) -AString & StrToUpper(AString & s) +AString & InPlaceLowercase(AString & s) { - std::transform(s.begin(), s.end(), s.begin(), ::toupper); + std::transform(s.begin(), s.end(), s.begin(), ::tolower); return s; } @@ -206,9 +206,9 @@ AString & StrToUpper(AString & s) -AString & StrToLower(AString & s) +AString & InPlaceUppercase(AString & s) { - std::transform(s.begin(), s.end(), s.begin(), ::tolower); + std::transform(s.begin(), s.end(), s.begin(), ::toupper); return s; } @@ -227,16 +227,25 @@ AString StrToLower(const AString & s) +AString StrToUpper(const AString & s) +{ + AString res(s); + std::transform(res.begin(), res.end(), res.begin(), ::toupper); + return res; +} + + + + + int NoCaseCompare(const AString & s1, const AString & s2) { #ifdef _MSC_VER // MSVC has stricmp that compares case-insensitive: return _stricmp(s1.c_str(), s2.c_str()); #else - // Do it the hard way: - AString s1Copy(s1); - AString s2Copy(s2); - return StrToUpper(s1Copy).compare(StrToUpper(s2Copy)); + // Do it the hard way - convert both strings to lowercase: + return StrToLower(s1).compare(StrToLower(s2)); #endif // else _MSC_VER } |