summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stdlib/format.ml1
-rw-r--r--stdlib/format.mli4
-rw-r--r--stdlib/printf.ml2
-rw-r--r--stdlib/printf.mli7
-rw-r--r--stdlib/sys.ml2
5 files changed, 13 insertions, 3 deletions
diff --git a/stdlib/format.ml b/stdlib/format.ml
index 2eb8f6760..f5deb0674 100644
--- a/stdlib/format.ml
+++ b/stdlib/format.ml
@@ -1193,6 +1193,7 @@ let mkprintf to_s get_out =
**************************************************************)
let kfprintf k ppf = mkprintf false (fun _ -> ppf) k;;
+let ifprintf ppf = Printf.kapr (fun _ -> Obj.magic ignore);;
let fprintf ppf = kfprintf ignore ppf;;
let printf fmt = fprintf std_formatter fmt;;
diff --git a/stdlib/format.mli b/stdlib/format.mli
index 04d47080e..c39788495 100644
--- a/stdlib/format.mli
+++ b/stdlib/format.mli
@@ -656,6 +656,10 @@ val kfprintf : (formatter -> 'a) -> formatter ->
(** Same as [fprintf] above, but instead of returning immediately,
passes the formatter to its first argument at the end of printing. *)
+val ifprintf : formatter -> ('a, formatter, unit) format -> 'a;;
+(** Same as [fprintf] 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. *)
diff --git a/stdlib/printf.ml b/stdlib/printf.ml
index 677ad6323..1fbc0c145 100644
--- a/stdlib/printf.ml
+++ b/stdlib/printf.ml
@@ -523,6 +523,8 @@ let mkprintf to_s get_out outc outs flush k fmt =
let kfprintf k oc =
mkprintf false (fun _ -> oc) output_char output_string flush k;;
+let ifprintf oc = kapr (fun _ -> Obj.magic ignore);;
+
let fprintf oc = kfprintf ignore oc;;
let printf fmt = fprintf stdout fmt;;
let eprintf fmt = fprintf stderr fmt;;
diff --git a/stdlib/printf.mli b/stdlib/printf.mli
index 5995a6ba1..b28a8f6df 100644
--- a/stdlib/printf.mli
+++ b/stdlib/printf.mli
@@ -113,10 +113,13 @@ val printf : ('a, out_channel, unit) format -> 'a
val eprintf : ('a, out_channel, unit) format -> 'a
(** Same as {!Printf.fprintf}, but output on [stderr]. *)
+val ifprintf : 'a -> ('b, 'a, unit) format -> 'b
+(** Same as {!Printf.fprintf}, but does not print anything.
+ Useful to ignore some material when conditionally printing. *)
+
val sprintf : ('a, unit, string) format -> 'a
(** Same as {!Printf.fprintf}, but instead of printing on an output channel,
- return a string containing the result of formatting
- the arguments. *)
+ return a string containing the result of formatting the arguments. *)
val bprintf : Buffer.t -> ('a, Buffer.t, unit) format -> 'a
(** Same as {!Printf.fprintf}, but instead of printing on an output channel,
diff --git a/stdlib/sys.ml b/stdlib/sys.ml
index 50845d9f1..da1b69e89 100644
--- a/stdlib/sys.ml
+++ b/stdlib/sys.ml
@@ -78,4 +78,4 @@ let catch_break on =
(* OCaml version string, must be in the format described in sys.mli. *)
-let ocaml_version = "3.10+dev14 (2006-10-27)";;
+let ocaml_version = "3.10+dev15 (2006-11-05)";;