Merge branch 'master' into no-language

Conflicts:
	lib/linguist/heuristics.rb
This commit is contained in:
Arfon Smith
2014-12-11 21:17:38 -06:00
13 changed files with 175 additions and 22 deletions

View File

@@ -61,6 +61,14 @@ module Linguist
@heuristic.call(data)
end
disambiguate "BitBake", "BlitzBasic" do |data|
if /^\s*; /.match(data) || data.include?("End Function")
Language["BlitzBasic"]
elsif /^\s*(# |include|require)\b/.match(data)
Language["BitBake"]
end
end
disambiguate "Objective-C", "C++", "C" do |data|
if (/@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data))
Language["Objective-C"]
@@ -156,6 +164,14 @@ module Linguist
end
end
disambiguate "TypeScript", "XML" do |data|
if data.include?("<TS ")
Language["XML"]
else
Language["TypeScript"]
end
end
disambiguate "Frege", "Forth", "Text" do |data|
if /^(: |also |new-device|previous )/.match(data)
Language["Forth"]
@@ -165,13 +181,5 @@ module Linguist
Language["Text"]
end
end
disambiguate "TypeScript", "XML" do |data|
if data.include?("<TS ")
Language["XML"]
else
Language["TypeScript"]
end
end
end
end

View File

@@ -281,6 +281,13 @@ Bison:
- .y
ace_mode: text
BitBake:
type: programming
tm_scope: none
extensions:
- .bb
ace_mode: text
BlitzBasic:
type: programming
aliases:
@@ -3028,6 +3035,13 @@ Volt:
tm_scope: source.d
ace_mode: d
WebIDL:
type: programming
extensions:
- .webidl
tm_scope: source.webidl
ace_mode: text
XC:
type: programming
extensions:

View File

@@ -3,7 +3,6 @@
# This file should only be edited by GitHub staff
- ActionScript
- Bash
- C
- C#
- C++
@@ -27,3 +26,4 @@
- SQL
- Scala
- Scheme
- Shell

View File

@@ -18,23 +18,32 @@ module Linguist
#
# Returns a String or nil
def self.interpreter(data)
lines = data.lines
return unless match = /^#! ?(.+)$/.match(lines.first)
shebang = data.lines.first
tokens = match[1].split(' ')
script = tokens.first.split('/').last
# First line must start with #!
return unless shebang && shebang.start_with?("#!")
# Get the parts of the shebang without the #!
tokens = shebang.sub(/^#!\s*/, '').strip.split(' ')
# There was nothing after the #!
return if tokens.empty?
# Get the name of the interpreter
script = File.basename(tokens.first)
# Get next argument if interpreter was /usr/bin/env
script = tokens[1] if script == 'env'
# If script has an invalid shebang, we might get here
# Interpreter was /usr/bin/env with no arguments
return unless script
# "python2.6" -> "python2"
script.sub! $1, '' if script =~ /(\.\d+)$/
script.sub! /(\.\d+)$/, ''
# Check for multiline shebang hacks that call `exec`
if script == 'sh' &&
lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
data.lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
script = $1
end