]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/matita/matitaMisc.ml
milestone in basic_2, λδ-2A reconstructed
[helm.git] / helm / software / matita / matitaMisc.ml
index 266aec526920ad8d96bda49f7cca4cd0d29a2861..687cb94f052de7c1068d90ec4a88ce62c91f7a1e 100644 (file)
@@ -30,7 +30,10 @@ open Printf
 (** 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
@@ -152,7 +155,32 @@ let list_tl_at ?(equality=(==)) e l =
   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"