formats: enable the legacy mode by default

Given that there still remains a small incompatibility (typing of
%(..%)), I decided to keep the legacy mode enabled for now. This means
that any failure related to format can be traced to this
incompatiblity (or unknown regressions), which will simplify the
monitoring and handling of changes considerably. As soon as the %(..%)
typing is generalized, we can turn the legacy mode off (or maybe
simply add warnings for ignored formats).

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14841 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Gabriel Scherer 2014-05-12 15:38:35 +00:00
parent f0e39fee7d
commit eccf1e2975
1 changed files with 13 additions and 2 deletions

View File

@ -1,7 +1,18 @@
open CamlinternalFormatBasics open CamlinternalFormatBasics
let legacy_behavior = let legacy_behavior = true
try Sys.getenv "OCAML_LEGACY_FORMAT" <> "" with _ -> false (** When this flag is enabled, the format parser tries to behave as
the <4.02 implementations, in particular it ignores most benine
nonsensical format. When the flag is disabled, it will reject any
format that is not accepted by the specification.
A typical example would be "%+ d": specifying both '+' (if the
number is positive, pad with a '+' to get the same width as
negative numbres) and ' ' (if the number is positive, pad with
a space) does not make sense, but the legacy (< 4.02)
implementation was happy to just ignore the space.
*)
(******************************************************************************) (******************************************************************************)
(* Tools to manipulate scanning set of chars (see %[...]) *) (* Tools to manipulate scanning set of chars (see %[...]) *)