+sub patch_html_output
+{
+ my $filesref = shift;
+
+ open( my $filehandle, ">", $opt_output ) || die "Can't open $opt_output for writing:$!\n";
+
+ my $OUTPUT_FH = select;
+ select $filehandle;
+ print <<EOH;
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
+"http://www.w3.org/TR/REC-html40/loose.dtd">
+<html>
+<head>
+<title>Patch Coverage</title>
+</head>
+<body bgcolor="white">
+EOH
+
+ foreach my $file (keys(%$filesref))
+ {
+ my ($name, $path, $suffix) = fileparse($file, qr{\.[^.]*$});
+ next if($path !~ /^dali/);
+
+ my $patchref = $filesref->{$file}->{"patch"};
+ my $b_lines_ref = $filesref->{$file}->{"b_lines"};
+ my $coverage_ref = $filesref->{$file}->{"coverage"};
+ print "<h2>$file</h2>\n";
+
+ if($coverage_ref)
+ {
+ if( $coverage_ref->{"covered_lines"} > 0
+ ||
+ $coverage_ref->{"uncovered_lines"} > 0 )
+ {
+ print "<p style=\"color:green;\">Covered: " .
+ $coverage_ref->{"covered_lines"} . "<p>" .
+ "<p style=\"color:red;\">Uncovered: " .
+ $coverage_ref->{"uncovered_lines"} . "</span></p>";
+ }
+ }
+ else
+ {
+ print "<p>";
+ my $span=0;
+ if($suffix eq ".cpp" || $suffix eq ".c" || $suffix eq ".h")
+ {
+ print "<span style=\"color:red;\">";
+ $span=1;
+ }
+ print "No coverage found";
+ print "</span>" if $span;
+ }
+ print "</p>";
+
+ for my $patch (@$patchref)
+ {
+ my $hunkstr="Hunk: " . $patch->[0];
+ if( $patch->[1] > 1 )
+ {
+ $hunkstr .= " - " . ($patch->[0]+$patch->[1]-1);
+ }
+ print "<p style=\"font-weight:bold;\">" . $hunkstr . "</p>";
+
+ print "<pre>";
+ for(my $i = 0; $i < $patch->[1]; $i++ )
+ {
+ my $line = $i + $patch->[0];
+ my $num_line_digits=log($line)/log(10);
+ for $i (0..(6-$num_line_digits-1))
+ {
+ print " ";
+ }
+ print "$line ";
+
+ if($coverage_ref)
+ {
+ my $color;
+ if($coverage_ref->{"covered"}->{$line})
+ {
+ print("<span style=\"color:green;\">");
+ }
+ elsif($coverage_ref->{"uncovered"}->{$line})
+ {
+ print("<span style=\"color:red;font-weight:bold;\">");
+ }
+ else
+ {
+ #print("<span style=\"color:black;font-weight:normal;\">");
+ }
+ my $src=$coverage_ref->{"src"}->{$line};
+ chomp($src);
+ #print $color, "$src\n", RESET;
+ print "$src</span>\n";
+ }
+ else
+ {
+ # We don't have coverage data, so print it from the patch instead.
+ my $src = $b_lines_ref->{$line};
+ print "$src\n";
+ }
+ }
+ print "<\pre>\n";
+ }
+ }
+
+ print $filehandle "<hr>\n</body>\n</html>\n";
+ close $filehandle;
+ select $OUTPUT_FH;
+}
+
+