summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Glondu <steph@glondu.net>2019-09-02 17:42:14 +0200
committerStephane Glondu <steph@glondu.net>2019-09-02 17:42:14 +0200
commit7fe10b2f105429c4942e89ccaf4121e17b57d9b4 (patch)
treef880790c644685242dcd3279cd6e77a86965feb8
parent5388732e4ad19bfdab5dd54bc7674e288502c3b5 (diff)
Fix compilation with OCaml 4.08.0
-rw-r--r--debian/patches/0004-Fix-compilation-with-OCaml-4.08.0.patch255
-rw-r--r--debian/patches/series1
2 files changed, 256 insertions, 0 deletions
diff --git a/debian/patches/0004-Fix-compilation-with-OCaml-4.08.0.patch b/debian/patches/0004-Fix-compilation-with-OCaml-4.08.0.patch
new file mode 100644
index 0000000..2d1c671
--- /dev/null
+++ b/debian/patches/0004-Fix-compilation-with-OCaml-4.08.0.patch
@@ -0,0 +1,255 @@
+From: Stephane Glondu <steph@glondu.net>
+Date: Mon, 2 Sep 2019 17:41:26 +0200
+Subject: Fix compilation with OCaml 4.08.0
+
+---
+ bitstring.ml | 59 ++++++++++++++++++++++++------------------------
+ bitstring.mli | 2 +-
+ bitstring_persistent.mli | 2 +-
+ 3 files changed, 32 insertions(+), 31 deletions(-)
+
+diff --git a/bitstring.ml b/bitstring.ml
+index cfefb79..6f8b831 100644
+--- a/bitstring.ml
++++ b/bitstring.ml
+@@ -36,15 +36,15 @@ exception Construct_failure of string * string * int * int
+ * bitoffset and the bitlength within the string. Note offset/length
+ * are counted in bits, not bytes.
+ *)
+-type bitstring = string * int * int
++type bitstring = bytes * int * int
+
+ type t = bitstring
+
+ (* Functions to create and load bitstrings. *)
+-let empty_bitstring = "", 0, 0
++let empty_bitstring = Bytes.create 0, 0, 0
+
+ let make_bitstring len c =
+- if len >= 0 then String.make ((len+7) lsr 3) c, 0, len
++ if len >= 0 then Bytes.make ((len+7) lsr 3) c, 0, len
+ else
+ invalid_arg (
+ sprintf "make_bitstring/create_bitstring: len %d < 0" len
+@@ -56,7 +56,7 @@ let zeroes_bitstring = create_bitstring
+
+ let ones_bitstring len = make_bitstring len '\xff'
+
+-let bitstring_of_string str = str, 0, String.length str lsl 3
++let bitstring_of_string str = Bytes.of_string str, 0, String.length str lsl 3
+
+ let bitstring_of_chan chan =
+ let tmpsize = 16384 in
+@@ -64,9 +64,9 @@ let bitstring_of_chan chan =
+ let tmp = String.create tmpsize in
+ let n = ref 0 in
+ while n := input chan tmp 0 tmpsize; !n > 0 do
+- Buffer.add_substring buf tmp 0 !n;
++ Buffer.add_subbytes buf tmp 0 !n;
+ done;
+- Buffer.contents buf, 0, Buffer.length buf lsl 3
++ Buffer.to_bytes buf, 0, Buffer.length buf lsl 3
+
+ let bitstring_of_chan_max chan max =
+ let tmpsize = 16384 in
+@@ -78,14 +78,14 @@ let bitstring_of_chan_max chan max =
+ let r = min tmpsize (max - !len) in
+ let n = input chan tmp 0 r in
+ if n > 0 then (
+- Buffer.add_substring buf tmp 0 n;
++ Buffer.add_subbytes buf tmp 0 n;
+ len := !len + n;
+ loop ()
+ )
+ )
+ in
+ loop ();
+- Buffer.contents buf, 0, !len lsl 3
++ Buffer.to_bytes buf, 0, !len lsl 3
+
+ let bitstring_of_file_descr fd =
+ let tmpsize = 16384 in
+@@ -93,9 +93,9 @@ let bitstring_of_file_descr fd =
+ let tmp = String.create tmpsize in
+ let n = ref 0 in
+ while n := Unix.read fd tmp 0 tmpsize; !n > 0 do
+- Buffer.add_substring buf tmp 0 !n;
++ Buffer.add_subbytes buf tmp 0 !n;
+ done;
+- Buffer.contents buf, 0, Buffer.length buf lsl 3
++ Buffer.to_bytes buf, 0, Buffer.length buf lsl 3
+
+ let bitstring_of_file_descr_max fd max =
+ let tmpsize = 16384 in
+@@ -107,14 +107,14 @@ let bitstring_of_file_descr_max fd max =
+ let r = min tmpsize (max - !len) in
+ let n = Unix.read fd tmp 0 r in
+ if n > 0 then (
+- Buffer.add_substring buf tmp 0 n;
++ Buffer.add_subbytes buf tmp 0 n;
+ len := !len + n;
+ loop ()
+ )
+ )
+ in
+ loop ();
+- Buffer.contents buf, 0, !len lsl 3
++ Buffer.to_bytes buf, 0, !len lsl 3
+
+ let bitstring_of_file fname =
+ let chan = open_in_bin fname in
+@@ -799,7 +799,7 @@ module Buffer = struct
+ Buffer.contents buf
+ else
+ Buffer.contents buf ^ (String.make 1 (Char.chr last)) in
+- data, 0, len
++ Bytes.of_string data, 0, len
+
+ (* Add exactly 8 bits. *)
+ let add_byte ({ buf = buf; len = len; last = last } as t) byte =
+@@ -992,7 +992,7 @@ let construct_bitstring buf (data, off, len) =
+ let rec loop off len blen =
+ if blen = 0 then (off, len)
+ else (
+- let b = extract_bit data off len 1
++ let b = extract_bit (Bytes.to_string data) off len 1
+ and off = off + 1 and len = len - 1 in
+ Buffer.add_bit buf b;
+ loop off len (blen-1)
+@@ -1006,9 +1006,9 @@ let construct_bitstring buf (data, off, len) =
+ let off = off lsr 3 in
+ (* XXX dangerous allocation *)
+ if off = 0 then data
+- else String.sub data off (String.length data - off) in
++ else Bytes.sub data off (Bytes.length data - off) in
+
+- Buffer.add_bits buf data len
++ Buffer.add_bits buf (Bytes.to_string data) len
+
+ (* Concatenate bitstrings. *)
+ let concat bs =
+@@ -1021,11 +1021,11 @@ let concat bs =
+ let string_of_bitstring (data, off, len) =
+ if off land 7 = 0 && len land 7 = 0 then
+ (* Easy case: everything is byte-aligned. *)
+- String.sub data (off lsr 3) (len lsr 3)
++ Bytes.sub_string data (off lsr 3) (len lsr 3)
+ else (
+ (* Bit-twiddling case. *)
+ let strlen = (len + 7) lsr 3 in
+- let str = String.make strlen '\000' in
++ let str = Bytes.make strlen '\000' in
+ let rec loop data off len i =
+ if len >= 8 then (
+ let c = extract_char_unsigned data off len 8
+@@ -1037,8 +1037,8 @@ let string_of_bitstring (data, off, len) =
+ str.[i] <- Char.chr (c lsl (8-len))
+ )
+ in
+- loop data off len 0;
+- str
++ loop (Bytes.to_string data) off len 0;
++ Bytes.to_string str
+ )
+
+ (* To channel. *)
+@@ -1078,8 +1078,8 @@ let compare ((data1, off1, len1) as bs1) ((data2, off2, len2) as bs2) =
+ and len1 = len1 lsr 3 and len2 = len2 lsr 3 in
+ let rec loop i =
+ if i < len1 && i < len2 then (
+- let c1 = String.unsafe_get data1 (off1 + i)
+- and c2 = String.unsafe_get data2 (off2 + i) in
++ let c1 = Bytes.unsafe_get data1 (off1 + i)
++ and c2 = Bytes.unsafe_get data2 (off2 + i) in
+ let r = compare c1 c2 in
+ if r <> 0 then r
+ else loop (i+1)
+@@ -1106,7 +1106,7 @@ let is_zeroes_bitstring ((data, off, len) as bits) =
+ let off = off lsr 3 and len = len lsr 3 in
+ let rec loop i =
+ if i < len then (
+- if String.unsafe_get data (off + i) <> '\000' then false
++ if Bytes.unsafe_get data (off + i) <> '\000' then false
+ else loop (i+1)
+ ) else true
+ in
+@@ -1124,7 +1124,7 @@ let is_ones_bitstring ((data, off, len) as bits) =
+ let off = off lsr 3 and len = len lsr 3 in
+ let rec loop i =
+ if i < len then (
+- if String.unsafe_get data (off + i) <> '\xff' then false
++ if Bytes.unsafe_get data (off + i) <> '\xff' then false
+ else loop (i+1)
+ ) else true
+ in
+@@ -1147,7 +1147,7 @@ let put (data, off, len) n v =
+ else (
+ let i = off+n in
+ let si = i lsr 3 and mask = 0x80 lsr (i land 7) in
+- let c = Char.code data.[si] in
++ let c = Char.code (Bytes.get data si) in
+ let c = if v <> 0 then c lor mask else c land (lnot mask) in
+ data.[si] <- Char.unsafe_chr c
+ )
+@@ -1161,7 +1161,7 @@ let get (data, off, len) n =
+ else (
+ let i = off+n in
+ let si = i lsr 3 and mask = 0x80 lsr (i land 7) in
+- let c = Char.code data.[si] in
++ let c = Char.code (Bytes.get data si) in
+ c land mask
+ )
+
+@@ -1181,7 +1181,8 @@ let hexdump_bitstring chan (data, off, len) =
+ let off = ref off in
+ let len = ref len in
+ let linelen = ref 0 in
+- let linechars = String.make 16 ' ' in
++ let linechars = Bytes.make 16 ' ' in
++ let data = Bytes.to_string data in
+
+ fprintf chan "00000000 ";
+
+@@ -1200,7 +1201,7 @@ let hexdump_bitstring chan (data, off, len) =
+ incr linelen;
+ if !linelen = 8 then fprintf chan " ";
+ if !linelen = 16 then (
+- fprintf chan " |%s|\n%08x " linechars !count;
++ fprintf chan " |%s|\n%08x " (Bytes.to_string linechars) !count;
+ linelen := 0;
+ for i = 0 to 15 do linechars.[i] <- ' ' done
+ )
+@@ -1209,6 +1210,6 @@ let hexdump_bitstring chan (data, off, len) =
+ if !linelen > 0 then (
+ let skip = (16 - !linelen) * 3 + if !linelen < 8 then 1 else 0 in
+ for i = 0 to skip-1 do fprintf chan " " done;
+- fprintf chan " |%s|\n%!" linechars
++ fprintf chan " |%s|\n%!" (Bytes.to_string linechars)
+ ) else
+ fprintf chan "\n%!"
+diff --git a/bitstring.mli b/bitstring.mli
+index 250739d..67ff2ef 100644
+--- a/bitstring.mli
++++ b/bitstring.mli
+@@ -650,7 +650,7 @@ type endian = BigEndian | LittleEndian | NativeEndian
+ val string_of_endian : endian -> string
+ (** Endianness. *)
+
+-type bitstring = string * int * int
++type bitstring = bytes * int * int
+ (** [bitstring] is the basic type used to store bitstrings.
+
+ The type contains the underlying data (a string),
+diff --git a/bitstring_persistent.mli b/bitstring_persistent.mli
+index 10cbee3..305091e 100644
+--- a/bitstring_persistent.mli
++++ b/bitstring_persistent.mli
+@@ -305,7 +305,7 @@ val named_to_channel : out_channel -> named -> unit
+ val named_to_string : named -> string
+ (** Serialize a pattern/constructor to a string. *)
+
+-val named_to_buffer : string -> int -> int -> named -> int
++val named_to_buffer : bytes -> int -> int -> named -> int
+ (** Serialize a pattern/constructor to part of a string, return the length. *)
+
+ val named_from_channel : in_channel -> named
diff --git a/debian/patches/series b/debian/patches/series
index 36d495b..518d5aa 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
0001-Fix-camlp4of.opt-detection-in-configure.patch
0002-Allow-byte-only-compilation.patch
0003-Fix-META-file-for-bitstring.syntax.patch
+0004-Fix-compilation-with-OCaml-4.08.0.patch