Fix empty .m file

This commit is contained in:
Joshua Peek
2012-05-09 09:52:14 -05:00
parent f56fbffa6d
commit 35fe44549e
3 changed files with 2 additions and 1 deletions

View File

@@ -470,7 +470,7 @@ module Linguist
Language['Objective-C']
# Matlab file function or class or comments
elsif lines.first.grep(/^\s*(function |classdef )/).any? || lines.grep(/^\s*%/).any?
elsif lines.any? && lines.first.grep(/^\s*(function |classdef )/).any? || lines.grep(/^\s*%/).any?
Language['Matlab']
# Fallback to Objective-C, don't want any Matlab false positives

0
test/fixtures/empty.m vendored Normal file
View File

View File

@@ -307,6 +307,7 @@ class TestBlob < Test::Unit::TestCase
assert_equal Language['Perl'], blob("test-perl2.pl").language
# .m disambiguation
assert_equal Language['Objective-C'], blob("empty.m").language
assert_equal Language['Objective-C'], blob("Foo.m").language
assert_equal Language['Objective-C'], blob("hello.m").language
assert_equal Language['Matlab'], blob("matlab_function.m").language