Commit a9d3d6c7 authored by Raphael Rieu-Helft's avatar Raphael Rieu-Helft

C printer: default to base 16 for binary literals

parent f50f1d6b
...@@ -928,12 +928,14 @@ module MLToC = struct ...@@ -928,12 +928,14 @@ module MLToC = struct
let print fmt ic = let print fmt ic =
let n = ic.il_int in let n = ic.il_int in
if BigInt.lt n BigInt.zero if BigInt.lt n BigInt.zero
then Format.fprintf fmt "-%a" (print_in_base 10 None) (BigInt.abs n) then
(* default to base 10 for negative literals *)
Format.fprintf fmt "-%a" (print_in_base 10 None) (BigInt.abs n)
else else
match ic.il_kind with match ic.il_kind with
| ILitHex -> Format.fprintf fmt "0x%a" (print_in_base 16 None) n | ILitHex | ILitBin -> Format.fprintf fmt "0x%a" (print_in_base 16 None) n
| ILitOct -> Format.fprintf fmt "0%a" (print_in_base 8 None) n | ILitOct -> Format.fprintf fmt "0%a" (print_in_base 8 None) n
| _ -> | ILitDec | ILitUnk ->
(* default to base 10 *) (* default to base 10 *)
Format.fprintf fmt "%a" (print_in_base 10 None) n in Format.fprintf fmt "%a" (print_in_base 10 None) n in
let s = match e.e_ity with let s = match e.e_ity with
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment