Permalink
Browse files

some benine meaningless formats were previously ignored

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14814 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
gasche committed May 12, 2014
1 parent fb90637 commit b56ea67724f1b7cd70ab308ba8965c3c7c7c5d7e
Showing with 14 additions and 3 deletions.
  1. +14 −3 stdlib/camlinternalFormat.ml
@@ -1370,12 +1370,18 @@ let fmt_ebb_of_string str =
parse_after_padding pct_ind (str_ind + 1) end_ind plus sharp space ign
(Arg_padding padty)
| _ ->
- match padty with
- | Left -> invalid_format_without (str_ind - 1) '-' "padding"
- | Zeros -> invalid_format_without (str_ind - 1) '0' "padding"
+ if legacy_behavior then
+ parse_after_padding pct_ind str_ind end_ind plus sharp space ign
+ No_padding
+ else begin match padty with
+ | Left ->
+ invalid_format_without (str_ind - 1) '-' "padding"
+ | Zeros ->
+ invalid_format_without (str_ind - 1) '0' "padding"
| Right ->
parse_after_padding pct_ind str_ind end_ind plus sharp space ign
No_padding
+ end
(* Is precision defined? *)
and parse_after_padding : type x e f .
@@ -1405,6 +1411,11 @@ let fmt_ebb_of_string str =
parse_after_precision pct_ind (str_ind + 1) end_ind plus sharp space ign
pad Arg_precision
| _ ->
+ if legacy_behavior then
+ (* note that legacy implementation did not ignore '.' without
+ a number (as it does for padding indications), but
+ interprets it as '.0' *)
+ parse_after_precision pct_ind str_ind end_ind plus sharp space ign pad (Lit_precision 0) else
invalid_format_without (str_ind - 1) '.' "precision"
(* Try to read the conversion. *)

0 comments on commit b56ea67

Please sign in to comment.