|
|
|
@ -106,16 +106,11 @@ Glib::RefPtr<Gsv::Language> Source::guess_language(const boost::filesystem::path |
|
|
|
else if(language->get_id() == "octave" && extension == ".m") { |
|
|
|
else if(language->get_id() == "octave" && extension == ".m") { |
|
|
|
// .m is used for both Octave and Objective-C, so try to differentiate
|
|
|
|
// .m is used for both Octave and Objective-C, so try to differentiate
|
|
|
|
std::ifstream input(file_path.string(), std::ios::binary); |
|
|
|
std::ifstream input(file_path.string(), std::ios::binary); |
|
|
|
std::string buffer(256, '\0'); |
|
|
|
std::string line; |
|
|
|
input.read(&buffer[0], static_cast<std::streamsize>(buffer.size())); |
|
|
|
if(input && std::getline(input, line) && |
|
|
|
buffer.resize(static_cast<std::size_t>(input.gcount())); |
|
|
|
(starts_with(line, "#import ") || starts_with(line, "@interface ") || starts_with(line, "/*") || starts_with(line, "//"))) |
|
|
|
if(input && (buffer.find("#import ") != std::string::npos || |
|
|
|
|
|
|
|
buffer.find("@interface ") != std::string::npos || |
|
|
|
|
|
|
|
buffer.find("/*") != std::string::npos || |
|
|
|
|
|
|
|
buffer.find("//") != std::string::npos)) { |
|
|
|
|
|
|
|
language = language_manager->get_language("objc"); |
|
|
|
language = language_manager->get_language("objc"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return language; |
|
|
|
return language; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|