1
(**************************************************************************)
3
(* This file is part of Frama-C. *)
5
(* Copyright (C) 2007-2008 *)
6
(* CEA (Commissariat � l'�nergie Atomique) *)
8
(* you can redistribute it and/or modify it under the terms of the GNU *)
9
(* Lesser General Public License as published by the Free Software *)
10
(* Foundation, version 2.1. *)
12
(* It is distributed in the hope that it will be useful, *)
13
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
14
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
15
(* GNU Lesser General Public License for more details. *)
17
(* See the GNU Lesser General Public License version 2.1 *)
18
(* for more details (enclosed in the file licenses/LGPLv2.1). *)
20
(**************************************************************************)
22
(* $Id: pretty_utils.ml,v 1.5 2008/11/04 10:05:05 uid568 Exp $ *)
25
let b = Buffer.create 5 in
26
let return fmt = Format.pp_print_flush fmt (); Buffer.contents b in
27
Format.kfprintf return (Format.formatter_of_buffer b) fmt
29
let space_sep = format_of_string "@ "
30
let nl_sep = format_of_string "@\n"
32
let rec pp_print_string_fill out s =
33
if String.contains s ' ' then begin
34
let i = String.index s ' ' in
35
let l = String.length s in
36
let s1 = String.sub s 0 i in
37
let s2 = String.sub s (i+1) (l - i - 1) in
38
Format.fprintf out "%s@ %a" s1 pp_print_string_fill s2
39
end else Format.pp_print_string out s
41
let open_box = format_of_string "@["
42
let close_box = format_of_string "@]"
44
let pp_list ?(pre=format_of_string "@[")
45
?(sep=format_of_string "") ?(suf=format_of_string "@]")
50
| e::l -> Format.fprintf f "%(%)%a%a" sep pp_elt e aux l
53
| e::l -> Format.fprintf f "%(%)%a%a%(%)" pre pp_elt e aux l suf
56
?(pre=format_of_string "") ?(suf=format_of_string "") pp_elt f o =
59
| Some v -> Format.fprintf f "%(%)%a%(%)" pre pp_elt v suf
61
let pp_cond ?(pr_false=format_of_string "") cond f pr_true =
62
Format.fprintf f "%(%)" (if cond then pr_true else pr_false)
64
let escape_underscores = Str.global_replace (Str.regexp_string "_") "__"
70
compile-command: "make -C ../.. -j"