Skip to content

Commit 4aff20d

Browse files
authored
Fix language detection (#328)
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 <sjx233@qq.com>
1 parent b7ebec0 commit 4aff20d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/lcovutil.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ our $trivial_function_threshold = 5;
345345
our @omit_line_patterns;
346346
our @exclude_function_patterns;
347347

348-
our %languageExtensions = ('c' => 'c|h|i||C|H|I|icc|cpp|cc|cxx|hh|hpp|hxx',
348+
our %languageExtensions = ('c' => 'c|h|i|C|H|I|icc|cpp|cc|cxx|hh|hpp|hxx',
349349
'rtl' => 'v|vh|sv|vhdl?',
350350
'perl' => 'pl|pm',
351351
'python' => 'py',
@@ -7616,12 +7616,12 @@ sub is_language
76167616
{
76177617
my ($lang, $filename) = @_;
76187618
my $idx = index($filename, '.');
7619-
my $ext = $idx == -1 ? '' : substr($filename, $idx + 1);
7619+
my $ext = $idx == -1 ? '' : substr($filename, $idx);
76207620
foreach my $l (split('\|', $lang)) {
76217621
die("unknown language '$l'")
76227622
unless exists($lcovutil::languageExtensions{$l});
76237623
my $extensions = $lcovutil::languageExtensions{$l};
7624-
return 1 if ($ext =~ /($extensions)/);
7624+
return 1 if ($ext =~ /\.($extensions)$/);
76257625
}
76267626
return 0;
76277627
}

0 commit comments

Comments
 (0)