X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=matita%2Fmatita%2Fcontribs%2Flambdadelta%2Fbin%2Frecomm%2FrecommOutput.ml;h=fe8bebe945148fdd03ce6450c4b8b3f1bdbc56ec;hp=5189c7f7790141b113491e39e3c4d2085e299d86;hb=dbc57c92512c04b3fd88f8289bb8dbe99b2f90e0;hpb=baa54e5db0fb93c4242dd1b67a5018ca63206cf6 diff --git a/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml b/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml index 5189c7f77..fe8bebe94 100644 --- a/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml +++ b/matita/matita/contribs/lambdadelta/bin/recomm/recommOutput.ml @@ -2,6 +2,8 @@ module ET = RecommTypes let width = ref 78 +let replace = ref false + let complete s = let l = !width - String.length s - 6 in if l < 0 then begin @@ -19,7 +21,7 @@ let out_src och = function | ET.Mark s -> Printf.fprintf och "(* %s**)" s | ET.Key (s1, s2) -> - Printf.fprintf och "(* %s1%s2*)" s1 s2 + Printf.fprintf och "(* %s%s*)" s1 s2 | ET.Title ss -> let s = String.concat " " ss in Printf.fprintf och "(* %s %s*)" s (complete s) @@ -30,6 +32,14 @@ let out_src och = function Printf.fprintf och "%s%s%s" s1 s2 s3 let write_srcs file srcs = - let och = open_out (file ^ ".new") in + let target = + if !replace then begin + Sys.rename file (file ^ ".old"); + file + end else begin + file ^ ".new" + end + in + let och = open_out target in List.iter (out_src och) srcs; close_out och