Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Utilities/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Config.h"
#include "util/types.hpp"
#include "util/yaml.hpp"
#include "util/cctype.hpp"

#include <charconv>

Expand Down Expand Up @@ -712,6 +713,26 @@ bool cfg::node::validate(std::string_view value)
return false;
}

bool cfg::_bool::from_string(std::string_view value, bool /*dynamic*/)
{
if (value.size() != 4 && value.size() != 5)
{
return false;
}

char copy[5];
std::transform(value.begin(), value.end(), std::begin(copy), utils::tolower<char>);

if (value.size() == 5 && std::string_view{copy, 5} == "false")
m_value = false;
else if (value.size() == 4 && std::string_view{copy, 4} == "true")
m_value = true;
else
return false;

return true;
}

std::string cfg::map_entry::get_value(std::string_view key)
{
if (auto it = m_map.find(key); it != m_map.end())
Expand Down
20 changes: 1 addition & 19 deletions Utilities/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,25 +212,7 @@ namespace cfg
return def ? "true" : "false";
}

bool from_string(std::string_view value, bool /*dynamic*/ = false) override
{
if (value.size() != 4 && value.size() != 5)
{
return false;
}

char copy[5];
std::transform(value.begin(), value.end(), std::begin(copy), ::tolower);

if (value.size() == 5 && std::string_view{copy, 5} == "false")
m_value = false;
else if (value.size() == 4 && std::string_view{copy, 4} == "true")
m_value = true;
else
return false;

return true;
}
bool from_string(std::string_view value, bool dynamic = false) override;

void set(const bool& value)
{
Expand Down
4 changes: 3 additions & 1 deletion Utilities/JITLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#if defined(__APPLE__)
#include <pthread.h>
#elif defined(ANDROID)
#include "util/cctype.hpp"
#endif

LOG_CHANNEL(jit_log, "JIT");
Expand Down Expand Up @@ -1039,7 +1041,7 @@ const char * fallback_cpu_detection()
return "cortex-a78";
}

std::transform(result.begin(), result.end(), result.begin(), ::tolower);
std::transform(result.begin(), result.end(), result.begin(), utils::tolower<char>);
return result;
}();

Expand Down
3 changes: 2 additions & 1 deletion Utilities/LUrlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include "LUrlParser.h"
#include "util/cctype.hpp"

#include <algorithm>
#include <cstring>
Expand All @@ -36,7 +37,7 @@ static bool IsSchemeValid( const std::string& SchemeName )
{
return std::all_of(SchemeName.cbegin(), SchemeName.cend(), [](const auto& c)
{
return isalpha(c) || c == '+' || c == '-' || c == '.';
return utils::isalpha(c) || c == '+' || c == '-' || c == '.';
});
}

Expand Down
11 changes: 6 additions & 5 deletions Utilities/StrFmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "cfmt.h"
#include "util/endian.hpp"
#include "util/v128.hpp"
#include "util/cctype.hpp"

#include <locale>
#include <codecvt>
Expand Down Expand Up @@ -198,12 +199,12 @@ fmt::base57_result fmt::base57_result::from_string(std::string_view str)
{
auto to_val = [](u8 c) -> u64
{
if (std::isdigit(c))
if (utils::isdigit(c))
{
return c - '0';
}

if (std::isupper(c))
if (utils::isupper(c))
{
// Omitted characters
if (c == 'B' || c == 'D' || c == 'I' || c == 'O')
Expand Down Expand Up @@ -231,7 +232,7 @@ fmt::base57_result fmt::base57_result::from_string(std::string_view str)
return c - 'A' + 10;
}

if (std::islower(c))
if (utils::islower(c))
{
// Omitted characters
if (c == 'l')
Expand Down Expand Up @@ -952,15 +953,15 @@ std::string fmt::to_upper(std::string_view string)
{
std::string result;
result.resize(string.size());
std::transform(string.begin(), string.end(), result.begin(), ::toupper);
std::transform(string.begin(), string.end(), result.begin(), utils::toupper<char>);
return result;
}

std::string fmt::to_lower(std::string_view string)
{
std::string result;
result.resize(string.size());
std::transform(string.begin(), string.end(), result.begin(), ::tolower);
std::transform(string.begin(), string.end(), result.begin(), utils::tolower<char>);
return result;
}

Expand Down
5 changes: 3 additions & 2 deletions Utilities/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ DYNAMIC_IMPORT_RENAME("Kernel32.dll", SetThreadDescriptionImport, "SetThreadDesc
#include "util/asm.hpp"
#include "util/v128.hpp"
#include "util/simd.hpp"
#include "util/cctype.hpp"
#include "util/sysinfo.hpp"
#include "Emu/Memory/vm_locking.h"

Expand Down Expand Up @@ -185,9 +186,9 @@ bool IsDebuggerPresent()

for (const char* cp = status.data() + found + 10; cp <= status.data() + num_read; ++cp)
{
if (!std::isspace(*cp))
if (!utils::isspace(*cp))
{
return std::isdigit(*cp) != 0 && *cp != '0';
return utils::isdigit(*cp) != 0 && *cp != '0';
}
}

Expand Down
3 changes: 2 additions & 1 deletion Utilities/bin_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "util/types.hpp"
#include "util/asm.hpp"
#include "util/cctype.hpp"

#include <charconv>
#include <regex>
Expand Down Expand Up @@ -329,7 +330,7 @@ bool patch_engine::load(patch_map& patches_map, const std::string& path, std::st
is_valid = false;
continue;
}
else if (serial.size() != 9 || !std::all_of(serial.begin(), serial.end(), [](char c) { return std::isalnum(static_cast<unsigned char>(c)); }))
else if (serial.size() != 9 || !std::all_of(serial.begin(), serial.end(), [](char c) { return utils::isalnum(c); }))
{
append_log_message(log_messages, fmt::format("Error: Serial '%s' invalid (patch: %s, key: %s, location: %s, file: %s)", serial, description, main_key, get_yaml_node_location(serial_node), path), &patch_log.error);
is_valid = false;
Expand Down
12 changes: 7 additions & 5 deletions rpcs3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,19 @@ if(BUILD_RPCS3_TESTS)
target_sources(rpcs3_test
PRIVATE
tests/test.cpp
tests/test_address_range.cpp
tests/test_bit_set.cpp
tests/test_cctype.cpp
tests/test_dmux_pamf.cpp
tests/test_fmt.cpp
tests/test_pair.cpp
tests/test_tuple.cpp
tests/test_simple_array.cpp
tests/test_address_range.cpp
tests/test_sys_fs.cpp
tests/test_rsx_cfg.cpp
tests/test_rsx_fp_asm.cpp
tests/test_dmux_pamf.cpp
tests/test_rsx_mm_queue.cpp
tests/test_simple_array.cpp
tests/test_spu_analyser.cpp
tests/test_sys_fs.cpp
tests/test_tuple.cpp
tests/test_types_util.cpp
)

Expand Down
6 changes: 4 additions & 2 deletions rpcs3/Crypto/unedat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "Emu/system_utils.hpp"

#include "util/asm.hpp"
#include "util/cctype.hpp"

#include <algorithm>
#include <span>

Expand Down Expand Up @@ -628,8 +630,8 @@ bool validate_npd_hashes(std::string_view file_name, const u8* klicensee, const
for (usz i = std::distance(it, buf_span.rend()) - 1; i < buf_len; ++i)
{
const u8 c = buf[i];
buf_upper[i] = std::toupper(c);
buf_lower[i] = std::tolower(c);
buf_upper[i] = utils::toupper(c);
buf_lower[i] = utils::tolower(c);
}

// Hash with NPDRM_OMAC_KEY_3 and compare with title_hash.
Expand Down
13 changes: 7 additions & 6 deletions rpcs3/Emu/Cell/Modules/cellGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Utilities/StrUtil.h"
#include "util/init_mutex.hpp"
#include "util/asm.hpp"
#include "util/cctype.hpp"
#include "Crypto/utils.h"

#include <span>
Expand Down Expand Up @@ -228,13 +229,13 @@ static bool check_system_ver(vm::cptr<char> systemVersion)
return (
systemVersion &&
std::strlen(systemVersion.get_ptr()) == 7 &&
std::isdigit(systemVersion[0]) &&
std::isdigit(systemVersion[1]) &&
utils::isdigit(systemVersion[0]) &&
utils::isdigit(systemVersion[1]) &&
systemVersion[2] == '.' &&
std::isdigit(systemVersion[3]) &&
std::isdigit(systemVersion[4]) &&
std::isdigit(systemVersion[5]) &&
std::isdigit(systemVersion[6])
utils::isdigit(systemVersion[3]) &&
utils::isdigit(systemVersion[4]) &&
utils::isdigit(systemVersion[5]) &&
utils::isdigit(systemVersion[6])
);
}

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/cellKb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "Emu/IdManager.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUModule.h"

#include "Emu/Io/KeyboardHandler.h"
#include "util/cctype.hpp"
#include "cellKb.h"

error_code sys_config_start(ppu_thread& ppu);
Expand Down Expand Up @@ -198,7 +198,7 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode)
const auto get_ascii = [&](u16 raw, u16 shifted = 0, u16 altered = 0)
{
// Usually caps lock only applies uppercase to letters, but some layouts treat it as shift lock for all keys.
if ((is_shift || (is_caps_lock && (is_shift_lock || std::isalpha(raw)))) && shifted)
if ((is_shift || (is_caps_lock && (is_shift_lock || utils::isalpha(raw)))) && shifted)
{
return shifted;
}
Expand Down
Loading
Loading