Merge pull request #2087 from pchaigno/case-sensitivity

Detection by extension made case-insensitive
This commit is contained in:
Arfon Smith
2015-02-27 14:06:50 -06:00
8 changed files with 176 additions and 30 deletions

View File

@@ -67,7 +67,7 @@ module Linguist
#
# Returns an Array
def extensions
basename, *segments = File.basename(name).split(".")
basename, *segments = File.basename(name).downcase.split(".")
segments.map.with_index do |segment, index|
"." + segments[index..-1].join(".")

View File

@@ -73,7 +73,7 @@ module Linguist
raise ArgumentError, "Extension is missing a '.': #{extension.inspect}"
end
@extension_index[extension] << language
@extension_index[extension.downcase] << language
end
language.interpreters.each do |interpreter|
@@ -191,7 +191,7 @@ module Linguist
# Returns all matching Languages or [] if none were found.
def self.find_by_extension(extname)
extname = ".#{extname}" unless extname.start_with?(".")
@extension_index[extname]
@extension_index[extname.downcase]
end
# DEPRECATED
@@ -528,8 +528,8 @@ module Linguist
if extnames = extensions[name]
extnames.each do |extname|
if !options['extensions'].index { |x| x.end_with? extname }
warn "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml" unless extname == '.script!'
if !options['extensions'].index { |x| x.downcase.end_with? extname.downcase }
warn "#{name} has a sample with extension (#{extname.downcase}) that isn't explicitly defined in languages.yml" unless extname == '.script!'
options['extensions'] << extname
end
end

View File

@@ -204,7 +204,6 @@ Assembly:
- nasm
extensions:
- .asm
- .ASM
- .a51
- .nasm
tm_scope: source.asm.x86
@@ -352,8 +351,6 @@ C:
color: "#555"
extensions:
- .c
- .C
- .H
- .cats
- .h
- .idc
@@ -435,8 +432,6 @@ COBOL:
type: programming
extensions:
- .cob
- .COB
- .CPY
- .cbl
- .ccp
- .cobol
@@ -888,14 +883,6 @@ FORTRAN:
color: "#4d41b1"
extensions:
- .f90
- .F
- .F03
- .F08
- .F77
- .F90
- .F95
- .FOR
- .FPP
- .f
- .f03
- .f08
@@ -939,9 +926,7 @@ Forth:
color: "#341708"
extensions:
- .fth
- .4TH
- .4th
- .F
- .f
- .for
- .forth
@@ -990,7 +975,6 @@ GAS:
group: Assembly
extensions:
- .s
- .S
tm_scope: source.asm.x86
ace_mode: assembly_x86
@@ -1152,7 +1136,6 @@ Graphviz (DOT):
tm_scope: source.dot
extensions:
- .dot
- .DOT
- .gv
ace_mode: text
@@ -2269,7 +2252,6 @@ Perl:
color: "#0298c3"
extensions:
- .pl
- .PL
- .cgi
- .fcgi
- .perl
@@ -2502,8 +2484,6 @@ R:
- splus
extensions:
- .r
- .R
- .Rd
- .rd
- .rsx
filenames:
@@ -2556,7 +2536,6 @@ RMarkdown:
ace_mode: markdown
extensions:
- .rmd
- .Rmd
tm_scope: none
Racket:
@@ -3270,11 +3249,11 @@ XML:
- .sublime-snippet
- .targets
- .tmCommand
- .tml
- .tmLanguage
- .tmPreferences
- .tmSnippet
- .tmTheme
- .tml
- .ts
- .ui
- .urdf