Use Common::ToLower and Common::ToUpper
This commit is contained in:
parent
aaec64501a
commit
6e5f4125e3
|
@ -4,7 +4,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -22,9 +21,8 @@ struct CaseInsensitiveStringCompare
|
||||||
bool operator()(std::string_view a, std::string_view b) const
|
bool operator()(std::string_view a, std::string_view b) const
|
||||||
{
|
{
|
||||||
return std::lexicographical_compare(
|
return std::lexicographical_compare(
|
||||||
a.begin(), a.end(), b.begin(), b.end(), [](char lhs, char rhs) {
|
a.begin(), a.end(), b.begin(), b.end(),
|
||||||
return std::tolower(static_cast<u8>(lhs)) < std::tolower(static_cast<u8>(rhs));
|
[](char lhs, char rhs) { return Common::ToLower(lhs) < Common::ToLower(rhs); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsEqual(std::string_view a, std::string_view b)
|
static bool IsEqual(std::string_view a, std::string_view b)
|
||||||
|
@ -33,7 +31,7 @@ struct CaseInsensitiveStringCompare
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char lhs, char rhs) {
|
return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char lhs, char rhs) {
|
||||||
return std::tolower(static_cast<u8>(lhs)) == std::tolower(static_cast<u8>(rhs));
|
return Common::ToLower(lhs) == Common::ToLower(rhs);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -101,8 +101,7 @@ static size_t DeterminePathCutOffPoint()
|
||||||
constexpr const char* pattern2 = "\\source\\core\\";
|
constexpr const char* pattern2 = "\\source\\core\\";
|
||||||
#endif
|
#endif
|
||||||
std::string path = __FILE__;
|
std::string path = __FILE__;
|
||||||
std::transform(path.begin(), path.end(), path.begin(),
|
Common::ToLower(&path);
|
||||||
[](char c) { return std::tolower(c, std::locale::classic()); });
|
|
||||||
size_t pos = path.find(pattern);
|
size_t pos = path.find(pattern);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "Common/Network.h"
|
#include "Common/Network.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -18,6 +17,7 @@
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "Common/Random.h"
|
#include "Common/Random.h"
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,7 @@ std::optional<MACAddress> StringToMacAddress(std::string_view mac_string)
|
||||||
|
|
||||||
for (size_t i = 0; i < mac_string.size() && x < (MAC_ADDRESS_SIZE * 2); ++i)
|
for (size_t i = 0; i < mac_string.size() && x < (MAC_ADDRESS_SIZE * 2); ++i)
|
||||||
{
|
{
|
||||||
char c = tolower(mac_string.at(i));
|
char c = Common::ToLower(mac_string.at(i));
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
{
|
{
|
||||||
mac[x / 2] |= (c - '0') << ((x & 1) ? 0 : 4);
|
mac[x / 2] |= (c - '0') << ((x & 1) ? 0 : 4);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "Common/BitUtils.h"
|
#include "Common/BitUtils.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/Swap.h"
|
#include "Common/Swap.h"
|
||||||
|
|
||||||
namespace ActionReplay
|
namespace ActionReplay
|
||||||
|
@ -462,7 +463,7 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* ops)
|
||||||
|
|
||||||
for (std::string& s : vCodes)
|
for (std::string& s : vCodes)
|
||||||
{
|
{
|
||||||
std::transform(s.begin(), s.end(), s.begin(), toupper);
|
Common::ToUpper(&s);
|
||||||
}
|
}
|
||||||
|
|
||||||
const u32 ret = alphatobin(uCodes.data(), vCodes, (int)vCodes.size());
|
const u32 ret = alphatobin(uCodes.data(), vCodes, (int)vCodes.size());
|
||||||
|
|
|
@ -205,7 +205,7 @@ std::unique_ptr<BootParameters> BootParameters::GenerateFromFile(std::vector<std
|
||||||
std::string folder_path;
|
std::string folder_path;
|
||||||
std::string extension;
|
std::string extension;
|
||||||
SplitPath(paths.front(), &folder_path, nullptr, &extension);
|
SplitPath(paths.front(), &folder_path, nullptr, &extension);
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
Common::ToLower(&extension);
|
||||||
|
|
||||||
if (extension == ".m3u" || extension == ".m3u8")
|
if (extension == ".m3u" || extension == ".m3u8")
|
||||||
{
|
{
|
||||||
|
@ -214,7 +214,7 @@ std::unique_ptr<BootParameters> BootParameters::GenerateFromFile(std::vector<std
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
SplitPath(paths.front(), nullptr, nullptr, &extension);
|
SplitPath(paths.front(), nullptr, nullptr, &extension);
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
Common::ToLower(&extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path = paths.front();
|
std::string path = paths.front();
|
||||||
|
@ -226,7 +226,7 @@ std::unique_ptr<BootParameters> BootParameters::GenerateFromFile(std::vector<std
|
||||||
{
|
{
|
||||||
const std::string display_name = GetAndroidContentDisplayName(path);
|
const std::string display_name = GetAndroidContentDisplayName(path);
|
||||||
SplitPath(display_name, nullptr, nullptr, &extension);
|
SplitPath(display_name, nullptr, nullptr, &extension);
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
Common::ToLower(&extension);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ bool DSPDisassembler::DisassembleOpcode(const u16* binbuf, u16* pc, std::string&
|
||||||
if (is_extended)
|
if (is_extended)
|
||||||
opname += fmt::format("{}{}", settings_.ext_separator, opc_ext->name);
|
opname += fmt::format("{}{}", settings_.ext_separator, opc_ext->name);
|
||||||
if (settings_.lower_case_ops)
|
if (settings_.lower_case_ops)
|
||||||
std::transform(opname.begin(), opname.end(), opname.begin(), ::tolower);
|
Common::ToLower(&opname);
|
||||||
|
|
||||||
if (settings_.print_tabs)
|
if (settings_.print_tabs)
|
||||||
dest += fmt::format("{}\t", opname);
|
dest += fmt::format("{}\t", opname);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "Core/HW/DVD/FileMonitor.h"
|
#include "Core/HW/DVD/FileMonitor.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
@ -29,7 +28,7 @@ static bool IsSoundFile(const std::string& filename)
|
||||||
{
|
{
|
||||||
std::string extension;
|
std::string extension;
|
||||||
SplitPath(filename, nullptr, nullptr, &extension);
|
SplitPath(filename, nullptr, nullptr, &extension);
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
Common::ToLower(&extension);
|
||||||
|
|
||||||
static const std::unordered_set<std::string> extensions = {
|
static const std::unordered_set<std::string> extensions = {
|
||||||
".adp", // 1080 Avalanche, Crash Bandicoot, etc.
|
".adp", // 1080 Avalanche, Crash Bandicoot, etc.
|
||||||
|
|
|
@ -31,8 +31,7 @@ CEXIETHERNET::CEXIETHERNET(BBADeviceType type)
|
||||||
std::string mac_addr_setting = Config::Get(Config::MAIN_BBA_MAC);
|
std::string mac_addr_setting = Config::Get(Config::MAIN_BBA_MAC);
|
||||||
std::optional<Common::MACAddress> mac_addr = Common::StringToMacAddress(mac_addr_setting);
|
std::optional<Common::MACAddress> mac_addr = Common::StringToMacAddress(mac_addr_setting);
|
||||||
|
|
||||||
std::transform(mac_addr_setting.begin(), mac_addr_setting.end(), mac_addr_setting.begin(),
|
Common::ToLower(&mac_addr_setting);
|
||||||
[](unsigned char c) { return std::tolower(c); });
|
|
||||||
|
|
||||||
if (!mac_addr)
|
if (!mac_addr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1132,8 +1132,10 @@ void DirectoryBlobPartition::WriteDirectory(std::vector<FSTBuilderNode>* parent_
|
||||||
// Sort for determinism
|
// Sort for determinism
|
||||||
std::sort(sorted_entries.begin(), sorted_entries.end(),
|
std::sort(sorted_entries.begin(), sorted_entries.end(),
|
||||||
[](const FSTBuilderNode& one, const FSTBuilderNode& two) {
|
[](const FSTBuilderNode& one, const FSTBuilderNode& two) {
|
||||||
const std::string one_upper = ASCIIToUppercase(one.m_filename);
|
std::string one_upper = one.m_filename;
|
||||||
const std::string two_upper = ASCIIToUppercase(two.m_filename);
|
std::string two_upper = two.m_filename;
|
||||||
|
Common::ToUpper(&one_upper);
|
||||||
|
Common::ToUpper(&two_upper);
|
||||||
return one_upper == two_upper ? one.m_filename < two.m_filename :
|
return one_upper == two_upper ? one.m_filename < two.m_filename :
|
||||||
one_upper < two_upper;
|
one_upper < two_upper;
|
||||||
});
|
});
|
||||||
|
@ -1199,12 +1201,4 @@ static void Write32(u32 data, u32 offset, std::vector<u8>* buffer)
|
||||||
(*buffer)[offset++] = (data >> 8) & 0xff;
|
(*buffer)[offset++] = (data >> 8) & 0xff;
|
||||||
(*buffer)[offset] = data & 0xff;
|
(*buffer)[offset] = data & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string ASCIIToUppercase(std::string str)
|
|
||||||
{
|
|
||||||
std::transform(str.begin(), str.end(), str.begin(),
|
|
||||||
[](char c) { return std::toupper(c, std::locale::classic()); });
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace DiscIO
|
} // namespace DiscIO
|
||||||
|
|
|
@ -146,13 +146,9 @@ bool FileInfoGCWii::NameCaseInsensitiveEquals(std::string_view other) const
|
||||||
// other is in UTF-8 and this is in Shift-JIS, so we convert so that we can compare correctly
|
// other is in UTF-8 and this is in Shift-JIS, so we convert so that we can compare correctly
|
||||||
const std::string this_utf8 = SHIFTJISToUTF8(this_ptr);
|
const std::string this_utf8 = SHIFTJISToUTF8(this_ptr);
|
||||||
return std::equal(this_utf8.cbegin(), this_utf8.cend(), other.cbegin() + i, other.cend(),
|
return std::equal(this_utf8.cbegin(), this_utf8.cend(), other.cbegin() + i, other.cend(),
|
||||||
[](char a, char b) {
|
[](char a, char b) { return Common::ToLower(a) == Common::ToLower(b); });
|
||||||
return std::tolower(a, std::locale::classic()) ==
|
|
||||||
std::tolower(b, std::locale::classic());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else if (std::tolower(*this_ptr, std::locale::classic()) !=
|
else if (Common::ToLower(*this_ptr) != Common::ToLower(*other_ptr))
|
||||||
std::tolower(*other_ptr, std::locale::classic()))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "DiscIO/RiivolutionPatcher.h"
|
#include "DiscIO/RiivolutionPatcher.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
@ -324,9 +323,8 @@ static bool CaseInsensitiveEquals(std::string_view a, std::string_view b)
|
||||||
{
|
{
|
||||||
if (a.size() != b.size())
|
if (a.size() != b.size())
|
||||||
return false;
|
return false;
|
||||||
return std::equal(a.begin(), a.end(), b.begin(), [](char ca, char cb) {
|
return std::equal(a.begin(), a.end(), b.begin(),
|
||||||
return std::tolower(ca, std::locale::classic()) == std::tolower(cb, std::locale::classic());
|
[](char ca, char cb) { return Common::ToLower(ca) == Common::ToLower(cb); });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FSTBuilderNode* FindFileNodeInFST(std::string_view path, std::vector<FSTBuilderNode>* fst,
|
static FSTBuilderNode* FindFileNodeInFST(std::string_view path, std::vector<FSTBuilderNode>* fst,
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include <cctype>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
|
@ -175,7 +175,7 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index)
|
||||||
// checking the name is probably good (and hacky) enough
|
// checking the name is probably good (and hacky) enough
|
||||||
// but I'll double check with the num of buttons/axes
|
// but I'll double check with the num of buttons/axes
|
||||||
std::string lcasename = GetName();
|
std::string lcasename = GetName();
|
||||||
std::transform(lcasename.begin(), lcasename.end(), lcasename.begin(), tolower);
|
Common::ToLower(&lcasename);
|
||||||
|
|
||||||
if ((std::string::npos != lcasename.find("xbox 360")) &&
|
if ((std::string::npos != lcasename.find("xbox 360")) &&
|
||||||
(10 == SDL_JoystickNumButtons(joystick)) && (5 == SDL_JoystickNumAxes(joystick)) &&
|
(10 == SDL_JoystickNumButtons(joystick)) && (5 == SDL_JoystickNumAxes(joystick)) &&
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#ifdef USE_DISCORD_PRESENCE
|
#ifdef USE_DISCORD_PRESENCE
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -19,6 +18,7 @@
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include "Common/Hash.h"
|
#include "Common/Hash.h"
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -167,8 +167,7 @@ std::string ArtworkForGameId(const std::string& gameid)
|
||||||
if (REGISTERED_GAMES.count(region_neutral_gameid) != 0)
|
if (REGISTERED_GAMES.count(region_neutral_gameid) != 0)
|
||||||
{
|
{
|
||||||
// Discord asset keys can only be lowercase.
|
// Discord asset keys can only be lowercase.
|
||||||
std::transform(region_neutral_gameid.begin(), region_neutral_gameid.end(),
|
Common::ToLower(®ion_neutral_gameid);
|
||||||
region_neutral_gameid.begin(), tolower);
|
|
||||||
return "game_" + region_neutral_gameid;
|
return "game_" + region_neutral_gameid;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -610,7 +610,7 @@ std::string GameFile::GetNetPlayName(const Core::TitleDatabase& title_database)
|
||||||
int disc_number = GetDiscNumber() + 1;
|
int disc_number = GetDiscNumber() + 1;
|
||||||
|
|
||||||
std::string lower_name = name;
|
std::string lower_name = name;
|
||||||
std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower);
|
Common::ToLower(&lower_name);
|
||||||
if (disc_number > 1 &&
|
if (disc_number > 1 &&
|
||||||
lower_name.find(fmt::format("disc {}", disc_number)) == std::string::npos &&
|
lower_name.find(fmt::format("disc {}", disc_number)) == std::string::npos &&
|
||||||
lower_name.find(fmt::format("disc{}", disc_number)) == std::string::npos)
|
lower_name.find(fmt::format("disc{}", disc_number)) == std::string::npos)
|
||||||
|
@ -786,7 +786,7 @@ std::string GameFile::GetFileFormatName() const
|
||||||
case DiscIO::Platform::ELFOrDOL:
|
case DiscIO::Platform::ELFOrDOL:
|
||||||
{
|
{
|
||||||
std::string extension = GetExtension();
|
std::string extension = GetExtension();
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::toupper);
|
Common::ToUpper(&extension);
|
||||||
|
|
||||||
// substr removes the dot
|
// substr removes the dot
|
||||||
return extension.substr(std::min<size_t>(1, extension.size()));
|
return extension.substr(std::min<size_t>(1, extension.size()));
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright 2014 Dolphin Emulator Project
|
// Copyright 2014 Dolphin Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <cctype>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <disasm.h> // From Bochs, fallback included in Externals.
|
#include <disasm.h> // From Bochs, fallback included in Externals.
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
@ -17,6 +16,7 @@
|
||||||
#undef TEST
|
#undef TEST
|
||||||
|
|
||||||
#include "Common/CPUDetect.h"
|
#include "Common/CPUDetect.h"
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/x64Emitter.h"
|
#include "Common/x64Emitter.h"
|
||||||
|
|
||||||
namespace Gen
|
namespace Gen
|
||||||
|
@ -125,7 +125,7 @@ protected:
|
||||||
bool inside_parens = false;
|
bool inside_parens = false;
|
||||||
for (auto c : str)
|
for (auto c : str)
|
||||||
{
|
{
|
||||||
c = tolower(c);
|
c = Common::ToLower(c);
|
||||||
if (c == '(')
|
if (c == '(')
|
||||||
{
|
{
|
||||||
inside_parens = true;
|
inside_parens = true;
|
||||||
|
|
Loading…
Reference in New Issue