v1.0.20 Bug fixes

This commit is contained in:
aristocratos 2021-10-26 23:41:40 +02:00
parent 36c74fb08a
commit 587005f094
5 changed files with 17 additions and 16 deletions

View File

@ -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 ## v1.0.19
* Fixed: Makefile now tests compiler flag compatibility * Fixed: Makefile now tests compiler flag compatibility

View File

@ -53,7 +53,7 @@ namespace Global {
{"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"}, {"#801414", "██████╔╝ ██║ ╚██████╔╝██║ ╚═╝ ╚═╝"},
{"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"}, {"#000000", "╚═════╝ ╚═╝ ╚═════╝ ╚═╝"},
}; };
const string Version = "1.0.19"; const string Version = "1.0.20";
int coreCount; int coreCount;
string overlay; string overlay;

View File

@ -145,12 +145,12 @@ namespace Fx {
for (size_t offset = 0, start_pos = 0, end_pos = 0, next_pos = 0;;) { 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) if ((start_pos = next_pos > 0 ? next_pos : out.find('\x1b', offset)) == string::npos)
break; break;
offset = start_pos; offset = ++start_pos;
if ((end_pos = out.find('m', offset)) == string::npos) if ((end_pos = out.find('m', offset)) == string::npos)
break; 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; continue;
out.replace(start_pos, (end_pos - start_pos) + 1, ""); out.replace(start_pos, end_pos - start_pos, "");
next_pos = 0; next_pos = 0;
} }
out.shrink_to_fit(); out.shrink_to_fit();

View File

@ -21,7 +21,6 @@ tab-size = 4
#include <string> #include <string>
#include <vector> #include <vector>
#include <array> #include <array>
#include <regex>
#include <atomic> #include <atomic>
#include <filesystem> #include <filesystem>
#include <ranges> #include <ranges>
@ -30,7 +29,7 @@ tab-size = 4
#include <tuple> #include <tuple>
#include <pthread.h> #include <pthread.h>
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 ------------------------------------------------------ //? ------------------------------------------------- NAMESPACES ------------------------------------------------------
@ -57,12 +56,6 @@ namespace Fx {
//* Reset text effects and restore theme foregrund and background color //* Reset text effects and restore theme foregrund and background color
extern string reset; 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 //* Return a string with all colors and text styling removed
string uncolor(const string& s); string uncolor(const string& s);

View File

@ -21,7 +21,6 @@ tab-size = 4
#include <cmath> #include <cmath>
#include <unistd.h> #include <unistd.h>
#include <numeric> #include <numeric>
#include <regex>
#include <sys/statvfs.h> #include <sys/statvfs.h>
#include <netdb.h> #include <netdb.h>
#include <ifaddrs.h> #include <ifaddrs.h>
@ -217,9 +216,8 @@ namespace Cpu {
name += n + ' '; name += n + ' ';
} }
name.pop_back(); name.pop_back();
for (const auto& reg : {regex("Processor"), regex("CPU"), regex("\\(R\\)"), regex("\\(TM\\)"), regex("Intel"), for (const auto& replace : {"Processor", "CPU", "(R)", "(TM)", "Intel", "AMD", "Core"}) {
regex("AMD"), regex("Core"), regex("\\d?\\.?\\d+[mMgG][hH][zZ]")}) { name = s_replace(name, replace, "");
name = std::regex_replace(name, reg, "");
} }
name = trim(name); name = trim(name);
} }