mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Improved M detection to be more specific.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
3
test/fixtures/m_simple.m
vendored
3
test/fixtures/m_simple.m
vendored
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user