Skip to content

Commit

Permalink
Fix language detection (#328)
Browse files Browse the repository at this point in the history
A previous change to `is_language` resulted in all files being assumed
to be C code, which is fixed by this patch.

Signed-off-by: ud2 <[email protected]>
  • Loading branch information
0f-0b authored Nov 12, 2024
1 parent b7ebec0 commit 4aff20d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/lcovutil.pm
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ our $trivial_function_threshold = 5;
our @omit_line_patterns;
our @exclude_function_patterns;

our %languageExtensions = ('c' => 'c|h|i||C|H|I|icc|cpp|cc|cxx|hh|hpp|hxx',
our %languageExtensions = ('c' => 'c|h|i|C|H|I|icc|cpp|cc|cxx|hh|hpp|hxx',
'rtl' => 'v|vh|sv|vhdl?',
'perl' => 'pl|pm',
'python' => 'py',
Expand Down Expand Up @@ -7616,12 +7616,12 @@ sub is_language
{
my ($lang, $filename) = @_;
my $idx = index($filename, '.');
my $ext = $idx == -1 ? '' : substr($filename, $idx + 1);
my $ext = $idx == -1 ? '' : substr($filename, $idx);
foreach my $l (split('\|', $lang)) {
die("unknown language '$l'")
unless exists($lcovutil::languageExtensions{$l});
my $extensions = $lcovutil::languageExtensions{$l};
return 1 if ($ext =~ /($extensions)/);
return 1 if ($ext =~ /\.($extensions)$/);
}
return 0;
}
Expand Down

0 comments on commit 4aff20d

Please sign in to comment.