From 55f9faea10589f54754c1901bae70dd50e18ab46 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 13 Mar 2023 08:58:08 +0100 Subject: [PATCH] sys: Updated more code to libwolv --- lib/external/libwolv | 2 +- lib/external/pattern_language | 2 +- lib/libimhex/CMakeLists.txt | 3 +-- lib/libimhex/include/hex/helpers/fs_macos.hpp | 12 ----------- lib/libimhex/include/hex/helpers/utils.hpp | 20 ------------------- lib/libimhex/source/helpers/encoding_file.cpp | 4 +++- .../source/content/data_visualizers.cpp | 3 +-- .../source/content/views/view_yara.cpp | 3 +-- 8 files changed, 8 insertions(+), 41 deletions(-) delete mode 100644 lib/libimhex/include/hex/helpers/fs_macos.hpp diff --git a/lib/external/libwolv b/lib/external/libwolv index f98c18807..3c3843db1 160000 --- a/lib/external/libwolv +++ b/lib/external/libwolv @@ -1 +1 @@ -Subproject commit f98c18807a961dfcbf19dae256361e6b99a265d2 +Subproject commit 3c3843db13a515edd0d3c7c2ed5eae5ffd05bb8f diff --git a/lib/external/pattern_language b/lib/external/pattern_language index 0858a0a1a..f7b6ca47e 160000 --- a/lib/external/pattern_language +++ b/lib/external/pattern_language @@ -1 +1 @@ -Subproject commit 0858a0a1a0309bacaa34670488f7643d53d91849 +Subproject commit f7b6ca47ef6bfc41ca74581669e822b343e6fc6c diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index b1fce8807..3aaf48a03 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -47,8 +47,7 @@ if (APPLE) endif () endif () - set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES} - source/helpers/utils_macos.m) + set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES} source/helpers/utils_macos.m) endif () add_compile_definitions(IMHEX_PROJECT_NAME="${PROJECT_NAME}") diff --git a/lib/libimhex/include/hex/helpers/fs_macos.hpp b/lib/libimhex/include/hex/helpers/fs_macos.hpp deleted file mode 100644 index 1a1ae2c74..000000000 --- a/lib/libimhex/include/hex/helpers/fs_macos.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#if defined(OS_MACOS) - - #include - - extern "C" char * getMacExecutableDirectoryPath(); - extern "C" char * getMacApplicationSupportDirectoryPath(); - - extern "C" void macFree(void *ptr); - -#endif diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index d58d1d81f..cd6e9db41 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -238,26 +238,6 @@ namespace hex { return result; } - template - inline void trimLeft(std::basic_string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { - return !std::isspace(ch) && ch >= 0x20; - })); - } - - template - inline void trimRight(std::basic_string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { - return !std::isspace(ch) && ch >= 0x20; - }).base(), s.end()); - } - - template - inline void trim(std::basic_string &s) { - trimLeft(s); - trimRight(s); - } - float float16ToFloat32(u16 float16); inline bool equalsIgnoreCase(const std::string &left, const std::string &right) { diff --git a/lib/libimhex/source/helpers/encoding_file.cpp b/lib/libimhex/source/helpers/encoding_file.cpp index 7dd2c5854..f585a7dfb 100644 --- a/lib/libimhex/source/helpers/encoding_file.cpp +++ b/lib/libimhex/source/helpers/encoding_file.cpp @@ -1,7 +1,9 @@ #include #include + #include +#include namespace hex { @@ -52,7 +54,7 @@ namespace hex { if (fromBytes.empty()) continue; if (to.length() > 1) - hex::trim(to); + to = wolv::util::trim(to); if (to.empty()) to = " "; diff --git a/plugins/builtin/source/content/data_visualizers.cpp b/plugins/builtin/source/content/data_visualizers.cpp index 298927b3d..8246c839e 100644 --- a/plugins/builtin/source/content/data_visualizers.cpp +++ b/plugins/builtin/source/content/data_visualizers.cpp @@ -316,8 +316,7 @@ namespace hex::plugin::builtin { } if (drawDefaultTextEditingTextBox(address, this->m_inputBuffer, ImGuiInputTextFlags_None)) { - hex::trim(this->m_inputBuffer); - if (auto result = hex::parseBinaryString(this->m_inputBuffer); result.has_value()) { + if (auto result = hex::parseBinaryString(wolv::util::trim(this->m_inputBuffer)); result.has_value()) { *data = result.value(); return true; } diff --git a/plugins/builtin/source/content/views/view_yara.cpp b/plugins/builtin/source/content/views/view_yara.cpp index 2dce17111..e3d08c1b6 100644 --- a/plugins/builtin/source/content/views/view_yara.cpp +++ b/plugins/builtin/source/content/views/view_yara.cpp @@ -294,9 +294,8 @@ namespace hex::plugin::builtin { if (yr_compiler_add_file(compiler, file.getHandle(), nullptr, nullptr) != 0) { std::string errorMessage(0xFFFF, '\x00'); yr_compiler_get_error_message(compiler, errorMessage.data(), errorMessage.size()); - hex::trim(errorMessage); - TaskManager::doLater([this, errorMessage] { + TaskManager::doLater([this, errorMessage = wolv::util::trim(errorMessage)] { this->clearResult(); this->m_consoleMessages.push_back("Error: " + errorMessage);