mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
chore: apply light lints (#2570)
This commit is contained in:
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
Submodule lib/external/pattern_language updated: f213e0a6f0...a06da46a3c
@@ -16,7 +16,7 @@ EXPORT_MODULE namespace hex {
|
||||
void stopServices();
|
||||
}
|
||||
|
||||
void registerService(const UnlocalizedString &unlocalizedString, const impl::Callback &callback);
|
||||
void registerService(const UnlocalizedString &unlocalizedName, const impl::Callback &callback);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <numbers>
|
||||
#include <array>
|
||||
|
||||
#include <opengl_support.h>
|
||||
#include "imgui.h"
|
||||
@@ -935,7 +936,7 @@ namespace hex::gl {
|
||||
void attachTexture(const Texture &texture) const;
|
||||
|
||||
private:
|
||||
GLuint m_frameBuffer, m_renderBuffer;
|
||||
GLuint m_frameBuffer = 0, m_renderBuffer = 0;
|
||||
};
|
||||
|
||||
class AxesVectors {
|
||||
|
||||
@@ -264,8 +264,7 @@ namespace hex {
|
||||
}
|
||||
}
|
||||
|
||||
if (json.empty())
|
||||
return;
|
||||
if (json.empty()) return;
|
||||
|
||||
#if defined(OS_WEB)
|
||||
auto data = json.dump();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include <hex/api/event_manager.hpp>
|
||||
|
||||
namespace hex {
|
||||
@@ -35,7 +36,7 @@ namespace hex {
|
||||
|
||||
void EventManager::unsubscribe(void *token, impl::EventId id) {
|
||||
auto &tokenStore = getTokenStore();
|
||||
auto iter = std::find_if(tokenStore.begin(), tokenStore.end(), [&](auto &item) {
|
||||
auto iter = std::ranges::find_if(tokenStore, [&](auto &item) {
|
||||
return item.first == token && item.second->first == id;
|
||||
});
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace hex {
|
||||
definition.fallbackLanguageId = item["fallback"].get<std::string>();
|
||||
}
|
||||
|
||||
if (item.contains("hidden") && item["hidden"].get<bool>() == true) {
|
||||
if (item.contains("hidden") && item["hidden"].get<bool>()) {
|
||||
definition.hidden = true;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace hex {
|
||||
static AutoReset<std::unordered_map<std::size_t, std::string>> loadedLocalization;
|
||||
static std::mutex mutex;
|
||||
|
||||
std::lock_guard lock(mutex);
|
||||
std::scoped_lock lock(mutex);
|
||||
if (*currentLanguageId != languageId) {
|
||||
currentLanguageId = languageId;
|
||||
loadedLocalization->clear();
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
Plugin::Plugin(const std::string &name, const hex::PluginFunctions &functions) :
|
||||
m_handle(0), m_path(name), m_addedManually(true), m_functions(functions) { }
|
||||
m_path(name), m_addedManually(true), m_functions(functions) { }
|
||||
|
||||
|
||||
Plugin::Plugin(Plugin &&other) noexcept {
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace hex {
|
||||
namespace {
|
||||
|
||||
void skipWhitespace(std::string_view &string) {
|
||||
while (string.length() > 0) {
|
||||
while (!string.empty()) {
|
||||
if (!std::isspace(string.front()))
|
||||
break;
|
||||
string = string.substr(1);
|
||||
@@ -89,7 +89,7 @@ namespace hex {
|
||||
return { };
|
||||
|
||||
bool inString = false;
|
||||
while (string.length() > 0) {
|
||||
while (!string.empty()) {
|
||||
BinaryPattern::Pattern pattern = { 0, 0 };
|
||||
|
||||
if (string.starts_with("\"")) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include <hex/helpers/default_paths.hpp>
|
||||
|
||||
#include <hex/api/imhex_api/system.hpp>
|
||||
@@ -39,7 +40,7 @@ namespace hex::paths {
|
||||
paths.push_back(xdg::DataHomeDir());
|
||||
|
||||
auto dataDirs = xdg::DataDirs();
|
||||
std::copy(dataDirs.begin(), dataDirs.end(), std::back_inserter(paths));
|
||||
std::ranges::copy(dataDirs, std::back_inserter(paths));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -108,7 +109,7 @@ namespace hex::paths {
|
||||
|
||||
// Add the system plugin directory to the path if one was provided at compile time
|
||||
#if defined(OS_LINUX) && defined(SYSTEM_PLUGINS_LOCATION)
|
||||
paths.push_back(SYSTEM_PLUGINS_LOCATION);
|
||||
paths.emplace_back(SYSTEM_PLUGINS_LOCATION);
|
||||
#endif
|
||||
|
||||
return paths;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <ranges>
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/utils/string.hpp>
|
||||
|
||||
@@ -89,9 +90,7 @@ namespace hex {
|
||||
|
||||
|
||||
std::pair<std::string_view, size_t> EncodingFile::getEncodingFor(std::span<const u8> buffer) const {
|
||||
for (auto riter = m_mapping->crbegin(); riter != m_mapping->crend(); ++riter) {
|
||||
const auto &[size, mapping] = *riter;
|
||||
|
||||
for (auto [size, mapping] : std::ranges::reverse_view(*m_mapping)) {
|
||||
if (size > buffer.size()) continue;
|
||||
|
||||
std::vector key(buffer.begin(), buffer.begin() + size);
|
||||
@@ -103,9 +102,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
u64 EncodingFile::getEncodingLengthFor(std::span<u8> buffer) const {
|
||||
for (auto riter = m_mapping->crbegin(); riter != m_mapping->crend(); ++riter) {
|
||||
const auto &[size, mapping] = *riter;
|
||||
|
||||
for (auto [size, mapping] : std::ranges::reverse_view(*m_mapping)) {
|
||||
if (size > buffer.size()) continue;
|
||||
|
||||
std::vector key(buffer.begin(), buffer.begin() + size);
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <xdg.hpp>
|
||||
# if defined(OS_FREEBSD)
|
||||
#include <sys/syslimits.h>
|
||||
# else
|
||||
#include <limits.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#include <cstddef>
|
||||
#include "wolv/types.hpp"
|
||||
#include <cmath>
|
||||
#include <hex/helpers/opengl.hpp>
|
||||
#include <opengl_support.h>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <span>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
#include <numbers>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include <hex/helpers/patches.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
@@ -5,7 +6,6 @@
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <string_view>
|
||||
|
||||
|
||||
namespace hex {
|
||||
@@ -83,7 +83,7 @@ namespace hex {
|
||||
|
||||
[[nodiscard]] UnlocalizedString getTypeName() const override { return ""; }
|
||||
|
||||
const std::map<u64, u8>& getPatches() const {
|
||||
[[nodiscard]] const std::map<u64, u8>& getPatches() const {
|
||||
return m_patches;
|
||||
}
|
||||
private:
|
||||
@@ -92,7 +92,7 @@ namespace hex {
|
||||
|
||||
|
||||
void pushStringBack(std::vector<u8> &buffer, const std::string &string) {
|
||||
std::copy(string.begin(), string.end(), std::back_inserter(buffer));
|
||||
std::ranges::copy(string, std::back_inserter(buffer));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace hex {
|
||||
|
||||
UDPServer::UDPServer(u16 port, Callback callback)
|
||||
: m_port(port), m_callback(std::move(callback)), m_running(false), m_socketFd(-1) {
|
||||
: m_port(port), m_callback(std::move(callback)), m_running(false) {
|
||||
}
|
||||
|
||||
UDPServer::~UDPServer() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include <cwchar>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
@@ -98,7 +99,7 @@ namespace hex {
|
||||
string = wolv::util::replaceStrings(string, ",", "");
|
||||
|
||||
// Check for non-hex characters
|
||||
bool isValidHexString = std::find_if(string.begin(), string.end(), [](char c) {
|
||||
bool isValidHexString = std::ranges::find_if(string, [](char c) {
|
||||
return !std::isxdigit(c) && !std::isspace(c);
|
||||
}) == string.end();
|
||||
|
||||
@@ -824,10 +825,10 @@ namespace hex {
|
||||
|
||||
if (lang.has_value() && !lang->empty() && *lang != "C" && *lang != "C.UTF-8") {
|
||||
auto parts = wolv::util::splitString(*lang, ".");
|
||||
if (parts.size() > 0)
|
||||
if (!parts.empty())
|
||||
return parts[0];
|
||||
else
|
||||
return *lang;
|
||||
return lang;
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
|
||||
@@ -10,13 +10,14 @@ namespace hex {
|
||||
|
||||
void executeCmd(const std::vector<std::string> &argsVector) {
|
||||
std::vector<char*> cArgsVector;
|
||||
for (const auto &str : argsVector) {
|
||||
cArgsVector.reserve(argsVector.size());
|
||||
for (const auto &str : argsVector) {
|
||||
cArgsVector.push_back(const_cast<char*>(str.c_str()));
|
||||
}
|
||||
cArgsVector.push_back(nullptr);
|
||||
|
||||
if (fork() == 0) {
|
||||
execvp(cArgsVector[0], &cArgsVector[0]);
|
||||
execvp(cArgsVector[0], cArgsVector.data());
|
||||
log::error("execvp() failed: {}", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -1516,9 +1516,9 @@ namespace ImGuiExt {
|
||||
|
||||
bool IsDarkBackground(const ImColor& bgColor) {
|
||||
// Extract RGB components in 0–255 range
|
||||
int r = static_cast<int>(bgColor.Value.x * 255.0f);
|
||||
int g = static_cast<int>(bgColor.Value.y * 255.0f);
|
||||
int b = static_cast<int>(bgColor.Value.z * 255.0f);
|
||||
int r = static_cast<int>(bgColor.Value.x * 255.0F);
|
||||
int g = static_cast<int>(bgColor.Value.y * 255.0F);
|
||||
int b = static_cast<int>(bgColor.Value.z * 255.0F);
|
||||
|
||||
// Compute brightness using perceived luminance
|
||||
int brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
||||
|
||||
@@ -22,6 +22,5 @@ namespace hex::trace {
|
||||
};
|
||||
|
||||
StackTraceResult getStackTrace();
|
||||
[[nodiscard]] std::string demangle(const std::string &mangledName);
|
||||
|
||||
}
|
||||
[[nodiscard]] std::string demangle(const std::string &symbolName);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ static std::mutex s_traceMutex;
|
||||
}
|
||||
|
||||
StackTraceResult getStackTrace() {
|
||||
std::lock_guard lock(s_traceMutex);
|
||||
std::scoped_lock lock(s_traceMutex);
|
||||
|
||||
static std::vector<StackFrame> result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user