diff --git a/include/util.hpp b/include/util.hpp index ba91709..f3e20dd 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -66,8 +66,8 @@ std::string which(const std::string& command); bool read_binary_file(std::ifstream& f, std::string& ret); void replace_str(std::string& str, const std::string_view from, const std::string_view to); bool read_exec(std::vector cmd, std::string& output, bool useStdErr = false, bool noerror_print = true); -std::string str_tolower(std::string_view str); -std::string str_toupper(std::string_view str); +std::string str_tolower(std::string str); +std::string str_toupper(std::string str); void strip(std::string& input); std::string read_by_syspath(const std::string_view path); fmt::rgb hexStringToColor(const std::string_view hexstr); diff --git a/src/util.cpp b/src/util.cpp index 7d74f67..725baa8 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -350,20 +350,20 @@ bool read_exec(std::vector cmd, std::string& output, bool useStdErr return false; } -std::string str_tolower(std::string_view str) +std::string str_tolower(std::string str) { - for (char x : str) + for (char& x : str) x = std::tolower(x); - return str.data(); + return str; } -std::string str_toupper(std::string_view str) +std::string str_toupper(std::string str) { - for (char x : str) + for (char& x : str) x = std::toupper(x); - return str.data(); + return str; } // Function to perform binary search on the pci vendors array to find a device from a vendor.