Improved the Obj-C heuristic with a Regex matching multiple unique keywords

Also improved the C++ heuristic by checking for class without an @ on the front.
This commit is contained in:
Rachel Mant
2014-04-02 13:09:17 +01:00
parent fd585beb07
commit 667f3de26b

View File

@@ -37,8 +37,10 @@ module Linguist
# Returns an array of Languages or []
def self.disambiguate_c(data, languages)
matches = []
matches << Language["Objective-C"] if data.include?("@interface")
if (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set)>$/.match(data))
if (/@(interface|class|protocol|synchronised|selector|implementation)/.match(data))
matches << Language["Objective-C"]
if (/^\s*#\s*include <(cstdint|string|vector|map|list|array|bitset|queue|stack|forward_list|unordered_map|unordered_set)>$/.match(data) or
/template\s*</.match(data) or /[^@]class/.match(data))
matches << Language["C++"]
matches
end