@@ -2699,11 +2699,10 @@ and isConstantOffset = function
26992699 | Index (e , off ) -> isConstant e && isConstantOffset off
27002700
27012701let parseInt (str : string ) : exp =
2702- let hasSuffix str =
2702+ let hasSuffix str suff =
27032703 let l = String. length str in
2704- fun s ->
2705- let ls = String. length s in
2706- l > = ls && s = String. uppercase_ascii (String. sub str (l - ls) ls)
2704+ let lsuff = String. length suff in
2705+ l > = lsuff && suff = String. uppercase_ascii (String. sub str (l - lsuff) lsuff)
27072706 in
27082707 let l = String. length str in
27092708 (* See if it is octal or hex *)
@@ -2747,17 +2746,11 @@ let parseInt (str: string) : exp =
27472746 let t = String. sub str start (String. length str - start - suffixlen) in
27482747 (* Normal Z.of_string does not work here as 0 is not recognized as the prefix for octal here *)
27492748 let i = Z. of_string_base base t in
2750- (* Construct an integer of the first kinds that fits. i must be POSITIVE *)
2751- let res =
2752- let rec loop = function
2753- | k ::rest ->
2754- if fitsInInt k i then kintegerCilintString k i (Some str)
2755- else loop rest
2756- | [] -> E. s (E. unimp " Cannot represent the integer %s\n " (string_of_cilint i))
2757- in
2758- loop kinds
2759- in
2760- res
2749+ try
2750+ (* Construct an integer of the first kinds that fits. i must be POSITIVE *)
2751+ let ik = List. find (fun ik -> fitsInInt ik i) kinds in
2752+ kintegerCilintString ik i (Some str)
2753+ with Not_found -> E. s (E. unimp " Cannot represent the integer %s\n " (string_of_cilint i))
27612754
27622755
27632756let d_unop () u =
0 commit comments