(** Functions "imported" from Http_getter_misc *)
let normalize_dir = Http_getter_misc.normalize_dir
-let strip_suffix = Http_getter_misc.strip_suffix
+let strip_suffix ~suffix s =
+ try
+ Http_getter_misc.strip_suffix ~suffix s
+ with Invalid_argument _ -> s
let absolute_path file =
if file.[0] = '/' then file else Unix.getcwd () ^ "/" ^ file
aux l
let shutup () =
- HLog.set_log_callback (fun _ _ -> ());
+ HLog.set_log_callback (fun _ _ -> ())
+(*
let out = open_out "/dev/null" in
Unix.dup2 (Unix.descr_of_out_channel out) (Unix.descr_of_out_channel stderr)
+*)
+(* FG: out_preamble *********************************************************)
+
+let out_comment och s =
+ let s = if s <> "" && s.[0] = '*' then "#" ^ s else s in
+ Printf.fprintf och "%s%s%s\n\n" "(*" s "*)"
+
+let out_line_comment och s =
+ let l = 70 - String.length s in
+ let s = Printf.sprintf " %s %s" s (String.make l '*') in
+ out_comment och s
+
+let out_preamble och =
+ let rt_base_dir = Filename.dirname Sys.argv.(0) in
+ let path = Filename.concat rt_base_dir "matita.ma.templ" in
+ let lines = 14 in
+ let ich = open_in path in
+ let rec print i =
+ if i > 0 then
+ let s = input_line ich in
+ begin Printf.fprintf och "%s\n" s; print (pred i) end
+ in
+ print lines;
+ out_line_comment och "This file was automatically generated: do not edit"