summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Weis <Pierre.Weis@inria.fr>2009-09-09 15:15:03 +0000
committerPierre Weis <Pierre.Weis@inria.fr>2009-09-09 15:15:03 +0000
commitb549b3ee9e45b46e4d3a07e5e69ca5edcfb0cab7 (patch)
tree059dc605dd8e38cce978f023536f608b2af7834b
parent25d7f8fdc1a9ae8fa9dc38fe0150dc4dc9474b17 (diff)
downloadocaml-b549b3ee9e45b46e4d3a07e5e69ca5edcfb0cab7.tar.gz
Addition of ikprintf as suggested in FR#0004859.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@9327 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rwxr-xr-xboot/ocamlcbin1046450 -> 1046562 bytes
-rwxr-xr-xboot/ocamldepbin290420 -> 290532 bytes
-rw-r--r--stdlib/format.ml5
-rw-r--r--stdlib/format.mli13
4 files changed, 12 insertions, 6 deletions
diff --git a/boot/ocamlc b/boot/ocamlc
index c34966db08..78172cc8ec 100755
--- a/boot/ocamlc
+++ b/boot/ocamlc
Binary files differ
diff --git a/boot/ocamldep b/boot/ocamldep
index fdc3739751..b7d008cb5f 100755
--- a/boot/ocamldep
+++ b/boot/ocamldep
Binary files differ
diff --git a/stdlib/format.ml b/stdlib/format.ml
index 1fcc96995a..37c6af8fa6 100644
--- a/stdlib/format.ml
+++ b/stdlib/format.ml
@@ -1077,8 +1077,8 @@ let implode_rev s0 = function
(* [mkprintf] is the printf-like function generator: given the
- [to_s] flag that tells if we are printing into a string,
- the [get_out] function that has to be called to get a [ppf] function to
- output onto.
- It generates a [kprintf] function that takes as arguments a [k]
+ output onto,
+ it generates a [kprintf] function that takes as arguments a [k]
continuation function to be called at the end of formatting,
and a printing format string to print the rest of the arguments
according to the format string.
@@ -1313,6 +1313,7 @@ let mkprintf to_s get_out =
let kfprintf k ppf = mkprintf false (fun _ -> ppf) k;;
let ifprintf ppf = Tformat.kapr (fun _ -> Obj.magic ignore);;
+let ikfprintf k ppf = Tformat.kapr (fun _ _ -> Obj.magic (k ppf));;
let fprintf ppf = kfprintf ignore ppf;;
let printf fmt = fprintf std_formatter fmt;;
diff --git a/stdlib/format.mli b/stdlib/format.mli
index bab557f8b3..1d4088ad67 100644
--- a/stdlib/format.mli
+++ b/stdlib/format.mli
@@ -640,16 +640,16 @@ val fprintf : out_channel -> ('a, out_channel, unit) format -> 'a;;
It prints [x = 1] within a pretty-printing box.
*)
+val ifprintf : out_channel -> ('a, out_channel, unit) format -> 'a;;
+(** Same as [fprintf] above, but does not print anything.
+ Useful to ignore some material when conditionally printing. *)
+
val printf : ('a, out_channel, unit) format -> 'a;;
(** Same as [fprintf] above, but output on [std_formatter]. *)
val eprintf : ('a, out_channel, unit) format -> 'a;;
(** Same as [fprintf] above, but output on [err_formatter]. *)
-val ifprintf : out_channel -> ('a, out_channel, unit) format -> 'a;;
-(** Same as [fprintf] above, but does not print anything.
- Useful to ignore some material when conditionally printing. *)
-
val sprintf : ('a, unit, string) format -> 'a;;
(** Same as [printf] above, but instead of printing on a formatter,
returns a string containing the result of formatting the arguments.
@@ -678,6 +678,11 @@ val kfprintf : (out_channel -> 'a) -> out_channel ->
(** Same as [fprintf] above, but instead of returning immediately,
passes the formatter to its first argument at the end of printing. *)
+val ikfprintf : (out_channel -> 'a) -> out_channel ->
+ ('b, out_channel, unit, 'a) format4 -> 'b;;
+(** Same as [kfprintf] above, but does not print anything.
+ Useful to ignore some material when conditionally printing. *)
+
val ksprintf : (string -> 'a) -> ('b, unit, string, 'a) format4 -> 'b;;
(** Same as [sprintf] above, but instead of returning the string,
passes it to the first argument. *)