diff --git a/Unix/t/01_opts.t b/Unix/t/01_opts.t index 8405794..a79f203 100755 --- a/Unix/t/01_opts.t +++ b/Unix/t/01_opts.t @@ -125,6 +125,12 @@ my @Tests = ( 'ref' => '../tests/outputs/issues/166/fake.thy.yaml', }, { + 'name' => '--read-lang-def w/triple_extension', + 'cd' => '../tests/inputs', + 'args' => '--read-lang-def triple_lang_def.txt custom.triple.extension.js', + 'ref' => '../tests/outputs/custom.triple.extension.js.yaml', + }, + { 'name' => 'Forth balanced parentheses #1 (github issue #183)', 'cd' => '../tests/inputs/issues/183', 'args' => 'file.fth', diff --git a/cloc b/cloc index f80f2d9..74bfb5a 100755 --- a/cloc +++ b/cloc @@ -4063,6 +4063,11 @@ sub classify_file { # {{{1 $extension = lc $extension if $ON_WINDOWS; unshift @extension_list, $extension; # examine double ext first } + if ($file =~ /\.([^\.]+\.[^\.]+\.[^\.]+)$/) { # has a triple extension + my $extension = $1; + $extension = lc $extension if $ON_WINDOWS; + unshift @extension_list, $extension; # examine triple ext first + } foreach my $extension (@extension_list) { if ($Not_Code_Extension{$extension} and !$Forced_Extension{$extension}) { diff --git a/tests/inputs/custom.triple.extension.js b/tests/inputs/custom.triple.extension.js new file mode 100644 index 0000000..be707cd --- /dev/null +++ b/tests/inputs/custom.triple.extension.js @@ -0,0 +1 @@ +js 4 diff --git a/tests/inputs/triple_lang_def.txt b/tests/inputs/triple_lang_def.txt new file mode 100644 index 0000000..c87144d --- /dev/null +++ b/tests/inputs/triple_lang_def.txt @@ -0,0 +1,6 @@ +Custom Triple JS + filter call_regexp_common C++ + filter remove_inline //.*$ + extension triple.extension.js + 3rd_gen_scale 1.48 + end_of_line_continuation \\$ diff --git a/tests/outputs/custom.triple.extension.js.yaml b/tests/outputs/custom.triple.extension.js.yaml new file mode 100644 index 0000000..5889005 --- /dev/null +++ b/tests/outputs/custom.triple.extension.js.yaml @@ -0,0 +1,21 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 1.67 + elapsed_seconds : 0.00475001335144043 + n_files : 1 + n_lines : 22 + files_per_second : 210.525724037545 + lines_per_second : 4631.56592882598 + report_file : glossary.json.yaml +Custom Triple JS : + nFiles: 1 + blank: 0 + comment: 0 + code: 1 +SUM: + blank: 0 + comment: 0 + code: 1 + nFiles: 1