From 18c119f65106996709f23e3445f8c705a7a4edbe Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 27 Aug 2025 21:37:52 +0200 Subject: [PATCH] Slight improvement to last commit --- src/source.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/source.cpp b/src/source.cpp index 9b7c5cc..47b5ba3 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -106,15 +106,10 @@ Glib::RefPtr Source::guess_language(const boost::filesystem::path else if(language->get_id() == "octave" && extension == ".m") { // .m is used for both Octave and Objective-C, so try to differentiate std::ifstream input(file_path.string(), std::ios::binary); - std::string buffer(256, '\0'); - input.read(&buffer[0], static_cast(buffer.size())); - buffer.resize(static_cast(input.gcount())); - if(input && (buffer.find("#import ") != std::string::npos || - buffer.find("@interface ") != std::string::npos || - buffer.find("/*") != std::string::npos || - buffer.find("//") != std::string::npos)) { + std::string line; + if(input && std::getline(input, line) && + (starts_with(line, "#import ") || starts_with(line, "@interface ") || starts_with(line, "/*") || starts_with(line, "//"))) language = language_manager->get_language("objc"); - } } return language; }