summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Weis <Pierre.Weis@inria.fr>2005-09-30 16:15:18 +0000
committerPierre Weis <Pierre.Weis@inria.fr>2005-09-30 16:15:18 +0000
commit19096f90f3a9a0c60cfa2a4e4f27f19f3640dfe0 (patch)
tree0897b111ca716a07d3e3fa1acedbf7ba8363b6e4
parent728fbc648eae4ffdde267a7d3a558bd6f61425dc (diff)
Hard bug in printf: when the first argument to print was a floating point
number, the printing process failed and we had a fatal error. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@7095 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rwxr-xr-xboot/ocamlcbin1002697 -> 1004338 bytes
-rwxr-xr-xboot/ocamllexbin157591 -> 159186 bytes
-rw-r--r--stdlib/printf.ml46
-rw-r--r--stdlib/sys.ml2
4 files changed, 36 insertions, 12 deletions
diff --git a/boot/ocamlc b/boot/ocamlc
index 3d0c1b409..728d18f79 100755
--- a/boot/ocamlc
+++ b/boot/ocamlc
Binary files differ
diff --git a/boot/ocamllex b/boot/ocamllex
index 277c0dfa7..9993c39fb 100755
--- a/boot/ocamllex
+++ b/boot/ocamllex
Binary files differ
diff --git a/stdlib/printf.ml b/stdlib/printf.ml
index af54f8cc6..43859d591 100644
--- a/stdlib/printf.ml
+++ b/stdlib/printf.ml
@@ -210,22 +210,45 @@ let list_iter_i f l =
loop 0 l;;
(* ``Abstracting'' version of kprintf: returns a (curried) function that
- will print when totally applied. *)
+ will print when totally applied.
+ Note: in the following, we are careful not to be badly caught
+ by the compiler optimizations on the representation of arrays. *)
let kapr kpr fmt =
match nargs_of_format_type fmt with
| 0 -> kpr fmt [||]
- | 1 -> Obj.magic (fun x -> kpr fmt [|x|])
- | 2 -> Obj.magic (fun x y -> kpr fmt [|x; y|])
- | 3 -> Obj.magic (fun x y z -> kpr fmt [|x; y; z|])
- | 4 -> Obj.magic (fun x y z t -> kpr fmt [|x; y; z; t|])
- | 5 -> Obj.magic (fun x y z t u -> kpr fmt [|x; y; z; t; u|])
- | 6 -> Obj.magic (fun x y z t u v -> kpr fmt [|x; y; z; t; u; v|])
+ | 1 -> Obj.magic (fun x ->
+ let a = Array.make 1 (Obj.repr 0) in
+ a.(0) <- x;
+ kpr fmt a)
+ | 2 -> Obj.magic (fun x y ->
+ let a = Array.make 2 (Obj.repr 0) in
+ a.(0) <- x; a.(1) <- y;
+ kpr fmt a)
+ | 3 -> Obj.magic (fun x y z ->
+ let a = Array.make 3 (Obj.repr 0) in
+ a.(0) <- x; a.(1) <- y; a.(2) <- z;
+ kpr fmt a)
+ | 4 -> Obj.magic (fun x y z t ->
+ let a = Array.make 4 (Obj.repr 0) in
+ a.(0) <- x; a.(1) <- y; a.(2) <- z;
+ a.(3) <- t;
+ kpr fmt a)
+ | 5 -> Obj.magic (fun x y z t u ->
+ let a = Array.make 5 (Obj.repr 0) in
+ a.(0) <- x; a.(1) <- y; a.(2) <- z;
+ a.(3) <- t; a.(4) <- u;
+ kpr fmt a)
+ | 6 -> Obj.magic (fun x y z t u v ->
+ let a = Array.make 6 (Obj.repr 0) in
+ a.(0) <- x; a.(1) <- y; a.(2) <- z;
+ a.(3) <- t; a.(4) <- u; a.(5) <- v;
+ kpr fmt a)
| nargs ->
let rec loop i args =
if i >= nargs then
- let v = Array.make nargs (Obj.repr 0) in
- list_iter_i (fun i arg -> v.(nargs - i - 1) <- arg) args;
- kpr fmt v
+ let a = Array.make nargs (Obj.repr 0) in
+ list_iter_i (fun i arg -> a.(nargs - i - 1) <- arg) args;
+ kpr fmt a
else Obj.magic (fun x -> loop (succ i) (x :: args)) in
loop 0 [];;
@@ -288,7 +311,8 @@ let scan_format fmt args n pos cont_s cont_a cont_t cont_f cont_m =
scan_flags n (width :: widths) i
| _, _ -> assert false in
scan_positional_spec fmt got_positional n (succ i)
- | '0'..'9' | '.' | '#' | '-' | ' ' | '+' -> scan_flags n widths (succ i)
+ | '0'..'9'
+ | '.' | '#' | '-' | ' ' | '+' -> scan_flags n widths (succ i)
| _ -> scan_conv n widths i
and scan_conv n widths i =
diff --git a/stdlib/sys.ml b/stdlib/sys.ml
index 4bed116e7..6492c68bc 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.09+dev34 (2005-09-26)";;
+let ocaml_version = "3.09+dev35 (2005-09-30)";;