summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/util.cc12
-rw-r--r--src/util.h2
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)
diff --git a/src/util.h b/src/util.h
index 8b41014..6e1bc7b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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);