diff options
author | Alain Frisch <alain@frisch.fr> | 2012-01-20 15:43:29 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2012-01-20 15:43:29 +0000 |
commit | a3cc246dec49681e8c71c89acef9ef29321b4dd1 (patch) | |
tree | ffc11dbf2f58242261b55b734e978399c3311bbc /toplevel/expunge.ml | |
parent | f5da2ab926f63bfe21f531a668f6add9bf4f6519 (diff) | |
download | ocaml-a3cc246dec49681e8c71c89acef9ef29321b4dd1.tar.gz |
#4830: Add option -v to expunge.ml.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12061 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'toplevel/expunge.ml')
-rw-r--r-- | toplevel/expunge.ml | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/toplevel/expunge.ml b/toplevel/expunge.ml index 1ff4685ef3..9cdcbf89e1 100644 --- a/toplevel/expunge.ml +++ b/toplevel/expunge.ml @@ -24,23 +24,29 @@ module StringSet = let compare = compare end) +let is_exn = + let h = Hashtbl.create 64 in + Array.iter (fun n -> Hashtbl.add h n ()) Runtimedef.builtin_exceptions; + Hashtbl.mem h + let to_keep = ref StringSet.empty +let negate = Sys.argv.(3) = "-v" + +let keep = + if negate then fun name -> is_exn name || not (StringSet.mem name !to_keep) + else fun name -> is_exn name || (StringSet.mem name !to_keep) + let expunge_map tbl = - Symtable.filter_global_map - (fun id -> StringSet.mem (Ident.name id) !to_keep) - tbl + Symtable.filter_global_map (fun id -> keep (Ident.name id)) tbl let expunge_crcs tbl = - List.filter (fun (unit, crc) -> StringSet.mem unit !to_keep) tbl + List.filter (fun (unit, crc) -> keep unit) tbl let main () = let input_name = Sys.argv.(1) in let output_name = Sys.argv.(2) in - Array.iter - (fun exn -> to_keep := StringSet.add exn !to_keep) - Runtimedef.builtin_exceptions; - for i = 3 to Array.length Sys.argv - 1 do + for i = (if negate then 4 else 3) to Array.length Sys.argv - 1 do to_keep := StringSet.add (String.capitalize Sys.argv.(i)) !to_keep done; let ic = open_in_bin input_name in |