// Previously any value meant true, but this was surprising to users, who
// might do something like CCACHE_DISABLE=0 and expect ccache to be
// enabled.
- std::string lower_value = Util::to_lowercase(value);
+ std::string lower_value = util::to_lowercase(value);
if (value == "0" || lower_value == "false" || lower_value == "disable"
|| lower_value == "no") {
throw core::Error(
{
std::string name(Util::base_name(path));
#ifdef _WIN32
- name = Util::to_lowercase(name);
+ name = util::to_lowercase(name);
#endif
return util::starts_with(name, "ccache");
}
return result;
}
-std::string
-to_lowercase(std::string_view string)
-{
- std::string result;
- result.resize(string.length());
- std::transform(string.begin(), string.end(), result.begin(), tolower);
- return result;
-}
-
#ifdef HAVE_DIRENT_H
void
// Returns a copy of string with the specified ANSI CSI sequences removed.
[[nodiscard]] std::string strip_ansi_csi_seqs(std::string_view string);
-// Convert a string to lowercase.
-[[nodiscard]] std::string to_lowercase(std::string_view string);
-
// Traverse `path` recursively (postorder, i.e. files are visited before their
// parent directory).
//
#include "Util.hpp"
+#include <util/string.hpp>
+
#include <chrono>
#include <thread>
std::string
add_exe_suffix(const std::string& path)
{
- auto ext = Util::to_lowercase(Util::get_extension(path));
+ auto ext = util::to_lowercase(Util::get_extension(path));
if (ext == ".exe" || ext == ".bat" || ext == ".sh") {
return path;
} else {
{
const char* term_env = getenv("TERM");
return isatty(STDERR_FILENO) && term_env
- && Util::to_lowercase(term_env) != "dumb";
+ && util::to_lowercase(term_env) != "dumb";
}
bool
#endif
const auto name =
- Util::to_lowercase(Util::remove_extension(Util::base_name(compiler_path)));
+ util::to_lowercase(Util::remove_extension(Util::base_name(compiler_path)));
if (name.find("clang-cl") != std::string_view::npos) {
return CompilerType::clang_cl;
} else if (name.find("clang") != std::string_view::npos) {
{
const char* path_list = getenv("PATH");
std::string sh;
- if (Util::to_lowercase(Util::get_extension(path)) == ".sh" && path_list) {
+ if (util::to_lowercase(Util::get_extension(path)) == ".sh" && path_list) {
sh = find_executable_in_path("sh.exe", path_list);
}
if (sh.empty() && getenv("CCACHE_DETECT_SHEBANG")) {
return start < end ? std::string(start, end) : std::string();
}
+std::string
+to_lowercase(std::string_view string)
+{
+ std::string result;
+ result.resize(string.length());
+ std::transform(string.begin(), string.end(), result.begin(), tolower);
+ return result;
+}
+
} // namespace util
// Strip whitespace from left and right side of a string.
[[nodiscard]] std::string strip_whitespace(std::string_view string);
+// Convert a string to lowercase.
+[[nodiscard]] std::string to_lowercase(std::string_view string);
+
// --- Inline implementations ---
inline bool
CHECK(Util::remove_extension("/foo/bar/f.abc.txt") == "/foo/bar/f.abc");
}
-TEST_CASE("Util::to_lowercase")
-{
- CHECK(Util::to_lowercase("") == "");
- CHECK(Util::to_lowercase("x") == "x");
- CHECK(Util::to_lowercase("X") == "x");
- CHECK(Util::to_lowercase(" x_X@") == " x_x@");
-}
-
TEST_CASE("Util::traverse")
{
TestContext test_context;
CHECK(util::strip_whitespace(" x y ") == "x y");
}
+TEST_CASE("util::to_lowercase")
+{
+ CHECK(util::to_lowercase("") == "");
+ CHECK(util::to_lowercase("x") == "x");
+ CHECK(util::to_lowercase("X") == "x");
+ CHECK(util::to_lowercase(" x_X@") == " x_x@");
+}
+
TEST_SUITE_END();