From dafd592cf44c184f9d24e2216bbed5c23e4b23c2 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 7 Jun 2022 18:06:57 +0200 Subject: Refactor the way task names are looked up. --- src/util.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/util.cc') diff --git a/src/util.cc b/src/util.cc index 9bf83cc..92560b6 100644 --- a/src/util.cc +++ b/src/util.cc @@ -110,3 +110,28 @@ Language languageFromExtension(const std::filesystem::path& file) exit(1); return {}; } + +namespace +{ +bool isClean(char c) +{ + return c != '.' && c != '/'; +} +} + +std::string cleanUp(const std::string& path) +{ + std::string cleaned; + for(const auto& c : path) + { + if(isClean(c)) + { + cleaned += c; + } + else + { + cleaned += '_'; + } + } + return cleaned; +} -- cgit v1.2.3