diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-03-30 14:56:49 +0200 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2025-03-30 14:56:49 +0200 | 
| commit | f1b763881a5a36d63d9826fc4201e38bfc604629 (patch) | |
| tree | 7d7d9514e246f46bc23ce71c99ee9d01efc8056f /src | |
| parent | 0022a217643dd7119df5dc0fcca41161d3201acc (diff) | |
Handle char conversion wrt. to_lower correctly, according to cppreference.
Diffstat (limited to 'src')
| -rw-r--r-- | src/util.cc | 12 | ||||
| -rw-r--r-- | src/util.h | 2 | 
2 files changed, 9 insertions, 5 deletions
| diff --git a/src/util.cc b/src/util.cc index 6fc650a..9052118 100644 --- a/src/util.cc +++ b/src/util.cc @@ -7,12 +7,16 @@  #include <fstream>  #include <algorithm>  #include <sstream> +#include <cctype> -std::string to_lower(const std::string& str) +std::string to_lower(std::string str)  { -	std::string out{str}; -	std::transform(out.begin(), out.end(), out.begin(), ::tolower); -	return out; +	std::transform(str.begin(), str.end(), str.begin(), +	               [](unsigned char c) +	               { +		               return std::tolower(c); +	               }); +	return str;  }  std::string readFile(const std::string& fileName) @@ -9,7 +9,7 @@  #include <filesystem>  #include <cstdlib> -std::string to_lower(const std::string& str); +std::string to_lower(std::string str);  std::string readFile(const std::string& fileName);  ctor::language languageFromExtension(const std::filesystem::path& file); | 
