Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

printf fixes

  • Loading branch information...
commit 8901f8c98c49c5813ba7a0b2b71eb706f2bf89c3 1 parent 44ac0ed
Jake Donham authored
View
9 src/stdlib/patches/3.11.0/printf.ml
@@ -168,15 +168,6 @@ let extract_format fmt start stop widths =
Buffer.contents b
;;
-let extract_format_int conv fmt start stop widths =
- let sfmt = extract_format fmt start stop widths in
- match conv with
- | 'n' | 'N' ->
- sfmt.[String.length sfmt - 1] <- 'u';
- sfmt
- | _ -> sfmt
-;;
-
(* Returns the position of the next character following the meta format
string, starting from position [i], inside a given format [fmt].
According to the character [conv], the meta format string is
View
22 src/stdlib/patches/3.11.0/printf.ml.patch
@@ -1,5 +1,5 @@
--- printf.ml.orig 2010-08-18 14:53:57.000000000 -0400
-+++ printf.ml 2010-08-19 15:43:49.000000000 -0400
++++ printf.ml 2010-08-26 16:23:55.000000000 -0400
@@ -1,3 +1,24 @@
+(*
+ * This file is part of ocamljs, OCaml to Javascript compiler
@@ -25,7 +25,23 @@
(***********************************************************************)
(* *)
(* Objective Caml *)
-@@ -476,10 +497,10 @@
+@@ -147,15 +168,6 @@
+ Buffer.contents b
+ ;;
+
+-let extract_format_int conv fmt start stop widths =
+- let sfmt = extract_format fmt start stop widths in
+- match conv with
+- | 'n' | 'N' ->
+- sfmt.[String.length sfmt - 1] <- 'u';
+- sfmt
+- | _ -> sfmt
+-;;
+-
+ (* Returns the position of the next character following the meta format
+ string, starting from position [i], inside a given format [fmt].
+ According to the character [conv], the meta format string is
+@@ -476,10 +488,10 @@
let s =
if conv = 'c' then String.make 1 x else "'" ^ Char.escaped x ^ "'" in
cont_s (next_index spec n) s (succ i)
@@ -38,7 +54,7 @@
cont_s (next_index spec n) s (succ i)
| 'f' | 'e' | 'E' | 'g' | 'G' ->
let (x : float) = get_arg spec n in
-@@ -520,7 +541,7 @@
+@@ -520,7 +532,7 @@
cont_s (next_index spec n) s (succ i)
| _ ->
let (x : int) = get_arg spec n in
View
22 src/stdlib/patches/3.11.1/printf.ml
@@ -169,24 +169,6 @@ let extract_format fmt start stop widths =
Buffer.contents b
;;
-let extract_format_int conv fmt start stop widths =
- let sfmt = extract_format fmt start stop widths in
- match conv with
- | 'n' | 'N' ->
- sfmt.[String.length sfmt - 1] <- 'u';
- sfmt
- | _ -> sfmt
-;;
-
-let extract_format_float conv fmt start stop widths =
- let sfmt = extract_format fmt start stop widths in
- match conv with
- | 'F' ->
- sfmt.[String.length sfmt - 1] <- 'f';
- sfmt
- | _ -> sfmt
-;;
-
(* Returns the position of the next character following the meta format
string, starting from position [i], inside a given format [fmt].
According to the character [conv], the meta format string is
@@ -541,10 +523,10 @@ let scan_format fmt args n pos cont_s cont_a cont_t cont_f cont_m =
let (x : float) = get_arg spec n in
let s = format_float (extract_format fmt pos i widths) x in
cont_s (next_index spec n) s (succ i)
- | 'F' as conv ->
+ | 'F' ->
let (x : float) = get_arg spec n in
let s =
- format_float_lexem (extract_format_float conv fmt pos i widths) x in
+ format_float_lexem (extract_format fmt pos i widths) x in
cont_s (next_index spec n) s (succ i)
| 'B' | 'b' ->
let (x : bool) = get_arg spec n in
View
42 src/stdlib/patches/3.11.1/printf.ml.patch
@@ -1,5 +1,5 @@
--- printf.ml.orig 2010-08-18 14:53:57.000000000 -0400
-+++ printf.ml 2010-08-19 15:43:03.000000000 -0400
++++ printf.ml 2010-08-26 16:25:58.000000000 -0400
@@ -1,3 +1,24 @@
+(*
+ * This file is part of ocamljs, OCaml to Javascript compiler
@@ -25,7 +25,32 @@
(***********************************************************************)
(* *)
(* Objective Caml *)
-@@ -511,10 +532,10 @@
+@@ -148,24 +169,6 @@
+ Buffer.contents b
+ ;;
+
+-let extract_format_int conv fmt start stop widths =
+- let sfmt = extract_format fmt start stop widths in
+- match conv with
+- | 'n' | 'N' ->
+- sfmt.[String.length sfmt - 1] <- 'u';
+- sfmt
+- | _ -> sfmt
+-;;
+-
+-let extract_format_float conv fmt start stop widths =
+- let sfmt = extract_format fmt start stop widths in
+- match conv with
+- | 'F' ->
+- sfmt.[String.length sfmt - 1] <- 'f';
+- sfmt
+- | _ -> sfmt
+-;;
+-
+ (* Returns the position of the next character following the meta format
+ string, starting from position [i], inside a given format [fmt].
+ According to the character [conv], the meta format string is
+@@ -511,19 +514,19 @@
let s =
if conv = 'c' then String.make 1 x else "'" ^ Char.escaped x ^ "'" in
cont_s (next_index spec n) s (succ i)
@@ -38,7 +63,18 @@
cont_s (next_index spec n) s (succ i)
| 'f' | 'e' | 'E' | 'g' | 'G' ->
let (x : float) = get_arg spec n in
-@@ -557,7 +578,7 @@
+ let s = format_float (extract_format fmt pos i widths) x in
+ cont_s (next_index spec n) s (succ i)
+- | 'F' as conv ->
++ | 'F' ->
+ let (x : float) = get_arg spec n in
+ let s =
+- format_float_lexem (extract_format_float conv fmt pos i widths) x in
++ format_float_lexem (extract_format fmt pos i widths) x in
+ cont_s (next_index spec n) s (succ i)
+ | 'B' | 'b' ->
+ let (x : bool) = get_arg spec n in
+@@ -557,7 +560,7 @@
cont_s (next_index spec n) s (succ i)
| _ ->
let (x : int) = get_arg spec n in
View
13 src/stdlib/patches/3.11.2/printf.ml
@@ -169,15 +169,6 @@ let extract_format fmt start stop widths =
Buffer.contents b
;;
-let extract_format_int conv fmt start stop widths =
- let sfmt = extract_format fmt start stop widths in
- match conv with
- | 'n' | 'N' ->
- sfmt.[String.length sfmt - 1] <- 'u';
- sfmt
- | _ -> sfmt
-;;
-
let extract_format_float conv fmt start stop widths =
let sfmt = extract_format fmt start stop widths in
match conv with
@@ -539,11 +530,11 @@ let scan_format fmt args n pos cont_s cont_a cont_t cont_f cont_m =
let (x : float) = get_arg spec n in
let s = format_float (extract_format fmt pos i widths) x in
cont_s (next_index spec n) s (succ i)
- | 'F' as conv ->
+ | 'F' ->
let (x : float) = get_arg spec n in
let s =
if widths = [] then Pervasives.string_of_float x else
- format_float_lexeme (extract_format_float conv fmt pos i widths) x in
+ format_float_lexeme (extract_format fmt pos i widths) x in
cont_s (next_index spec n) s (succ i)
| 'B' | 'b' ->
let (x : bool) = get_arg spec n in
View
34 src/stdlib/patches/3.11.2/printf.ml.patch
@@ -1,5 +1,5 @@
--- printf.ml.orig 2010-08-18 14:53:57.000000000 -0400
-+++ printf.ml 2010-08-19 15:43:27.000000000 -0400
++++ printf.ml 2010-08-26 16:28:35.000000000 -0400
@@ -1,3 +1,24 @@
+(*
+ * This file is part of ocamljs, OCaml to Javascript compiler
@@ -25,7 +25,23 @@
(***********************************************************************)
(* *)
(* Objective Caml *)
-@@ -509,10 +530,10 @@
+@@ -148,15 +169,6 @@
+ Buffer.contents b
+ ;;
+
+-let extract_format_int conv fmt start stop widths =
+- let sfmt = extract_format fmt start stop widths in
+- match conv with
+- | 'n' | 'N' ->
+- sfmt.[String.length sfmt - 1] <- 'u';
+- sfmt
+- | _ -> sfmt
+-;;
+-
+ let extract_format_float conv fmt start stop widths =
+ let sfmt = extract_format fmt start stop widths in
+ match conv with
+@@ -509,20 +521,20 @@
let s =
if conv = 'c' then String.make 1 x else "'" ^ Char.escaped x ^ "'" in
cont_s (next_index spec n) s (succ i)
@@ -38,7 +54,19 @@
cont_s (next_index spec n) s (succ i)
| 'f' | 'e' | 'E' | 'g' | 'G' ->
let (x : float) = get_arg spec n in
-@@ -556,7 +577,7 @@
+ let s = format_float (extract_format fmt pos i widths) x in
+ cont_s (next_index spec n) s (succ i)
+- | 'F' as conv ->
++ | 'F' ->
+ let (x : float) = get_arg spec n in
+ let s =
+ if widths = [] then Pervasives.string_of_float x else
+- format_float_lexeme (extract_format_float conv fmt pos i widths) x in
++ format_float_lexeme (extract_format fmt pos i widths) x in
+ cont_s (next_index spec n) s (succ i)
+ | 'B' | 'b' ->
+ let (x : bool) = get_arg spec n in
+@@ -556,7 +568,7 @@
cont_s (next_index spec n) s (succ i)
| _ ->
let (x : int) = get_arg spec n in
View
22 src/stdlib/patches/3.12.0/printf.ml
@@ -169,24 +169,6 @@ let extract_format fmt start stop widths =
Buffer.contents b
;;
-let extract_format_int conv fmt start stop widths =
- let sfmt = extract_format fmt start stop widths in
- match conv with
- | 'n' | 'N' ->
- sfmt.[String.length sfmt - 1] <- 'u';
- sfmt
- | _ -> sfmt
-;;
-
-let extract_format_float conv fmt start stop widths =
- let sfmt = extract_format fmt start stop widths in
- match conv with
- | 'F' ->
- sfmt.[String.length sfmt - 1] <- 'g';
- sfmt
- | _ -> sfmt
-;;
-
(* Returns the position of the next character following the meta format
string, starting from position [i], inside a given format [fmt].
According to the character [conv], the meta format string is
@@ -548,11 +530,11 @@ let scan_format fmt args n pos cont_s cont_a cont_t cont_f cont_m =
let (x : float) = get_arg spec n in
let s = format_float (extract_format fmt pos i widths) x in
cont_s (next_index spec n) s (succ i)
- | 'F' as conv ->
+ | 'F' ->
let (x : float) = get_arg spec n in
let s =
if widths = [] then Pervasives.string_of_float x else
- format_float_lexeme (extract_format_float conv fmt pos i widths) x in
+ format_float_lexeme (extract_format fmt pos i widths) x in
cont_s (next_index spec n) s (succ i)
| 'B' | 'b' ->
let (x : bool) = get_arg spec n in
View
45 src/stdlib/patches/3.12.0/printf.ml.patch
@@ -1,5 +1,5 @@
---- printf.ml.orig 2010-08-18 14:54:59.000000000 -0400
-+++ printf.ml 2010-08-19 15:44:08.000000000 -0400
+--- printf.ml.orig 2010-08-25 18:45:35.000000000 -0400
++++ printf.ml 2010-08-26 16:29:36.000000000 -0400
@@ -1,3 +1,24 @@
+(*
+ * This file is part of ocamljs, OCaml to Javascript compiler
@@ -25,7 +25,32 @@
(***********************************************************************)
(* *)
(* Objective Caml *)
-@@ -518,10 +539,10 @@
+@@ -148,24 +169,6 @@
+ Buffer.contents b
+ ;;
+
+-let extract_format_int conv fmt start stop widths =
+- let sfmt = extract_format fmt start stop widths in
+- match conv with
+- | 'n' | 'N' ->
+- sfmt.[String.length sfmt - 1] <- 'u';
+- sfmt
+- | _ -> sfmt
+-;;
+-
+-let extract_format_float conv fmt start stop widths =
+- let sfmt = extract_format fmt start stop widths in
+- match conv with
+- | 'F' ->
+- sfmt.[String.length sfmt - 1] <- 'g';
+- sfmt
+- | _ -> sfmt
+-;;
+-
+ (* Returns the position of the next character following the meta format
+ string, starting from position [i], inside a given format [fmt].
+ According to the character [conv], the meta format string is
+@@ -518,20 +521,20 @@
let s =
if conv = 'c' then String.make 1 x else "'" ^ Char.escaped x ^ "'" in
cont_s (next_index spec n) s (succ i)
@@ -38,7 +63,19 @@
cont_s (next_index spec n) s (succ i)
| 'f' | 'e' | 'E' | 'g' | 'G' ->
let (x : float) = get_arg spec n in
-@@ -565,7 +586,7 @@
+ let s = format_float (extract_format fmt pos i widths) x in
+ cont_s (next_index spec n) s (succ i)
+- | 'F' as conv ->
++ | 'F' ->
+ let (x : float) = get_arg spec n in
+ let s =
+ if widths = [] then Pervasives.string_of_float x else
+- format_float_lexeme (extract_format_float conv fmt pos i widths) x in
++ format_float_lexeme (extract_format fmt pos i widths) x in
+ cont_s (next_index spec n) s (succ i)
+ | 'B' | 'b' ->
+ let (x : bool) = get_arg spec n in
+@@ -565,7 +568,7 @@
cont_s (next_index spec n) s (succ i)
| _ ->
let (x : int) = get_arg spec n in
View
5 test/stdlib/stdlib_printf.ml
@@ -5,7 +5,10 @@ let tests = "Stdlib_printf" >::: [
"2" >:: begin fun () -> assert_equal (Printf.sprintf "%u %x %X %o" 10 12 13 14) "10 c D 16" end;
"3" >:: begin fun () -> assert_equal (Printf.sprintf "%s %S" "foo" "bar") "foo \"bar\"" end;
"4" >:: begin fun () -> assert_equal (Printf.sprintf "%c %C" 'a' 'b') "a 'b'" end;
- "5" >:: begin fun () -> assert_equal (Printf.sprintf "%f %F %e %E %g %G" 1.0 2.0 3.0 4.0 5.0 6.0) "1.000000 2. 3.000000e+00 4.000000E+00 5 6" end;
+ "5" >:: begin fun () ->
+ let two = match Sys.ocaml_version with "3.11.1" -> "2.000000" | _ -> "2." in (* bug 3.11.1 *)
+ assert_equal (Printf.sprintf "%f %F %e %E %g %G" 1.0 2.0 3.0 4.0 5.0 6.0) ("1.000000 " ^ two ^ " 3.000000e+00 4.000000E+00 5 6")
+ end;
"6" >:: begin fun () -> assert_equal (Printf.sprintf "%B %b" true false) "true false" end;
"7" >:: begin fun () -> assert_equal (Printf.sprintf "%nd %ni %nu %nx %nX %no" 1n 2n 3n 4n 5n 6n) "1 2 3 4 5 6" end;
]
Please sign in to comment.
Something went wrong with that request. Please try again.