Skip to content
Snippets Groups Projects
Commit 52d447c3 authored by erwan's avatar erwan
Browse files

Make sure an int string is not an ident before trying a big_int convertion

parent e9db055e
No related branches found
No related tags found
No related merge requests found
OASISFormat: 0.4 OASISFormat: 0.4
Name: lutils Name: lutils
Version: 1.13 Version: 1.14
Authors: Erwan Jahier Authors: Erwan Jahier
Maintainers: erwan.jahier@imag.fr Maintainers: erwan.jahier@imag.fr
License: GPL-3 License: GPL-3
......
\newcommand{\version}{1.13} \newcommand{\version}{1.14}
\newcommand{\sha}{0013635} \newcommand{\sha}{e9db055}
\newcommand{\versionname}{none} \newcommand{\versionname}{none}
\newcommand{\versiondate}{12-06-17} \newcommand{\versiondate}{22-06-17}
# OASIS_START # OASIS_START
# DO NOT EDIT (digest: 15d9e918ed9eb34ce3e848dd1e1775a7) # DO NOT EDIT (digest: bd2a3dd8b4c274b4d60cc3825abe018b)
version = "1.13" version = "1.14"
description = "shared by Verimag/synchronous tools (lustre, lutin, rdbg)." description = "shared by Verimag/synchronous tools (lustre, lutin, rdbg)."
requires = "unix str camlp4 num" requires = "unix str camlp4 num"
archive(byte) = "lutils.cma" archive(byte) = "lutils.cma"
......
...@@ -27,15 +27,19 @@ let big_max_int = Big_int.big_int_of_nativeint Nativeint.max_int ...@@ -27,15 +27,19 @@ let big_max_int = Big_int.big_int_of_nativeint Nativeint.max_int
let local_int_of_string str = let local_int_of_string str =
try int_of_string str try int_of_string str
with _ -> with _ ->
let big_i0 = Big_int.big_int_of_string str in if Str.string_match (Str.regexp "[a-z]") str 0
let big_i = Big_int.mod_big_int big_i0 (Big_int.succ_big_int big_max_int) in then failwith ("Cannot convert "^str^" into an int")
let i = Nativeint.to_int (Big_int.nativeint_of_big_int big_i) in else
if (Big_int.big_int_of_int i <> big_i0) then ( let big_i0 = Big_int.big_int_of_string str in
Printf.eprintf "Warning: integer overflow (%s truncated to %s)\n" let big_i = Big_int.mod_big_int big_i0 (Big_int.succ_big_int big_max_int) in
(Big_int.string_of_big_int big_i0) (string_of_int i); let i = Nativeint.to_int (Big_int.nativeint_of_big_int big_i) in
flush stderr if (Big_int.big_int_of_int i <> big_i0) then (
); Printf.eprintf "Warning: integer overflow (%s truncated to %s)\n"
i (Big_int.string_of_big_int big_i0) (string_of_int i);
flush stderr
);
i
......
let str="1.13" let str="1.14"
let sha="0013635" let sha="e9db055"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment