summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2026-01-27 08:33:44 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2026-01-27 08:33:44 +0100
commit175026ba3681bc341ae7e6f322061048a6ac1c46 (patch)
treef23a213365801726d3d6d4c9edfac4646338496a /src
parentad91dbc37429a7118f6e52fbcebd9ef55b57f392 (diff)
A bit of util refactorings
Diffstat (limited to 'src')
-rw-r--r--src/configure.cc8
-rw-r--r--src/util.cc8
-rw-r--r--src/util.h6
3 files changed, 11 insertions, 11 deletions
diff --git a/src/configure.cc b/src/configure.cc
index 0755d42..64b2476 100644
--- a/src/configure.cc
+++ b/src/configure.cc
@@ -902,10 +902,10 @@ int regenerateCache(ctor::settings& settings,
istr << "}\n";
auto new_configuration = istr.str();
- auto current_configuration = readFile(configurationFile);
+ auto current_configuration = readFile(configurationFile.string());
if(current_configuration != new_configuration)
{
- std::ofstream configuration_stream(configurationFile);
+ std::ofstream configuration_stream(configurationFile.string());
configuration_stream << new_configuration;
}
}
@@ -916,10 +916,10 @@ int regenerateCache(ctor::settings& settings,
new_config_stream << "#define HAS_FOO 1\n";
new_config_stream << "//#define HAS_BAR 1\n";
auto new_config = new_config_stream.str();
- auto current_config_content = readFile(configHeaderFile);
+ auto current_config_content = readFile(configHeaderFile.string());
if(current_config_content != new_config)
{
- std::ofstream config_file_stream(configHeaderFile);
+ std::ofstream config_file_stream(configHeaderFile.string());
config_file_stream << new_config;
}
}
diff --git a/src/util.cc b/src/util.cc
index 010cde3..7ca9c11 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -15,7 +15,7 @@ std::string to_lower(std::string str)
std::transform(str.begin(), str.end(), str.begin(),
[](unsigned char c)
{
- return std::tolower(c);
+ return static_cast<char>(std::tolower(c));
});
return str;
}
@@ -84,7 +84,7 @@ bool isClean(char c)
}
}
-std::string cleanUp(const std::string& path)
+std::string cleanUp(std::string_view path)
{
std::string cleaned;
for(const auto& c : path)
@@ -101,7 +101,7 @@ std::string cleanUp(const std::string& path)
return cleaned;
}
-std::string esc(const std::string& in)
+std::string esc(std::string_view in)
{
std::string out;
for(auto c : in)
@@ -118,7 +118,7 @@ std::string esc(const std::string& in)
return out;
}
-std::vector<std::string> get_paths(const std::string& path_env_)
+std::vector<std::string> get_paths(std::string_view path_env_)
{
std::string path_env;
if(!path_env_.empty())
diff --git a/src/util.h b/src/util.h
index 337c1e4..7dbe2bb 100644
--- a/src/util.h
+++ b/src/util.h
@@ -13,7 +13,7 @@ std::string to_lower(std::string str);
std::string readFile(const std::string& fileName);
ctor::language languageFromExtension(const std::filesystem::path& file);
-std::string cleanUp(const std::string& path);
+std::string cleanUp(std::string_view path);
template<typename T>
void append(T& a, const T& b)
@@ -21,13 +21,13 @@ void append(T& a, const T& b)
a.insert(a.end(), b.begin(), b.end());
}
-std::string esc(const std::string& in);
+std::string esc(std::string_view in);
//! Get system paths (ie. env var PATH).
//! If path_env is provided, this search string will be used, other the PATH
//! env variable is used.
//! \returns a vector of the individual toknized paths.
-std::vector<std::string> get_paths(const std::string& path_env = {});
+std::vector<std::string> get_paths(std::string_view path_env = {});
std::string locate(const std::string& app,
const std::vector<std::string>& paths,