aboutsummaryrefslogtreecommitdiff
path: root/plugins/extraction/extract_env.ml
diff options
context:
space:
mode:
authorletouzey2012-10-30 14:16:06 +0000
committerletouzey2012-10-30 14:16:06 +0000
commita14e4c0670eda14686a6fcf24b909f9fc3e1e3d3 (patch)
tree893b2e601fd9b1f04ae17e3d79c69eff91213b42 /plugins/extraction/extract_env.ml
parent6cd21c58557309919083610caff4a0b65a5c041f (diff)
Extraction: avoid initial strange empty comments after Arnaud's hack
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@15942 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'plugins/extraction/extract_env.ml')
-rw-r--r--plugins/extraction/extract_env.ml16
1 files changed, 10 insertions, 6 deletions
diff --git a/plugins/extraction/extract_env.ml b/plugins/extraction/extract_env.ml
index f49b1f3751..0b4047f178 100644
--- a/plugins/extraction/extract_env.ml
+++ b/plugins/extraction/extract_env.ml
@@ -453,6 +453,13 @@ let formatter dry file =
(* note: max_indent should be < margin above, otherwise it's ignored *)
ft
+let get_comment () =
+ let s = file_comment () in
+ if s = "" then None
+ else
+ let split_comment = Str.split (Str.regexp "[ \t\n]+") s in
+ Some (prlist_with_sep spc str split_comment)
+
let print_structure_to_file (fn,si,mo) dry struc =
Buffer.clear buf;
let d = descr () in
@@ -473,14 +480,11 @@ let print_structure_to_file (fn,si,mo) dry struc =
(* Print the implementation *)
let cout = if dry then None else Option.map open_out fn in
let ft = formatter dry cout in
- let file_comment =
- let split_comment = Str.split (Str.regexp "[ \t\n]+") (file_comment ()) in
- prlist_with_sep spc str split_comment
- in
+ let comment = get_comment () in
begin try
(* The real printing of the implementation *)
set_phase Impl;
- pp_with ft (d.preamble mo file_comment opened unsafe_needs);
+ pp_with ft (d.preamble mo comment opened unsafe_needs);
pp_with ft (d.pp_struct struc);
Option.iter close_out cout;
with e ->
@@ -494,7 +498,7 @@ let print_structure_to_file (fn,si,mo) dry struc =
let ft = formatter false (Some cout) in
begin try
set_phase Intf;
- pp_with ft (d.sig_preamble mo file_comment opened unsafe_needs);
+ pp_with ft (d.sig_preamble mo comment opened unsafe_needs);
pp_with ft (d.pp_sig (signature_of_structure struc));
close_out cout;
with e ->