summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-04-20 08:18:30 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-04-20 08:18:30 +0000
commitfe8a84e1212f14fa05626abe03dd91cdc9dcc3db (patch)
tree0eb2cfe24015fdc9d9e443f7ef3c660961b147b0 /driver
parent255cee09b71255051c2b40eae0c88bffce1f6f32 (diff)
Interp.ml: support printf of long long
test/regression: add test "int32"; update test "int64" git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2201 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'driver')
-rw-r--r--driver/Interp.ml12
1 files changed, 8 insertions, 4 deletions
diff --git a/driver/Interp.ml b/driver/Interp.ml
index 4f50514..a3ebe80 100644
--- a/driver/Interp.ml
+++ b/driver/Interp.ml
@@ -294,16 +294,17 @@ let extract_string ge m id ofs =
(* Emulation of printf *)
-(* All ISO C 99 formats except size modifiers [ll] (long long) and [L]
- (long double) *)
+(* All ISO C 99 formats except size modifier [L] (long double) *)
let re_conversion = Str.regexp
- "%[-+0# ]*[0-9]*\\(\\.[0-9]*\\)?\\([lhjzt]\\|hh\\)?\\([aAcdeEfgGinopsuxX%]\\)"
+ "%[-+0# ]*[0-9]*\\(\\.[0-9]*\\)?\\([lhjzt]\\|hh\\|ll\\)?\\([aAcdeEfgGinopsuxX%]\\)"
external format_float: string -> caml_float -> string
= "caml_format_float"
external format_int32: string -> int32 -> string
= "caml_int32_format"
+external format_int64: string -> int64 -> string
+ = "caml_int64_format"
let do_printf ge m fmt args =
@@ -337,6 +338,9 @@ let do_printf ge m fmt args =
| EVfloat f :: args', ('f'|'e'|'E'|'g'|'G'|'a') ->
Buffer.add_string b (format_float pat (camlfloat_of_coqfloat f));
scan pos' args'
+ | EVlong i :: args', ('d'|'i'|'u'|'o'|'x'|'X') ->
+ Buffer.add_string b (format_int64 pat (camlint64_of_coqint i));
+ scan pos' args'
| EVptr_global(id, ofs) :: args', 's' ->
Buffer.add_string b
(match extract_string ge m id ofs with
@@ -354,7 +358,7 @@ let do_printf ge m fmt args =
(* Implementing external functions *)
-let re_stub = Str.regexp "\\$[if]*$"
+let re_stub = Str.regexp "\\$[ifl]*$"
let chop_stub name = Str.replace_first re_stub "" name