" ]
[]
channel;
let gauge stats name =
let a, b = ReportStat.summarize stats in
let x = if b = 0 then 100 else (100 * a) / b in
let y = 100 - x in
output_strings
[ "
" ;
"
" ;
"
" ;
"
" ;
"
" ;
"
" ;
"
$(p)%
" ;
"
" ;
"
" ;
"
" ;
"
" ;
"
$(name)
";
"
" ]
[ "g", (if b = 0 then "gaugeNO" else "gaugeOK");
"x", string_of_int x ;
"y", string_of_int y ;
"p", (if b = 0 then "-" else string_of_int x) ;
"name", name ]
channel in
List.iter
(fun (in_file, out_file, stats) ->
gauge stats (Printf.sprintf "%s" out_file in_file))
l;
gauge stats "total";
output_strings
[ "
" ;
"
" ;
" " ;
" " ;
"
$(footer)
" ;
" " ;
"" ]
["footer", html_footer]
channel)
let escape_line tab_size line offset points =
let buff = Buffer.create (String.length line) in
let ofs = ref offset in
let pts = ref points in
let marker n =
Buffer.add_string buff "(*[";
Buffer.add_string buff (string_of_int n);
Buffer.add_string buff "]*)" in
let marker_if_any () =
match !pts with
| (o, n) :: tl when o = !ofs ->
marker n;
pts := tl
| _ -> () in
String.iter
(fun ch ->
marker_if_any ();
(match ch with
| '<' -> Buffer.add_string buff "<"
| '>' -> Buffer.add_string buff ">"
| ' ' -> Buffer.add_string buff " "
| '\"' -> Buffer.add_string buff """
| '&' -> Buffer.add_string buff "&"
| '\t' -> for _i = 1 to tab_size do Buffer.add_string buff " " done
| _ -> Buffer.add_char buff ch);
incr ofs)
line;
List.iter (fun (_, n) -> marker n) !pts;
Buffer.contents buff
let output_html verbose tab_size title no_navbar no_folding in_file out_file script_file script_file_basename resolver visited =
verbose (Printf.sprintf "Processing file '%s'..." in_file);
let cmp_content = Common.read_points (resolver in_file) in
verbose (Printf.sprintf "... file has %d points" (List.length cmp_content));
let len = Array.length visited in
let stats = ReportStat.make () in
let pts = ref (List.map
(fun p ->
let nb =
if p.Common.identifier < len then
visited.(p.Common.identifier)
else
0 in
ReportStat.update stats p.Common.kind (nb > 0);
(p.Common.offset, nb))
cmp_content) in
let in_channel, out_channel = open_both in_file out_file in
(try
let navbar_script =
if no_navbar then
[]
else
[ " " ] in
output_strings
([ "" ;
" " ;
" $(title)" ;
" " ] @
navbar_script @
(if no_folding then
[]
else
[ " " ]) @
[ " " ;
" " ;
"
" ;
" " ] @
fold_links @
[ " " ])
[]
out_channel;
let line_no = ref 0 in
let navigator = ref [] in
let fold_starts = ref [] in
let fold_ends = ref [] in
(try
while true do
incr line_no;
let start_ofs = pos_in in_channel in
let line = input_line in_channel in
let end_ofs = pos_in in_channel in
let before, after = split (fun (o, _) -> o < end_ofs) !pts in
let line' = escape_line tab_size line start_ofs before in
let visited, unvisited =
List.fold_left
(fun (v, u) (_, nb) ->
((v || (nb > 0)), (u || (nb = 0))))
(false, false)
before in
let jump =
Printf.sprintf " style=\"cursor: pointer;\" onclick=\"javascript:jump('line%06d');\" title=\"jump to line %d\""
!line_no
!line_no in
let cls, nav_color, nav_elements, foldable = match visited, unvisited with
| false, false -> "lineNone", "gray", "", true
| true, false -> "lineAllVisited", "gray", "", true
| false, true -> "lineAllUnvisited", "red", jump, false
| true, true -> "lineMixed", "yellow", jump, false in
let starting_fold =
if foldable && (List.length !fold_starts) = (List.length !fold_ends) then begin
fold_starts := !line_no :: !fold_starts;
output_strings
[ "
" ]
[ "line_no", (Printf.sprintf "%06d" !line_no) ]
out_channel;
true
end else
false in
if (not foldable) && (List.length !fold_starts) <> (List.length !fold_ends) then begin
fold_ends := (pred !line_no) :: !fold_ends;
output_strings
[ "
"
nav_color
nav_elements in
navigator := nav_line :: !navigator;
let icon =
if no_folding then
""
else if starting_fold then
Printf.sprintf
""
!line_no
else if foldable then
""
else
"" in
output_strings
[ "
$(icon)$(line_no)| $(line)
" ]
[ "cls", cls ;
"line_no", (Printf.sprintf "%06d" !line_no) ;
"line", (if line' = "" then " " else line') ;
"icon", icon ]
out_channel;
pts := after
done
with End_of_file -> ());
if (List.length !fold_starts) <> (List.length !fold_ends) then begin
fold_ends := (pred !line_no) :: !fold_ends;
output_strings
[ " " ]
[ ]
out_channel
end;
let navigator_div =
if no_navbar then
[]
else
[ "
" ;
" some code - line containing no point " ;
" some code - line containing only visited points " ;
" some code - line containing only unvisited points " ;
" some code - line containing both visited and unvisited points " ;
" " ;
" " ;
"