Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -Naur ocaml-4.00.1-old/stdlib/camlinternalFormat.ml ocaml-4.00.1-new/stdlib/camlinternalFormat.ml
- --- ocaml-4.00.1-old/stdlib/camlinternalFormat.ml 2013-05-26 16:24:33.089744387 +0200
- +++ ocaml-4.00.1-new/stdlib/camlinternalFormat.ml 2013-05-26 16:25:09.928281312 +0200
- @@ -6,11 +6,12 @@
- (* Reversed list of printing atoms. *)
- (* Used to accumulate printf arguments. *)
- type ('b, 'c) acc =
- - | Acc_formatting of ('b, 'c) acc * formatting (* Special formatting (box) *)
- - | Acc_string of ('b, 'c) acc * string (* Literal or generated string*)
- - | Acc_char of ('b, 'c) acc * char (* Literal or generated char *)
- - | Acc_delay of ('b, 'c) acc * ('b -> 'c) (* Delayed printing (%a, %t) *)
- - | Acc_flush of ('b, 'c) acc (* Flush *)
- + | Acc_formatting of ('b, 'c) acc * formatting(* Special formatting (box) *)
- + | Acc_string of ('b, 'c) acc * string (* Literal or generated string*)
- + | Acc_char of ('b, 'c) acc * char (* Literal or generated char *)
- + | Acc_delay of ('b, 'c) acc * ('b -> 'c)(* Delayed printing (%a, %t) *)
- + | Acc_flush of ('b, 'c) acc (* Flush *)
- + | Acc_invalid_arg of ('b, 'c) acc * string (* Raise Invalid_argument msg *)
- | End_of_acc
- (* List of heterogeneous values. *)
- @@ -617,8 +618,9 @@
- fun fmt -> make_printf k o acc
- (CamlinternalFormatBasics.(type_format fmt fmtty ^^ rest))
- - | Scan_char_set (_, _, _) ->
- - invalid_arg "Printf: bad conversion %["
- + | Scan_char_set (_, _, rest) ->
- + let new_acc = Acc_invalid_arg (acc, "Printf: bad conversion %[") in
- + fun _ -> make_printf k o new_acc rest
- | Scan_get_counter (_, rest) ->
- (* This case should be refused for Printf. *)
- (* Accepted for backward compatibility. *)
- @@ -626,8 +628,8 @@
- fun n ->
- let new_acc = Acc_string (acc, format_int "%d" n) in
- make_printf k o new_acc rest
- - | Ignored_param (_, _) ->
- - invalid_arg "Printf: bad conversion %_"
- + | Ignored_param (ign, rest) ->
- + make_ignored_param k o acc ign rest
- | Formatting (fmting, rest) ->
- make_printf k o (Acc_formatting (acc, fmting)) rest
- @@ -635,6 +637,59 @@
- | End_of_format ->
- k o acc
- +(* Delay the error (Invalid_argument "Printf: bad conversion %_"). *)
- +(* Generate functions to take remaining arguments (after the "%_"). *)
- +and make_ignored_param : type x y a b c f .
- + (b -> (b, c) acc -> f) -> b -> (b, c) acc ->
- + (a, b, c, c, y, x) CamlinternalFormatBasics.ignored ->
- + (x, b, c, y, c, f) CamlinternalFormatBasics.format6 -> a =
- +fun k o acc ign fmt -> match ign with
- + | Ignored_char -> make_invalid_arg k o acc fmt
- + | Ignored_caml_char -> make_invalid_arg k o acc fmt
- + | Ignored_string _ -> make_invalid_arg k o acc fmt
- + | Ignored_caml_string _ -> make_invalid_arg k o acc fmt
- + | Ignored_int (_, _) -> make_invalid_arg k o acc fmt
- + | Ignored_int32 (_, _) -> make_invalid_arg k o acc fmt
- + | Ignored_nativeint (_, _) -> make_invalid_arg k o acc fmt
- + | Ignored_int64 (_, _) -> make_invalid_arg k o acc fmt
- + | Ignored_float (_, _) -> make_invalid_arg k o acc fmt
- + | Ignored_bool -> make_invalid_arg k o acc fmt
- + | Ignored_format_arg _ -> make_invalid_arg k o acc fmt
- + | Ignored_format_subst (_, fmtty) -> make_from_fmtty k o acc fmtty fmt
- + | Ignored_reader -> assert false
- + | Ignored_scan_char_set _ -> make_invalid_arg k o acc fmt
- +
- +(* Special case of printf "%_(". *)
- +and make_from_fmtty : type x y a b c f .
- + (b -> (b, c) acc -> f) -> b -> (b, c) acc ->
- + (a, b, c, c, y, x) CamlinternalFormatBasics.fmtty ->
- + (x, b, c, y, c, f) CamlinternalFormatBasics.format6 -> a =
- +fun k o acc fmtty fmt -> match fmtty with
- + | Char_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | String_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Int_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Int32_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Nativeint_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Int64_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Float_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Bool_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Alpha_ty rest -> fun _ _ -> make_from_fmtty k o acc rest fmt
- + | Theta_ty rest -> fun _ -> make_from_fmtty k o acc rest fmt
- + | Reader_ty _ -> assert false
- + | Ignored_reader_ty _ -> assert false
- + | Format_arg_ty (_, rest) -> fun _ -> make_from_fmtty k o acc rest fmt
- + | End_of_fmtty -> make_invalid_arg k o acc fmt
- + | Format_subst_ty (_, ty, rest) ->
- + fun _ -> make_from_fmtty k o acc (ty ^^^ rest) fmt
- +
- +(* Insert an Acc_invalid_arg in the accumulator and continue to generate
- + closures to get the remaining arguments. *)
- +and make_invalid_arg : type a b c f .
- + (b -> (b, c) acc -> f) -> b -> (b, c) acc ->
- + (a, b, c, c, c, f) CamlinternalFormatBasics.format6 -> a =
- +fun k o acc fmt ->
- + make_printf k o (Acc_invalid_arg (acc, "Printf: bad conversion %_")) fmt
- +
- (* Fix padding, take it as an extra integer argument if needed. *)
- and make_string_padding : type x z a b c d .
- (b -> (b, c) acc -> d) -> b -> (b, c) acc ->
- @@ -756,11 +811,12 @@
- let s = string_of_formatting fmting in
- output_acc o p;
- output_string o s;
- - | Acc_string (p, s) -> output_acc o p; output_string o s
- - | Acc_char (p, c) -> output_acc o p; output_char o c
- - | Acc_delay (p, f) -> output_acc o p; f o
- - | Acc_flush p -> output_acc o p; flush o
- - | End_of_acc -> ()
- + | Acc_string (p, s) -> output_acc o p; output_string o s
- + | Acc_char (p, c) -> output_acc o p; output_char o c
- + | Acc_delay (p, f) -> output_acc o p; f o
- + | Acc_flush p -> output_acc o p; flush o
- + | Acc_invalid_arg (p, msg) -> output_acc o p; invalid_arg msg;
- + | End_of_acc -> ()
- (* Recursively output an "accumulator" containing a reversed list of
- printing entities (string, char, flus, ...) in a buffer. *)
- @@ -770,11 +826,12 @@
- let s = string_of_formatting fmting in
- bufput_acc b p;
- Buffer.add_string b s;
- - | Acc_string (p, s) -> bufput_acc b p; Buffer.add_string b s
- - | Acc_char (p, c) -> bufput_acc b p; Buffer.add_char b c
- - | Acc_delay (p, f) -> bufput_acc b p; f b
- - | Acc_flush p -> bufput_acc b p;
- - | End_of_acc -> ()
- + | Acc_string (p, s) -> bufput_acc b p; Buffer.add_string b s
- + | Acc_char (p, c) -> bufput_acc b p; Buffer.add_char b c
- + | Acc_delay (p, f) -> bufput_acc b p; f b
- + | Acc_flush p -> bufput_acc b p;
- + | Acc_invalid_arg (p, msg) -> bufput_acc b p; invalid_arg msg;
- + | End_of_acc -> ()
- (* Recursively output an "accumulator" containing a reversed list of
- printing entities (string, char, flus, ...) in a buffer. *)
- @@ -785,11 +842,12 @@
- let s = string_of_formatting fmting in
- strput_acc b p;
- Buffer.add_string b s;
- - | Acc_string (p, s) -> strput_acc b p; Buffer.add_string b s
- - | Acc_char (p, c) -> strput_acc b p; Buffer.add_char b c
- - | Acc_delay (p, f) -> strput_acc b p; Buffer.add_string b (f ())
- - | Acc_flush p -> strput_acc b p;
- - | End_of_acc -> ()
- + | Acc_string (p, s) -> strput_acc b p; Buffer.add_string b s
- + | Acc_char (p, c) -> strput_acc b p; Buffer.add_char b c
- + | Acc_delay (p, f) -> strput_acc b p; Buffer.add_string b (f ())
- + | Acc_flush p -> strput_acc b p;
- + | Acc_invalid_arg (p, msg) -> strput_acc b p; invalid_arg msg;
- + | End_of_acc -> ()
- (******************************************************************************)
- (* Error managment *)
- diff -Naur ocaml-4.00.1-old/stdlib/camlinternalFormat.mli ocaml-4.00.1-new/stdlib/camlinternalFormat.mli
- --- ocaml-4.00.1-old/stdlib/camlinternalFormat.mli 2013-05-26 16:24:33.120743996 +0200
- +++ ocaml-4.00.1-new/stdlib/camlinternalFormat.mli 2013-05-26 16:25:09.928281312 +0200
- @@ -3,11 +3,12 @@
- open CamlinternalFormatBasics
- type ('b, 'c) acc =
- - | Acc_formatting of ('b, 'c) acc * formatting
- - | Acc_string of ('b, 'c) acc * string
- - | Acc_char of ('b, 'c) acc * char
- - | Acc_delay of ('b, 'c) acc * ('b -> 'c)
- - | Acc_flush of ('b, 'c) acc
- + | Acc_formatting of ('b, 'c) acc * formatting
- + | Acc_string of ('b, 'c) acc * string
- + | Acc_char of ('b, 'c) acc * char
- + | Acc_delay of ('b, 'c) acc * ('b -> 'c)
- + | Acc_flush of ('b, 'c) acc
- + | Acc_invalid_arg of ('b, 'c) acc * string
- | End_of_acc
- type ('a, 'b) heter_list =
- diff -Naur ocaml-4.00.1-old/stdlib/format.ml ocaml-4.00.1-new/stdlib/format.ml
- --- ocaml-4.00.1-old/stdlib/format.ml 2013-05-26 16:24:40.340653241 +0200
- +++ ocaml-4.00.1-new/stdlib/format.ml 2013-05-26 16:24:59.690410005 +0200
- @@ -972,12 +972,13 @@
- | Acc_char (Acc_formatting (p, Magic_size (_, size)), c) ->
- output_acc ppf p;
- pp_print_as_size ppf (size_of_int size) (String.make 1 c);
- - | Acc_formatting (p, f) -> output_acc ppf p; output_formatting ppf f;
- - | Acc_string (p, s) -> output_acc ppf p; pp_print_string ppf s;
- - | Acc_char (p, c) -> output_acc ppf p; pp_print_char ppf c;
- - | Acc_delay (p, f) -> output_acc ppf p; f ppf;
- - | Acc_flush p -> output_acc ppf p; pp_print_flush ppf ();
- - | End_of_acc -> ()
- + | Acc_formatting (p, f) -> output_acc ppf p; output_formatting ppf f;
- + | Acc_string (p, s) -> output_acc ppf p; pp_print_string ppf s;
- + | Acc_char (p, c) -> output_acc ppf p; pp_print_char ppf c;
- + | Acc_delay (p, f) -> output_acc ppf p; f ppf;
- + | Acc_flush p -> output_acc ppf p; pp_print_flush ppf ();
- + | Acc_invalid_arg (p, msg) -> output_acc ppf p; invalid_arg msg;
- + | End_of_acc -> ()
- (* Recursively output an "accumulator" containing a reversed list of
- printing entities (string, char, flus, ...) in a buffer. *)
- @@ -993,12 +994,13 @@
- | Acc_delay (Acc_formatting (p, Magic_size (_, size)), f) ->
- strput_acc ppf p;
- pp_print_as_size ppf (size_of_int size) (f ());
- - | Acc_formatting (p, f) -> strput_acc ppf p; output_formatting ppf f;
- - | Acc_string (p, s) -> strput_acc ppf p; pp_print_string ppf s;
- - | Acc_char (p, c) -> strput_acc ppf p; pp_print_char ppf c;
- - | Acc_delay (p, f) -> strput_acc ppf p; pp_print_string ppf (f ());
- - | Acc_flush p -> strput_acc ppf p; pp_print_flush ppf ();
- - | End_of_acc -> ()
- + | Acc_formatting (p, f) -> strput_acc ppf p; output_formatting ppf f;
- + | Acc_string (p, s) -> strput_acc ppf p; pp_print_string ppf s;
- + | Acc_char (p, c) -> strput_acc ppf p; pp_print_char ppf c;
- + | Acc_delay (p, f) -> strput_acc ppf p; pp_print_string ppf (f ());
- + | Acc_flush p -> strput_acc ppf p; pp_print_flush ppf ();
- + | Acc_invalid_arg (p, msg) -> strput_acc ppf p; invalid_arg msg;
- + | End_of_acc -> ()
- (**************************************************************
Add Comment
Please, Sign In to add comment