diff --git a/.ocamlformat b/.ocamlformat index 3d851cc..f58f221 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,4 +1,4 @@ -version=0.17.0 +version=0.21.0 module-item-spacing=compact break-struct=natural break-infix=fit-or-vertical diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 466e3ce..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: c -install: - - wget https://raw.githubusercontent.com/ocaml/ocaml-travisci-skeleton/master/.travis-opam.sh -script: bash -ex .travis-opam.sh -env: - matrix: - - PACKAGE="decompress" OCAML_VERSION=4.08 TESTS=true - - PACKAGE="decompress" OCAML_VERSION=4.09 TESTS=true - - PACKAGE="decompress" OCAML_VERSION=4.10 TESTS=true - - PACKAGE="decompress" OCAML_VERSION=4.11 TESTS=true diff --git a/bin/pipe.ml b/bin/pipe.ml index 2d2456f..f97efd6 100644 --- a/bin/pipe.ml +++ b/bin/pipe.ml @@ -184,7 +184,6 @@ let format = let command = let doc = "Pipe." in - let exits = Term.default_exits in let man = [ `S Manpage.s_description @@ -192,6 +191,8 @@ let command = "$(tname) reads from standard input and writes the \ compressed/decompressed data to standard output." ] in - Term.(ret (const run $ deflate $ format)), Term.info "pipe" ~exits ~doc ~man + let term = Term.(ret (const run $ deflate $ format)) + and info = Cmd.info "pipe" ~doc ~man in + Cmd.v info term -let () = Term.(exit_status @@ eval command) +let () = exit (Cmd.eval' command) diff --git a/bindings/stubs/gen_decompress_bindings.ml b/bindings/stubs/gen_decompress_bindings.ml index 48af160..d2e8228 100644 --- a/bindings/stubs/gen_decompress_bindings.ml +++ b/bindings/stubs/gen_decompress_bindings.ml @@ -1,5 +1,4 @@ open Ctypes -open Zl let inflate i i_len o o_len = let i = bigarray_of_ptr array1 i_len Bigarray.char i in diff --git a/decompress.opam b/decompress.opam index a436a8c..d37065b 100644 --- a/decompress.opam +++ b/decompress.opam @@ -19,9 +19,7 @@ run-test: [ "dune" "runtest" "-p" name "-j" jobs ] depends: [ "ocaml" {>= "4.07.0"} "dune" {>= "2.8.0"} - "base-bytes" - "bigarray-compat" - "cmdliner" {>= "1.0.0"} + "cmdliner" {>= "1.1.0"} "optint" {>= "0.1.0"} "checkseum" {>= "0.2.0"} "bigstringaf" {with-test} diff --git a/lib/de.ml b/lib/de.ml index 765dcc0..abbb801 100644 --- a/lib/de.ml +++ b/lib/de.ml @@ -1,7 +1,5 @@ [@@@landmark "auto"] -module Bigarray = Bigarray_compat (* XXX(dinosaure): MirageOS compatibility. *) - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t @@ -643,7 +641,6 @@ module Inf = struct | End_of_inflate and jump = Length | Extra_length | Distance | Extra_distance | Write - and ret = Await | Flush | End | K | Malformed of string let malformedf fmt = kstrf (fun s -> Malformed s) fmt @@ -3913,7 +3910,6 @@ module Lz77 = struct let _8 = {good_length= 32; max_lazy= 128; nice_length= 258; max_chain= 1024} let _9 = {good_length= 32; max_lazy= 258; nice_length= 258; max_chain= 4096} let _mem_level = 8 (* default *) - let _hash_bits = _mem_level + 7 let _hash_size = 1 lsl _hash_bits let _hash_mask = _hash_size - 1 diff --git a/lib/de.mli b/lib/de.mli index b2337d9..405992a 100644 --- a/lib/de.mli +++ b/lib/de.mli @@ -15,9 +15,6 @@ functions even if they are available. Others libraries like [Bigstringaf] serve the same purpose of a much better way. *) -module Bigarray = Bigarray_compat -(** MirageOS compatibility. *) - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t (** The type for [bigstring]. *) diff --git a/lib/dune b/lib/dune index e5f4cb7..3a66b7f 100644 --- a/lib/dune +++ b/lib/dune @@ -3,20 +3,20 @@ (public_name decompress.de) (modules de) (ocamlopt_flags -O3 -unbox-closures -unbox-closures-factor 20) - (libraries optint checkseum bigarray-compat)) + (libraries optint checkseum)) (library (name lz) (public_name decompress.lz) (modules lz) (ocamlopt_flags -O3 -unbox-closures -unbox-closures-factor 20) - (libraries optint checkseum bigarray-compat de)) + (libraries optint checkseum de)) (library (name rfc1951) (public_name rfc1951) (modules rfc1951) - (libraries optint checkseum bigarray-compat)) + (libraries optint checkseum)) (rule (deps de.ml) @@ -28,19 +28,18 @@ (name zl) (public_name decompress.zl) (modules zl) - (libraries bigarray-compat optint checkseum de)) + (libraries optint checkseum de)) (library (name gz) (public_name decompress.gz) (modules gz) - (libraries bigarray-compat optint checkseum de)) + (libraries optint checkseum de)) (library (name lzo) (public_name decompress.lzo) - (modules lzo) - (libraries bigarray-compat)) + (modules lzo)) (alias (name default) diff --git a/lib/gz.ml b/lib/gz.ml index 249f76e..bd7dd3d 100644 --- a/lib/gz.ml +++ b/lib/gz.ml @@ -2,8 +2,6 @@ let io_buffer_size = 65536 let kstrf k fmt = Format.kasprintf k fmt let invalid_arg fmt = Format.kasprintf invalid_arg fmt -module Bigarray = Bigarray_compat (* XXX(dinosaure): MirageOS compatibility. *) - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t diff --git a/lib/gz.mli b/lib/gz.mli index 5e7976c..ce45383 100644 --- a/lib/gz.mli +++ b/lib/gz.mli @@ -5,9 +5,6 @@ non-blocking streaming codec to {{:#decode}decode} and {{:#encode}encode} GZIP encoding. It can efficiently work payload by payload without blocking IO. *) -module Bigarray = Bigarray_compat -(** MirageOS compatibility. *) - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t (** Type type for [bigstring]. *) diff --git a/lib/lz.ml b/lib/lz.ml index 3d3c39d..30551e0 100644 --- a/lib/lz.ml +++ b/lib/lz.ml @@ -1,7 +1,5 @@ [@@@landmark "auto"] -module Bigarray = Bigarray_compat (* XXX(dinosaure): MirageOS compatibility. *) - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t @@ -149,7 +147,6 @@ let _7 = {good_length= 8; max_lazy= 32; nice_length= 128; max_chain= 256} let _8 = {good_length= 32; max_lazy= 128; nice_length= 258; max_chain= 1024} let _9 = {good_length= 32; max_lazy= 258; nice_length= 258; max_chain= 4096} let _mem_level = 8 (* default *) - let _hash_bits = _mem_level + 7 let _hash_size = 1 lsl _hash_bits let _hash_mask = _hash_size - 1 diff --git a/lib/lz.mli b/lib/lz.mli index 4f0b3ff..99c2381 100644 --- a/lib/lz.mli +++ b/lib/lz.mli @@ -1,5 +1,3 @@ -module Bigarray = Bigarray_compat - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t diff --git a/lib/lzo.ml b/lib/lzo.ml index 9e43ff3..b79541f 100644 --- a/lib/lzo.ml +++ b/lib/lzo.ml @@ -1,5 +1,3 @@ -module Bigarray = Bigarray_compat (* XXX(dinosaure): MirageOS compatibility. *) - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t @@ -177,7 +175,6 @@ type ('a, 'error) t = | Lazy : ('a, 'error) t Lazy.t -> ('a, 'error) t and 'a value = Byte : char value | Short : [ `LE | `BE ] -> int value - and state = State.t type v = { diff --git a/lib/zl.ml b/lib/zl.ml index fa905fb..a629a44 100644 --- a/lib/zl.ml +++ b/lib/zl.ml @@ -2,8 +2,6 @@ let io_buffer_size = 65536 let kstrf k fmt = Format.kasprintf k fmt let invalid_arg fmt = Format.kasprintf invalid_arg fmt -module Bigarray = Bigarray_compat - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t diff --git a/lib/zl.mli b/lib/zl.mli index d655429..fee5dd3 100644 --- a/lib/zl.mli +++ b/lib/zl.mli @@ -5,9 +5,6 @@ to {{:#decode}decode} and {{:#encode}encode} ZLIB encoding. It can efficiently work payload by payload without blocking IO. *) -module Bigarray = Bigarray_compat -(** MirageOS compatibility. *) - type bigstring = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t (** The type for [bigstring]. *) diff --git a/rfc1951.opam b/rfc1951.opam index df09c9b..d98b78b 100644 --- a/rfc1951.opam +++ b/rfc1951.opam @@ -20,7 +20,6 @@ depends: [ "ocaml" {>= "4.07.0"} "dune" {>= "2.8"} "decompress" {= version} - "bigarray-compat" "checkseum" "optint" "ctypes" {with-test & >= "0.18.0"} diff --git a/test/test.ml b/test/test.ml index a5eeb87..5d78bfa 100644 --- a/test/test.ml +++ b/test/test.ml @@ -316,8 +316,8 @@ let fuzz2 () = ; "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e" (* ~~~~~~~~~~~~~~~~ *) ; "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e" - (* ~~~~~~~~~~~~~~~~ *); "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x3a\x2c\x50" - (* ~~~~~~~~:,P *) + (* ~~~~~~~~~~~~~~~~ *) + ; "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x3a\x2c\x50" (* ~~~~~~~~:,P *) ] in Alcotest.test_case "fuzz2" `Quick @@ fun () -> let decoder = @@ -401,8 +401,8 @@ let fuzz5 () = let expected_output = [ "\x1a\xca\x78\x78\x78\x78\x78\x78\x78\x50\x50\x37\x50\x50\x50\x50" - (* ..xxxxxxxPP7PPPP *); "\x50\x50\x50\x50\x50\x50\x50\x50\x50" - (* PPPPPPPPP *) + (* ..xxxxxxxPP7PPPP *) + ; "\x50\x50\x50\x50\x50\x50\x50\x50\x50" (* PPPPPPPPP *) ] in Alcotest.test_case "fuzz5" `Quick @@ fun () -> let decoder = Inf.decoder (`String (String.concat "" input)) ~o ~w in @@ -458,8 +458,8 @@ let fuzz9 () = "\x9b\x01\x95\xfc\x51\xd2\xed\xc8\xce\xc8\xff\x80\x00\x00\x7f\xff" (* ....Q........... *) ; "\x79\x2f\xe9\x51\x88\x7b\xb8\x2f\xef\xa5\x8c\xf8\xf1\xb6\xce\xc8" - (* y/.Q.{./........ *); "\xb8\xc8\xff\x2f\x00\x7f\x88\x7b\xbc" - (* .../...{. *) + (* y/.Q.{./........ *) + ; "\xb8\xc8\xff\x2f\x00\x7f\x88\x7b\xbc" (* .../...{. *) ] in let decoder = Inf.decoder (`String (String.concat "" inputs)) ~o ~w in Alcotest.(check decode) diff --git a/test/test_ns.ml b/test/test_ns.ml index 017a539..917deb3 100644 --- a/test/test_ns.ml +++ b/test/test_ns.ml @@ -136,40 +136,34 @@ let invalid_complement_of_length () = Alcotest.test_case "invalid complement of length" `Quick @@ fun () -> let src = bigstring_of_string "\x00\x00\x00\x00\x00" in Alcotest.(check check_decode) - "invalid complement of length" - (Error `Invalid_complement_of_length) + "invalid complement of length" (Error `Invalid_complement_of_length) (Inf.Ns.inflate src dst) let invalid_kind_of_block () = Alcotest.test_case "invalid kind of block" `Quick @@ fun () -> let src = bigstring_of_string "\x06" in Alcotest.(check check_decode) - "invalid kind of block" - (Error `Invalid_kind_of_block) + "invalid kind of block" (Error `Invalid_kind_of_block) (Inf.Ns.inflate src dst) let invalid_code_lengths () = Alcotest.test_case "invalid code lengths" `Quick @@ fun () -> let src = bigstring_of_string "\x04\x00\xfe\xff" in Alcotest.(check check_decode) - "invalid code lengths" - (Error `Invalid_dictionary) - (Inf.Ns.inflate src dst) + "invalid code lengths" (Error `Invalid_dictionary) (Inf.Ns.inflate src dst) let invalid_bit_length_repeat () = Alcotest.test_case "invalid bit length repeat" `Quick @@ fun () -> let src = bigstring_of_string "\x04\x00\x24\x49\x00" in Alcotest.(check check_decode) - "invalid bit length repeat" - (Error `Invalid_dictionary) + "invalid bit length repeat" (Error `Invalid_dictionary) (Inf.Ns.inflate src dst) let invalid_codes () = Alcotest.test_case "invalid codes -- missing end-of-block" `Quick @@ fun () -> let src = bigstring_of_string "\x04\x00\x24\xe9\xff\x6d" in Alcotest.(check check_decode) - "invalid codes -- missing end-of-block" - (Error `Invalid_dictionary) + "invalid codes -- missing end-of-block" (Error `Invalid_dictionary) (Inf.Ns.inflate src dst) let invalid_lengths () = @@ -179,8 +173,7 @@ let invalid_lengths () = "\x04\x80\x49\x92\x24\x49\x92\x24\x49\x92\x24\x71\xff\xff\x93\x11\x00" in Alcotest.(check check_decode) - "invalid literals/lengths" - (Error `Invalid_dictionary) + "invalid literals/lengths" (Error `Invalid_dictionary) (Inf.Ns.inflate src dst) let invalid_distances () = @@ -189,16 +182,13 @@ let invalid_distances () = bigstring_of_string "\x04\x80\x49\x92\x24\x49\x92\x24\x0f\xb4\xff\xff\xc3\x84" in Alcotest.(check check_decode) - "invalid distances" - (Error `Invalid_dictionary) - (Inf.Ns.inflate src dst) + "invalid distances" (Error `Invalid_dictionary) (Inf.Ns.inflate src dst) let too_many_length_or_distance_symbols () = Alcotest.test_case "too many length of distance symbols" `Quick @@ fun () -> let src = bigstring_of_string "\xfc\x00\x00" in Alcotest.(check check_decode) - "too many length of distance symbols" - (Error `Unexpected_end_of_input) + "too many length of distance symbols" (Error `Unexpected_end_of_input) (Inf.Ns.inflate src dst) (* XXX(dinosaure): error is not conform to what we expect (best will be [Invalid @@ -208,8 +198,7 @@ let invalid_distance_code () = Alcotest.test_case "invalid distance code" `Quick @@ fun () -> let src = bigstring_of_string "\x02\x7e\xff\xff" in Alcotest.(check check_decode) - "invalid distance code" - (Error `Invalid_distance_code) + "invalid distance code" (Error `Invalid_distance_code) (Inf.Ns.inflate src dst) (* XXX(dinosaure): see [Inf.base_dist]'s comment about this behavior. *) @@ -220,8 +209,7 @@ let invalid_distance_too_far_back () = bigstring_of_string "\x0c\xc0\x81\x00\x00\x00\x00\x00\x90\xff\x6b\x04\x00" in Alcotest.(check check_decode) - "invalid distance too far back" - (Error `Invalid_distance) + "invalid distance too far back" (Error `Invalid_distance) (Inf.Ns.inflate src dst) let invalid_flat_not_enough_output () = @@ -229,8 +217,7 @@ let invalid_flat_not_enough_output () = let src = bigstring_of_string "\x01\x04\x00\xfb\xff\xde\xad\xbe\xef" in let dst = bigstring_create 0 in Alcotest.(check check_decode) - "invalid distance too far back" - (Error `Unexpected_end_of_output) + "invalid distance too far back" (Error `Unexpected_end_of_output) (Inf.Ns.inflate src dst) let invalid_literal_not_enough_output () = @@ -246,8 +233,7 @@ let invalid_literal_not_enough_output () = let src = bigstring_of_string res in let dst = bigstring_create 0 in Alcotest.(check check_decode) - "invalid distance too far back" - (Error `Unexpected_end_of_output) + "invalid distance too far back" (Error `Unexpected_end_of_output) (Inf.Ns.inflate src dst) let invalid_copy_not_enough_output () = @@ -263,8 +249,7 @@ let invalid_copy_not_enough_output () = let src = bigstring_of_string res in let dst = bigstring_create 1 in Alcotest.(check check_decode) - "invalid distance too far back" - (Error `Unexpected_end_of_output) + "invalid distance too far back" (Error `Unexpected_end_of_output) (Inf.Ns.inflate src dst) let fixed () = @@ -674,8 +659,8 @@ let fuzz2 () = ; "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e" (* ~~~~~~~~~~~~~~~~ *) ; "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e" - (* ~~~~~~~~~~~~~~~~ *); "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x3a\x2c\x50" - (* ~~~~~~~~:,P *) + (* ~~~~~~~~~~~~~~~~ *) + ; "\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x7e\x3a\x2c\x50" (* ~~~~~~~~:,P *) ] in let expected = String.concat "" expected in (* All of src is not used (last byte is useless) *) @@ -779,8 +764,8 @@ let fuzz5 () = let expected = [ "\x1a\xca\x78\x78\x78\x78\x78\x78\x78\x50\x50\x37\x50\x50\x50\x50" - (* ..xxxxxxxPP7PPPP *); "\x50\x50\x50\x50\x50\x50\x50\x50\x50" - (* PPPPPPPPP *) + (* ..xxxxxxxPP7PPPP *) + ; "\x50\x50\x50\x50\x50\x50\x50\x50\x50" (* PPPPPPPPP *) ] in let expected = String.concat "" expected in (* All of src is not used (last byte is useless) *) @@ -831,9 +816,7 @@ let fuzz8 () = Alcotest.test_case "fuzz8" `Quick @@ fun () -> let src = bigstring_of_string "\x7a\x37\x6d\x99\x13" in Alcotest.(check check_decode) - "fuzz8" - (Error `Unexpected_end_of_input) - (Inf.Ns.inflate src dst) + "fuzz8" (Error `Unexpected_end_of_input) (Inf.Ns.inflate src dst) let fuzz9 () = Alcotest.test_case "fuzz9" `Quick @@ fun () -> @@ -842,14 +825,12 @@ let fuzz9 () = "\x9b\x01\x95\xfc\x51\xd2\xed\xc8\xce\xc8\xff\x80\x00\x00\x7f\xff" (* ....Q........... *) ; "\x79\x2f\xe9\x51\x88\x7b\xb8\x2f\xef\xa5\x8c\xf8\xf1\xb6\xce\xc8" - (* y/.Q.{./........ *); "\xb8\xc8\xff\x2f\x00\x7f\x88\x7b\xbc" - (* .../...{. *) + (* y/.Q.{./........ *) + ; "\xb8\xc8\xff\x2f\x00\x7f\x88\x7b\xbc" (* .../...{. *) ] in let src = bigstring_of_string (String.concat "" src) in Alcotest.(check check_decode) - "fuzz9" - (Error `Invalid_distance) - (Inf.Ns.inflate src dst) + "fuzz9" (Error `Invalid_distance) (Inf.Ns.inflate src dst) let fuzz10 () = Alcotest.test_case "fuzz10" `Quick @@ fun () ->