From 587005f094ba1b1b4b7da6f8289d621138f01815 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 26 Oct 2021 23:41:40 +0200 Subject: [PATCH] v1.0.20 Bug fixes --- CHANGELOG.md | 10 ++++++++++ src/btop.cpp | 2 +- src/btop_tools.cpp | 6 +++--- src/btop_tools.hpp | 9 +-------- src/linux/btop_collect.cpp | 6 ++---- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6826ef8..46c4310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v1.0.20 + +* Added: Improved cpu sensor detection for Ryzen Mobile, by @adnanpri + +* Changed: Updated makefile + +* Changed: Regex for Fx::uncolor() changed to string search and replace + +* Changed: Removed all use of regex with dedicated string functions + ## v1.0.19 * Fixed: Makefile now tests compiler flag compatibility diff --git a/src/btop.cpp b/src/btop.cpp index bfd1cb7..208da4a 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -53,7 +53,7 @@ namespace Global { {"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"}, {"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"}, }; - const string Version = "1.0.19"; + const string Version = "1.0.20"; int coreCount; string overlay; diff --git a/src/btop_tools.cpp b/src/btop_tools.cpp index 977aa5f..8778dbe 100644 --- a/src/btop_tools.cpp +++ b/src/btop_tools.cpp @@ -145,12 +145,12 @@ namespace Fx { for (size_t offset = 0, start_pos = 0, end_pos = 0, next_pos = 0;;) { if ((start_pos = next_pos > 0 ? next_pos : out.find('\x1b', offset)) == string::npos) break; - offset = start_pos; + offset = ++start_pos; if ((end_pos = out.find('m', offset)) == string::npos) break; - else if (next_pos = out.find('\x1b', offset + 1); end_pos - start_pos > next_pos - start_pos) + else if (next_pos = out.find('\x1b', offset); not isdigit(out[end_pos - 1]) or end_pos - start_pos > next_pos - start_pos) continue; - out.replace(start_pos, (end_pos - start_pos) + 1, ""); + out.replace(start_pos, end_pos - start_pos, ""); next_pos = 0; } out.shrink_to_fit(); diff --git a/src/btop_tools.hpp b/src/btop_tools.hpp index f802c77..c9f9b74 100644 --- a/src/btop_tools.hpp +++ b/src/btop_tools.hpp @@ -21,7 +21,6 @@ tab-size = 4 #include #include #include -#include #include #include #include @@ -30,7 +29,7 @@ tab-size = 4 #include #include -using std::string, std::vector, std::atomic, std::to_string, std::regex, std::tuple, std::array; +using std::string, std::vector, std::atomic, std::to_string, std::tuple, std::array; //? ------------------------------------------------- NAMESPACES ------------------------------------------------------ @@ -57,12 +56,6 @@ namespace Fx { //* Reset text effects and restore theme foregrund and background color extern string reset; - //* Regex for matching color, style and cursor move escape sequences - const regex escape_regex("\033\\[\\d+;?\\d?;?\\d*;?\\d*;?\\d*(m|f|s|u|C|D|A|B){1}"); - - //* Regex for matching only color and style escape sequences - const regex color_regex("\033\\[\\d+;?\\d?;?\\d*;?\\d*;?\\d*(m){1}"); - //* Return a string with all colors and text styling removed string uncolor(const string& s); diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index 761e7e4..1e5c0dc 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -21,7 +21,6 @@ tab-size = 4 #include #include #include -#include #include #include #include @@ -217,9 +216,8 @@ namespace Cpu { name += n + ' '; } name.pop_back(); - for (const auto& reg : {regex("Processor"), regex("CPU"), regex("\\(R\\)"), regex("\\(TM\\)"), regex("Intel"), - regex("AMD"), regex("Core"), regex("\\d?\\.?\\d+[mMgG][hH][zZ]")}) { - name = std::regex_replace(name, reg, ""); + for (const auto& replace : {"Processor", "CPU", "(R)", "(TM)", "Intel", "AMD", "Core"}) { + name = s_replace(name, replace, ""); } name = trim(name); }