Skip to content

Commit

Permalink
fix deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrek committed Feb 3, 2021
1 parent 82f2ea7 commit 0114dfd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions compiler/gen_OCaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ let rec default_value (ev_regime : Gencode.ev_regime) t =
| Bitstring32 _ -> None
| Sum (l, _) -> begin (* first constant constructor = default*)
match
try
Some (List.find_map (function `Constant x -> Some x | _ -> None) l)
with Not_found -> None
List.find_map_opt (function `Constant x -> Some x | _ -> None) l
with
| None -> None
| Some c ->
Expand Down
2 changes: 1 addition & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ depends: [
"ocamlfind" {build}
"ounit" {test}
"camlp4" {build}
("extlib" | "extlib-compat")
("extlib" {>= "1.7.7"} | "extlib-compat" {>="1.7.7"})
"base-bytes"
]
4 changes: 2 additions & 2 deletions runtime/error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ let rec pp_location pp = function
| Field (field, loc) ->
PP.fprintf pp "@[<1>%s.@,%a@]" field pp_location loc
| Message (msg, constr, loc) -> match constr with
None -> PP.fprintf pp "@[<1>%s.@,%a@]" (String.capitalize msg) pp_location loc
None -> PP.fprintf pp "@[<1>%s.@,%a@]" (String.capitalize_ascii msg) pp_location loc
| Some c -> PP.fprintf pp "@[<1>%s_%s.@,%a@]"
(String.capitalize msg) (String.capitalize c) pp_location loc
(String.capitalize_ascii msg) (String.capitalize_ascii c) pp_location loc

let pp_format_error pp = function
| Bad_wire_type ty ->
Expand Down
2 changes: 1 addition & 1 deletion runtime/msg_buffer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ let resize b more =
let add_char b c =
let pos = b.position in
if pos >= b.length then resize b 1;
b.buffer.[pos] <- c;
Bytes.set b.buffer pos c;
b.position <- pos + 1

let add_substring b s offset len =
Expand Down
4 changes: 2 additions & 2 deletions runtime/random_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ struct
let s = Bytes.create n in
let rec loop = function
n when n < 0 -> return @@ Bytes.unsafe_to_string s
| n -> rand_integer 255 >>= fun c -> s.[n] <- Char.chr c; loop (n - 1)
| n -> rand_integer 255 >>= fun c -> Bytes.set s n (Char.chr c); loop (n - 1)
in loop (n - 1)

let rand_readable_string len =
len >>= fun n ->
let s = Bytes.create n in
let rec loop = function
n when n < 0 -> return @@ Bytes.unsafe_to_string s
| n -> rand_integer (127 - 32) >>= fun c -> s.[n] <- Char.chr (32 + c); loop (n - 1)
| n -> rand_integer (127 - 32) >>= fun c -> Bytes.set s n (Char.chr (32 + c)); loop (n - 1)
in loop (n - 1)

let rand_int =
Expand Down

0 comments on commit 0114dfd

Please sign in to comment.