summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/gc.mli2
-rw-r--r--stdlib/printf.ml16
-rw-r--r--stdlib/printf.mli23
-rw-r--r--stdlib/random.ml7
-rw-r--r--stdlib/random.mli2
-rw-r--r--stdlib/scanf.ml2
6 files changed, 37 insertions, 15 deletions
diff --git a/stdlib/gc.mli b/stdlib/gc.mli
index 71b8ffa783..45d882f25a 100644
--- a/stdlib/gc.mli
+++ b/stdlib/gc.mli
@@ -158,7 +158,7 @@ external quick_stat : unit -> stat = "caml_gc_quick_stat"
external counters : unit -> float * float * float = "caml_gc_counters"
(** Return [(minor_words, promoted_words, major_words)]. This function
- is as fast at [quick_stat]. *)
+ is as fast as [quick_stat]. *)
external get : unit -> control = "caml_gc_get"
(** Return the current values of the GC parameters in a [control] record. *)
diff --git a/stdlib/printf.ml b/stdlib/printf.ml
index c55c64d367..567949064a 100644
--- a/stdlib/printf.ml
+++ b/stdlib/printf.ml
@@ -638,12 +638,19 @@ let mkprintf to_s get_out outc outs flush k fmt =
kapr kpr fmt
;;
+(**************************************************************
+
+ Defining [fprintf] and various flavors of [fprintf].
+
+ **************************************************************)
+
let kfprintf k oc =
mkprintf false (fun _ -> oc) output_char output_string flush k
;;
-let ifprintf _ = kapr (fun _ -> Obj.magic ignore);;
+let ikfprintf k oc = kapr (fun _ _ -> Obj.magic (k oc));;
let fprintf oc = kfprintf ignore oc;;
+let ifprintf oc = ikfprintf ignore oc;;
let printf fmt = fprintf stdout fmt;;
let eprintf fmt = fprintf stderr fmt;;
@@ -671,7 +678,12 @@ let ksprintf k =
let sprintf fmt = ksprintf (fun s -> s) fmt;;
-(* Obsolete and deprecated. *)
+(**************************************************************
+
+ Deprecated stuff.
+
+ **************************************************************)
+
let kprintf = ksprintf;;
(* For OCaml system internal use only: needed to implement modules [Format]
diff --git a/stdlib/printf.mli b/stdlib/printf.mli
index 6fcb45ebac..f7dca62d61 100644
--- a/stdlib/printf.mli
+++ b/stdlib/printf.mli
@@ -82,7 +82,8 @@ val fprintf : out_channel -> ('a, out_channel, unit) format -> 'a
- [!]: take no argument and flush the output.
- [%]: take no argument and output one [%] character.
- [\@]: take no argument and output one [\@] character.
- - [,]: take no argument and do nothing.
+ - [,]: take no argument and output nothing: a no-op delimiter for
+ conversion specifications.
The optional [flags] are:
- [-]: left-justify the output (default is right justification).
@@ -115,12 +116,6 @@ 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.
- @since 3.10.0
-*)
-
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. *)
@@ -130,6 +125,12 @@ val bprintf : Buffer.t -> ('a, Buffer.t, unit) format -> 'a
append the formatted arguments to the given extensible buffer
(see module {!Buffer}). *)
+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.
+ @since 3.10.0
+*)
+
(** Formatted output functions with continuations. *)
val kfprintf : (out_channel -> 'a) -> out_channel ->
@@ -139,6 +140,14 @@ val kfprintf : (out_channel -> 'a) -> out_channel ->
@since 3.09.0
*)
+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.
+ @since 4.0
+*)
+
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/random.ml b/stdlib/random.ml
index 50b5708220..800c629706 100644
--- a/stdlib/random.ml
+++ b/stdlib/random.ml
@@ -53,7 +53,7 @@ module State = struct
let j = i mod 55 in
let k = i mod l in
accu := combine !accu seed.(k);
- s.st.(j) <- s.st.(j) lxor extract !accu;
+ s.st.(j) <- (s.st.(j) lxor extract !accu) land 0x3FFFFFFF; (* PR#5575 *)
done;
s.idx <- 0;
;;
@@ -78,8 +78,9 @@ module State = struct
let curval = s.st.(s.idx) in
let newval = s.st.((s.idx + 24) mod 55)
+ (curval lxor ((curval lsr 25) land 0x1F)) in
- s.st.(s.idx) <- newval;
- newval land 0x3FFFFFFF (* land is needed for 64-bit arch *)
+ let newval30 = newval land 0x3FFFFFFF in (* PR#5575 *)
+ s.st.(s.idx) <- newval30;
+ newval30
;;
let rec intaux s n =
diff --git a/stdlib/random.mli b/stdlib/random.mli
index 9c66c3a86e..d8ea01e621 100644
--- a/stdlib/random.mli
+++ b/stdlib/random.mli
@@ -67,7 +67,7 @@ val bool : unit -> bool
(** {6 Advanced functions} *)
(** The functions from module [State] manipulate the current state
- of the random generator explicitely.
+ of the random generator explicitly.
This allows using one or several deterministic PRNGs,
even in a multi-threaded program, without interference from
other parts of the program.
diff --git a/stdlib/scanf.ml b/stdlib/scanf.ml
index 37740765d5..cac4a136a4 100644
--- a/stdlib/scanf.ml
+++ b/stdlib/scanf.ml
@@ -483,7 +483,7 @@ let compatible_format_type fmt1 fmt2 =
Tformat.summarize_format_type (string_to_format fmt2);;
(* Checking that [c] is indeed in the input, then skips it.
- In this case, the character c has been explicitely specified in the
+ In this case, the character c has been explicitly specified in the
format as being mandatory in the input; hence we should fail with
End_of_file in case of end_of_input. (Remember that Scan_failure is raised
only when (we can prove by evidence) that the input does not match the