}
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) {
-// 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.
//
} // 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)
{
-// 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.
//
#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);