Improved M detection to be more specific.

This commit is contained in:
Laurent Parenteau
2012-03-28 20:30:24 -04:00
parent e0190a5a6e
commit 1e34faa920
2 changed files with 5 additions and 6 deletions

View File

@@ -458,7 +458,7 @@ module Linguist
# * "%" comments # * "%" comments
# #
# M heuristics: # M heuristics:
# * ";" comments # * Look at first line. It is either a comment (1st regex) or label/code (2nd regex)
# #
# Returns a Language. # Returns a Language.
def guess_m_language def guess_m_language
@@ -466,7 +466,7 @@ module Linguist
if lines.grep(/^#import|@(interface|implementation|property|synthesize|end)/).any? if lines.grep(/^#import|@(interface|implementation|property|synthesize|end)/).any?
Language['Objective-C'] Language['Objective-C']
# File function # Matlab leading function keyword
elsif lines.first.to_s =~ /^function / elsif lines.first.to_s =~ /^function /
Language['Matlab'] Language['Matlab']
@@ -474,8 +474,8 @@ module Linguist
elsif lines.grep(/^%/).any? elsif lines.grep(/^%/).any?
Language['Matlab'] Language['Matlab']
# M comment # M (see M heuristics above)
elsif lines.grep(/^[ \t]*;/).any? elsif lines.first.to_s =~ /^[\t ]*;/ or lines.first.to_s =~ /^%?[A-Za-z0-9]+[\t ]*;*/
Language['M'] Language['M']
# Fallback to Objective-C, don't want any Matlab false positives # Fallback to Objective-C, don't want any Matlab false positives

View File

@@ -1,4 +1,3 @@
fox fox ; The quick brown fox jumps over the lazy dog
; The quick brown fox jumps over the lazy dog
write "The quick brown fox jumps over the lazy dog",! write "The quick brown fox jumps over the lazy dog",!
quit quit