> 2. Comparison for the incidence of unnamed function parameters to all of them
I am trying out a bit more preparation with OCaml script development for this
report variant.
@initialize:ocaml@
@@
module My_map = Map.Make(Int64)
let m = ref My_map.empty
let counting dir =
let d = Unix.opendir dir in
try while true do
let name = Unix.readdir d in
let length = Int64.of_int (String.length name) in
if My_map.mem length (! m) then
ignore (m := My_map.add length (Int64.add (My_map.find length (! m))
Int64.one) (! m))
else
ignore (m := My_map.add length Int64.one (! m))
done
with End_of_file -> Unix.closedir d
@find@
identifier fu;
@@
*fu(...)
{ ... }
@script:ocaml collection@
area << virtual.folder;
@@
if area = "" then
counting "/"
else
counting area
@finalize:ocaml@
@@
if My_map.is_empty (! m) then
prerr_endline "No result for this analysis!"
else
let delimiter = '|' in
let output key count = Printf.printf "%Li%c%Li\r\n" key delimiter count in
Printf.printf "length%cincidence\r\n" delimiter;
My_map.iter output (! m)
elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt --sp-file
list_file_name_lengths1.cocci ../Probe/f-ptr-test1.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
Using native version of ocamlc/ocamlopt/ocamldep
ocamlopt.opt -shared -o /tmp/list_file_name_lengths1f3bae5.cmxs -g -I
/usr/lib64/ocaml -I /usr/local/share/coccinelle/ocaml
/tmp/list_file_name_lengths1f3bae5.ml
Compilation OK!
Loading ML code of the SP...
HANDLING: ../Probe/f-ptr-test1.c
...
No result for this analysis!
How do you think about such a semantic patch approach?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci