Skip to content

fix invalid printf formats

Zoggy requested to merge damiendoligez:strict-formats into master

Created by: damiendoligez

There are some format strings that are "invalid" in the stog sources.

In general, invalid formats are nonsensical format strings that were accepted in OCaml 4.01.0 and earlier, but whose semantics is unspecified. They are still accepted by the new Printf implementation of OCaml 4.02.0 but in some cases with different semantics, and they will be statically rejected by OCaml 4.03.0.

You can check for them in OCaml 4.02.0 with the flag -strict-formats.

In the case of stog, the behaviour has not changed between 4.01.0 and 4.02.0 but the formats are probably wrong: they have the form "%0x", which means to pad with '0' characters, but does not specify a minimum width (so there will be no padding). This is treated the same as "%x" by the implementations. The patch changes it to "%02x" and "%04x" to add (what I think is) the right padding, but you should review it carefully.

Merge request reports