Skip to content

Commit 75bdb5b

Browse files
committed
use Cstruct.length instead of deprecated Cstruct.len
requires cstruct 6.0.0 also require OCaml 4.08.0 to drop bigarray-compat and stdlib-shims dependencies
1 parent c15f690 commit 75bdb5b

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

asn1-combinators.opam

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ build: [ ["dune" "subst"] {pinned}
1111
["dune" "build" "-p" name "-j" jobs ]
1212
["dune" "runtest" "-p" name "-j" jobs] {with-test} ]
1313
depends: [
14-
"ocaml" {>="4.05.0"}
14+
"ocaml" {>="4.08.0"}
1515
"dune" {>= "1.2.0"}
16-
"cstruct" {>= "1.6.0"}
16+
"cstruct" {>= "6.0.0"}
1717
"zarith"
18-
"bigarray-compat"
19-
"stdlib-shims"
2018
"ptime"
2119
"alcotest" {with-test}
2220
]

src/asn_ber_der.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module R = struct
123123

124124
let split_off cs off n =
125125
let k = off + n in
126-
Cstruct.(sub cs off n, sub cs k (len cs - k))
126+
Cstruct.(sub cs off n, sub cs k (length cs - k))
127127

128128
let rec children cfg eof acc cs =
129129
if eof cs then (List.rev acc, cs) else

src/asn_combinators.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ end
1212

1313
let clone_cs cs =
1414
let open Cstruct in
15-
let ds = create_unsafe (len cs) in
16-
blit cs 0 ds 0 (len cs); cs
15+
let ds = create_unsafe (length cs) in
16+
blit cs 0 ds 0 (length cs); cs
1717

1818
type cls = [ `Universal | `Application | `Private ]
1919

@@ -76,7 +76,7 @@ and bit_string_cs =
7676
let f = function
7777
| 0, cs -> cs
7878
| clip, cs ->
79-
let n = Cstruct.len cs in
79+
let n = Cstruct.length cs in
8080
let last = Cstruct.get_uint8 cs (n - 1) in
8181
let cs = clone_cs cs
8282
and last = last land (lnot (1 lsl clip - 1)) in

src/asn_prim.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
open Asn_core
55

66
module Writer = Asn_writer
7-
module Bigarray = Bigarray_compat
87

98
module type Prim = sig
109
type t
@@ -171,7 +170,7 @@ module Octets : Prim_s with type t = Cstruct.t = struct
171170

172171
let concat = Cstruct.concat
173172

174-
let length = Cstruct.len
173+
let length = Cstruct.length
175174

176175
end
177176

@@ -188,21 +187,21 @@ struct
188187
type t = int * Cstruct.t
189188

190189
let of_cstruct cs =
191-
let n = Cstruct.len cs in
190+
let n = Cstruct.length cs in
192191
if n = 0 then parse_error "BITS" else
193192
let unused = Cstruct.get_uint8 cs 0 in
194193
if n = 1 && unused > 0 || unused > 7 then parse_error "BITS" else
195194
unused, Octets.of_cstruct (Cstruct.shift cs 1)
196195

197196
let to_writer (unused, cs) =
198-
let size = Cstruct.len cs in
197+
let size = Cstruct.length cs in
199198
let write off cs' =
200199
Cstruct.set_uint8 cs' off unused;
201200
Cstruct.blit cs 0 cs' (off + 1) size in
202201
Writer.immediate (size + 1) write
203202

204203
let to_array (unused, cs) =
205-
Array.init (Cstruct.len cs * 8 - unused) @@ fun i ->
204+
Array.init (Cstruct.length cs * 8 - unused) @@ fun i ->
206205
let byte = (Cstruct.get_uint8 cs (i / 8)) lsl (i mod 8) in
207206
byte land 0x80 = 0x80
208207

@@ -237,7 +236,7 @@ struct
237236
go css in
238237
(unused, Cstruct.concat css')
239238

240-
and length (unused, cs) = Cstruct.len cs - unused
239+
and length (unused, cs) = Cstruct.length cs - unused
241240

242241
end
243242

@@ -268,7 +267,7 @@ module OID = struct
268267
0 -> []
269268
| n -> let (c, i') = int_chain cs i n in
270269
c :: components cs i' (n + i - i') in
271-
match Cstruct.len cs with
270+
match Cstruct.length cs with
272271
0 -> parse_error "OID: 0 length"
273272
| n ->
274273
let (b1, i) = int_chain cs 0 n in

src/asn_writer.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
See LICENSE.md. *)
33

44
let cs_lex_compare cs1 cs2 =
5-
let (s1, s2) = Cstruct.(len cs1, len cs2) in
5+
let (s1, s2) = Cstruct.(length cs1, length cs2) in
66
let rec go i lim =
77
if i = lim then
88
compare s1 s2
@@ -42,7 +42,7 @@ let of_string str =
4242
(n, fun off cs -> Cstruct.blit_from_string str 0 cs off n)
4343

4444
let of_cstruct cs' =
45-
let n = Cstruct.len cs' in
45+
let n = Cstruct.length cs' in
4646
(n, fun off cs -> Cstruct.blit cs' 0 cs off n)
4747

4848
let of_byte b = (1, fun off cs -> Cstruct.set_uint8 cs off b)

src/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
(name asn1_combinators)
33
(public_name asn1-combinators)
44
(synopsis "Embed typed ASN.1 grammars in OCaml")
5-
(libraries cstruct zarith bigarray-compat ptime stdlib-shims)
5+
(libraries cstruct zarith ptime)
66
(wrapped false)
77
(private_modules asn_oid asn_cache asn_writer asn_prim asn_core asn_random
88
asn_combinators asn_ber_der))

tests/bench.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ let mmap fd = Bigarray.(
2121
let bench_certs filename =
2222
let cs = mmap Unix.(openfile filename [O_RDONLY] 0) in
2323
let rec bench n cs =
24-
if Cstruct.len cs = 0 then n else
24+
if Cstruct.length cs = 0 then n else
2525
match Asn.decode X509.cert_ber cs with
2626
| Ok (_, cs) -> bench (succ n) cs
2727
| Error e -> invalid_arg (Format.asprintf "%a" Asn.pp_error e) in

tests/test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
let pp_hex_cs ppf =
55
let pp ppf cs =
6-
for i = 0 to Cstruct.len cs - 1 do
6+
for i = 0 to Cstruct.length cs - 1 do
77
Format.fprintf ppf "%02x@ " (Cstruct.get_uint8 cs i)
88
done in
99
Format.fprintf ppf "@[%a@]" pp

0 commit comments

Comments
 (0)