mirror of
https://github.com/KevinMidboe/linguist.git
synced 2026-02-11 10:49:33 +00:00
Merge branch 'master' into revert-2014-revert-1976-path-for-fileblob
This commit is contained in:
@@ -62,6 +62,7 @@ module Linguist
|
|||||||
generated_parser? ||
|
generated_parser? ||
|
||||||
generated_net_docfile? ||
|
generated_net_docfile? ||
|
||||||
generated_postscript? ||
|
generated_postscript? ||
|
||||||
|
compiled_cython_file? ||
|
||||||
generated_protocol_buffer_go? ||
|
generated_protocol_buffer_go? ||
|
||||||
generated_protocol_buffer? ||
|
generated_protocol_buffer? ||
|
||||||
generated_jni_header? ||
|
generated_jni_header? ||
|
||||||
@@ -270,5 +271,17 @@ module Linguist
|
|||||||
# VCR Cassettes have "recorded_with: VCR" in the second last line.
|
# VCR Cassettes have "recorded_with: VCR" in the second last line.
|
||||||
return lines[-2].include?("recorded_with: VCR")
|
return lines[-2].include?("recorded_with: VCR")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Internal: Is this a compiled C/C++ file from Cython?
|
||||||
|
#
|
||||||
|
# Cython-compiled C/C++ files typically contain:
|
||||||
|
# /* Generated by Cython x.x.x on ... */
|
||||||
|
# on the first line.
|
||||||
|
#
|
||||||
|
# Return true or false
|
||||||
|
def compiled_cython_file?
|
||||||
|
return false unless ['.c', '.cpp'].include? extname
|
||||||
|
return lines[0].include?("Generated by Cython")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2213,6 +2213,7 @@ PLSQL:
|
|||||||
- .pkb
|
- .pkb
|
||||||
- .pks
|
- .pks
|
||||||
- .plb
|
- .plb
|
||||||
|
- .plsql
|
||||||
- .sql
|
- .sql
|
||||||
|
|
||||||
#Postgres
|
#Postgres
|
||||||
|
|||||||
93
samples/PLSQL/prime#.plsql
Normal file
93
samples/PLSQL/prime#.plsql
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
create or replace package prime#
|
||||||
|
is
|
||||||
|
invalid_argument_error exception;
|
||||||
|
|
||||||
|
function nth (
|
||||||
|
i_num pls_integer
|
||||||
|
) return number;
|
||||||
|
end prime#;
|
||||||
|
/
|
||||||
|
|
||||||
|
create or replace package body prime#
|
||||||
|
is
|
||||||
|
type t_primes is table of number index by pls_integer;
|
||||||
|
b_primes t_primes;
|
||||||
|
|
||||||
|
function is_prime(
|
||||||
|
i_candidate number
|
||||||
|
) return boolean
|
||||||
|
is
|
||||||
|
l_num number := 1;
|
||||||
|
l_prime number;
|
||||||
|
l_result number;
|
||||||
|
begin
|
||||||
|
if i_candidate < 2 then
|
||||||
|
return false;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
loop
|
||||||
|
l_prime := nth(l_num);
|
||||||
|
if l_prime = i_candidate then
|
||||||
|
return true;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
l_result := i_candidate / l_prime;
|
||||||
|
if l_result = ceil(l_result) then
|
||||||
|
return false;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
l_num := l_num + 1;
|
||||||
|
exit when l_result <= l_prime;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
end is_prime;
|
||||||
|
|
||||||
|
function next (
|
||||||
|
i_prime pls_integer
|
||||||
|
) return number
|
||||||
|
is
|
||||||
|
l_next number;
|
||||||
|
begin
|
||||||
|
l_next := i_prime + case mod(i_prime, 2) when 0 then 1 else 2 end;
|
||||||
|
|
||||||
|
while not is_prime(l_next) loop
|
||||||
|
l_next := l_next + 2;
|
||||||
|
end loop;
|
||||||
|
return l_next;
|
||||||
|
end next;
|
||||||
|
|
||||||
|
function nth (
|
||||||
|
i_num pls_integer
|
||||||
|
) return number
|
||||||
|
is
|
||||||
|
l_index number := 2;
|
||||||
|
l_prime number := 3;
|
||||||
|
begin
|
||||||
|
if i_num < 1
|
||||||
|
or ceil(i_num) != i_num
|
||||||
|
then
|
||||||
|
raise invalid_argument_error;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
case i_num
|
||||||
|
when 1 then return 2;
|
||||||
|
else
|
||||||
|
if b_primes.exists(i_num) then
|
||||||
|
return b_primes(i_num);
|
||||||
|
end if;
|
||||||
|
while l_index < i_num loop
|
||||||
|
l_index := l_index + 1;
|
||||||
|
if b_primes.exists(l_index) then
|
||||||
|
l_prime := b_primes(l_index);
|
||||||
|
else
|
||||||
|
l_prime := next(l_prime);
|
||||||
|
b_primes(l_index) := l_prime;
|
||||||
|
end if;
|
||||||
|
end loop;
|
||||||
|
return l_prime;
|
||||||
|
end case;
|
||||||
|
end nth;
|
||||||
|
|
||||||
|
end prime#;
|
||||||
|
/
|
||||||
@@ -239,6 +239,10 @@ class TestBlob < Minitest::Test
|
|||||||
# Godep saved dependencies
|
# Godep saved dependencies
|
||||||
assert sample_blob("Godeps/Godeps.json").generated?
|
assert sample_blob("Godeps/Godeps.json").generated?
|
||||||
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
|
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
|
||||||
|
|
||||||
|
# Cython-generated C/C++
|
||||||
|
assert sample_blob("C/sgd_fast.c").generated?
|
||||||
|
assert sample_blob("C++/wrapper_inner.cpp").generated?
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_vendored
|
def test_vendored
|
||||||
|
|||||||
Reference in New Issue
Block a user