fix cctype usage

According to the documentation, we should cast to unsigned char.
Anything negative is undefined behavior.
This commit is contained in:
Megamouse committed 2026-09-15 17:38:26 +02:00
1 parent b6bdf0d92d
commit ca522cf84c
36 files changed
+524 -115

No files matched your search

+21
View File
@@ -2,6 +2,7 @@
#include "Config.h"
#include "util/types.hpp"
#include "util/yaml.hpp"
#include "util/cctype.hpp"
#include <charconv>
@@ -712,6 +713,26 @@ bool cfg::node::validate(std::string_view value)
return false;
}
bool cfg::_bool::from_string(std::string_view value, bool /*dynamic*/)
{
if (value.size() != 4 && value.size() != 5)
{
return false;
}
char copy[5];
std::transform(value.begin(), value.end(), std::begin(copy), utils::tolower<char>);
if (value.size() == 5 && std::string_view{copy, 5} == "false")
m_value = false;
else if (value.size() == 4 && std::string_view{copy, 4} == "true")
m_value = true;
else
return false;
return true;
}
std::string cfg::map_entry::get_value(std::string_view key)
{
if (auto it = m_map.find(key); it != m_map.end())