Skip to content

Commit 9037de1

Browse files
Peter Oberparleiteroberpar
authored andcommitted
genhtml: handle source files in root directory gracefully
1 parent 68dd0f1 commit 9037de1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bin/genhtml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use Digest::MD5 qw(md5_base64);
7272

7373
# Global constants
7474
our $title = "LCOV - code coverage report";
75-
our $lcov_version = 'LCOV version 1.10 pre (CVS $Revision: 1.67 $)';
75+
our $lcov_version = 'LCOV version 1.10 pre (CVS $Revision: 1.68 $)';
7676
our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
7777
our $tool_name = basename($0);
7878

@@ -799,6 +799,9 @@ sub gen_html()
799799
$br_found, $br_hit)
800800
= process_dir($dir_name);
801801

802+
# Handle files in root directory gracefully
803+
$dir_name = "root" if ($dir_name eq "");
804+
802805
# Remove prefix if applicable
803806
if (!$no_prefix && $dir_prefix)
804807
{
@@ -953,6 +956,10 @@ sub process_dir($)
953956
$rel_dir = substr($rel_dir, 1);
954957
}
955958

959+
# Handle files in root directory gracefully
960+
$rel_dir = "root" if ($rel_dir eq "");
961+
$trunc_dir = "root" if ($trunc_dir eq "");
962+
956963
$base_dir = get_relative_base_path($rel_dir);
957964

958965
create_sub_dir($rel_dir);
@@ -2196,6 +2203,9 @@ sub get_prefix($@)
21962203
}
21972204
}
21982205

2206+
# Check if any prefix remains
2207+
return undef if (!%prefix);
2208+
21992209
# Calculate sum of lengths for all prefixes
22002210
foreach $current (keys(%prefix))
22012211
{

0 commit comments

Comments
 (0)