]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Add supported_source_extension function
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Jan 2021 19:05:35 +0000 (20:05 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 16 Jan 2021 19:05:35 +0000 (20:05 +0100)
src/argprocessing.cpp
src/language.cpp
src/language.hpp

index fb77414fe8a9593a78496a7dfff0818cc379a8e7..42ca43d72ef84e6a9a1f6aaa613c570d312b2afe 100644 (file)
@@ -853,7 +853,7 @@ process_arg(Context& ctx,
   }
 
   if (!args_info.input_file.empty()) {
-    if (!language_for_file(args[i]).empty()) {
+    if (supported_source_extension(args[i])) {
       LOG("Multiple input files: {} and {}", args_info.input_file, args[i]);
       return Statistic::multiple_source_files;
     } else if (!state.found_c_opt && !state.found_dc_opt) {
index 70325eaed5135e1c0e89684a74d91dd7d4660855..3dced4e2c3fe3fa8cb172cd861b4b049ba79aa28 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2021 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -101,6 +101,18 @@ const struct
 
 } // namespace
 
+bool
+supported_source_extension(const std::string& fname)
+{
+  const auto ext = Util::get_extension(fname);
+  for (size_t i = 0; k_ext_lang_table[i].extension; ++i) {
+    if (k_ext_lang_table[i].extension == ext) {
+      return true;
+    }
+  }
+  return false;
+}
+
 std::string
 language_for_file(const std::string& fname)
 {
index 69f7f269e1c2fc024263af13d20adec239aeded3..b90afdf54959aa2f819e8bf874c47fed93c23f80 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2010-2020 Joel Rosdahl and other contributors
+// Copyright (C) 2010-2021 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -22,6 +22,9 @@
 
 #include <string>
 
+// Return whether a filename has a supported source code extension.
+bool supported_source_extension(const std::string& fname);
+
 // Guess the language of `fname` based on its extension. Returns the empty
 // string if the extension is unknown.
 std::string language_for_file(const std::string& fname);