]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
chore: Simplify util::add_exe_suffix
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 25 Jan 2025 19:43:33 +0000 (20:43 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Tue, 28 Jan 2025 18:52:16 +0000 (19:52 +0100)
src/ccache/util/path.cpp
src/ccache/util/path.hpp

index 6c3376c3e3ead7e55c6d646f80f224ac1d66c902..434ed20f9fcc5f4ee11d514c0ab2610c309c800d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -36,12 +36,7 @@ namespace util {
 std::string
 add_exe_suffix(const std::string& program)
 {
-  std::string ext = util::to_lowercase(fs::path(program).extension().string());
-  if (ext == ".exe" || ext == ".bat" || ext == ".cmd" || ext == ".sh") {
-    return program;
-  } else {
-    return program + ".exe";
-  }
+  return fs::path(program).has_extension() ? program : program + ".exe";
 }
 
 fs::path
index fe850ef4ff1e0041b429115b6b9bbfad2c184d13..8e566ac484b77895e584114a4e9f79284e790ff0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2024 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -31,8 +31,7 @@ namespace util {
 
 // --- Interface ---
 
-// Add ".exe" suffix to `program` if it doesn't already end with ".exe", ".bat",
-// ".cmd" or ".sh".
+// Add ".exe" suffix to `program` if it doesn't already have an extension.
 std::string add_exe_suffix(const std::string& program);
 
 // Return a new path with `extension` added to `path` (keeping any existing