pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/ocaml-biniou Fix up mutable strings to make it b...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f449632d058c
branches:  trunk
changeset: 376906:f449632d058c
user:      dholland <dholland%pkgsrc.org@localhost>
date:      Sun Mar 11 02:30:34 2018 +0000

description:
Fix up mutable strings to make it build with ocaml 4.06.

diffstat:

 devel/ocaml-biniou/Makefile                     |    4 +-
 devel/ocaml-biniou/distinfo                     |   10 +-
 devel/ocaml-biniou/patches/patch-bi__inbuf.ml   |   81 +++++++++++++
 devel/ocaml-biniou/patches/patch-bi__inbuf.mli  |   33 +++++
 devel/ocaml-biniou/patches/patch-bi__io.ml      |  141 ++++++++++++++++++++++++
 devel/ocaml-biniou/patches/patch-bi__outbuf.ml  |   82 +++++++++++++
 devel/ocaml-biniou/patches/patch-bi__outbuf.mli |   24 ++++
 devel/ocaml-biniou/patches/patch-bi__stream.ml  |   18 +++
 devel/ocaml-biniou/patches/patch-bi__util.ml    |   52 ++++++++
 devel/ocaml-biniou/patches/patch-bi__vint.ml    |   15 ++
 10 files changed, 457 insertions(+), 3 deletions(-)

diffs (truncated from 514 to 300 lines):

diff -r dbc8b306a830 -r f449632d058c devel/ocaml-biniou/Makefile
--- a/devel/ocaml-biniou/Makefile       Sat Mar 10 23:15:15 2018 +0000
+++ b/devel/ocaml-biniou/Makefile       Sun Mar 11 02:30:34 2018 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.4 2018/01/10 16:53:08 jaapb Exp $
+# $NetBSD: Makefile,v 1.5 2018/03/11 02:30:34 dholland Exp $
 
 GITHUB_PROJECT=        biniou
 GITHUB_TAG=    v${PKGVERSION_NOREV}
 DISTNAME=      ${GITHUB_PROJECT}-1.0.13
 PKGNAME=       ocaml-${DISTNAME}
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    devel
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=mjambon/}
 
diff -r dbc8b306a830 -r f449632d058c devel/ocaml-biniou/distinfo
--- a/devel/ocaml-biniou/distinfo       Sat Mar 10 23:15:15 2018 +0000
+++ b/devel/ocaml-biniou/distinfo       Sun Mar 11 02:30:34 2018 +0000
@@ -1,7 +1,15 @@
-$NetBSD: distinfo,v 1.2 2017/07/13 10:41:33 jaapb Exp $
+$NetBSD: distinfo,v 1.3 2018/03/11 02:30:34 dholland Exp $
 
 SHA1 (biniou-1.0.13.tar.gz) = 87d62aeb15437f7ba26654b774b3106f374aad3c
 RMD160 (biniou-1.0.13.tar.gz) = 7b3306894c3407190acb707d53078ebd7118e82d
 SHA512 (biniou-1.0.13.tar.gz) = 2fe109e83260f546181dd26ea175d2c4f63d0f6604c6d26fa44ee31925ba1fdaac0139a436cd0271a31294de9cd8ea65f8dde0981403c652d31de721ef696788
 Size (biniou-1.0.13.tar.gz) = 24327 bytes
 SHA1 (patch-Makefile) = b9cf0685ae977211ebcc45b3f0e67408ae16162c
+SHA1 (patch-bi__inbuf.ml) = 3e62d15239d101323070655545e411a31f2dcda0
+SHA1 (patch-bi__inbuf.mli) = 7d493ce921bab96647117afe8ff554782259d85f
+SHA1 (patch-bi__io.ml) = 1330f33bd377d31f3bdf3d308b86e51ab77705bd
+SHA1 (patch-bi__outbuf.ml) = 7aa79eaccfd22b722b6d81f63c2fb74f6494eaa2
+SHA1 (patch-bi__outbuf.mli) = 21ce049e4133d2420c436e6021de99e0812f3456
+SHA1 (patch-bi__stream.ml) = 4e4d0c25d66bf83de682f353f8becc5fe25bf87f
+SHA1 (patch-bi__util.ml) = 1065354c10392255e1eedf2e5326c6c00bd6b8ff
+SHA1 (patch-bi__vint.ml) = 488d439585b4895174fb5434c6e3f5033e207828
diff -r dbc8b306a830 -r f449632d058c devel/ocaml-biniou/patches/patch-bi__inbuf.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/ocaml-biniou/patches/patch-bi__inbuf.ml     Sun Mar 11 02:30:34 2018 +0000
@@ -0,0 +1,81 @@
+$NetBSD: patch-bi__inbuf.ml,v 1.1 2018/03/11 02:30:34 dholland Exp $
+
+Fix up mutable strings to make it build with ocaml 4.06.
+
+--- bi_inbuf.ml~       2017-05-04 17:38:05.000000000 +0000
++++ bi_inbuf.ml
+@@ -1,5 +1,5 @@
+ type t = {
+-  mutable i_s : string;
++  mutable i_s : bytes;
+   mutable i_pos : int;
+   mutable i_len : int;
+   mutable i_offs : int;
+@@ -35,14 +35,14 @@ let read ib n =
+ let read_char ib =
+   let pos = ib.i_pos in
+   if ib.i_len - pos > 0 then (
+-    let c = String.unsafe_get ib.i_s pos in
++    let c = Bytes.unsafe_get ib.i_s pos in
+     ib.i_pos <- pos + 1;
+     c
+   )
+   else
+     if try_preread ib 1 > 0 then
+       let pos = ib.i_pos in
+-      let c = String.unsafe_get ib.i_s pos in
++      let c = Bytes.unsafe_get ib.i_s pos in
+       ib.i_pos <- pos + 1;
+       c
+     else
+@@ -51,24 +51,27 @@ let read_char ib =
+ let peek ib =
+   let pos = ib.i_pos in
+   if ib.i_len - pos > 0 then (
+-    String.unsafe_get ib.i_s pos
++    Bytes.unsafe_get ib.i_s pos
+   )
+   else
+     if try_preread ib 1 > 0 then
+-      String.unsafe_get ib.i_s ib.i_pos
++      Bytes.unsafe_get ib.i_s ib.i_pos
+     else
+       raise End_of_input
+ 
+-let from_string ?(pos = 0) ?(shrlen = 16) s = {
++let from_bytes ?(pos = 0) ?(shrlen = 16) s = {
+   i_s = s;
+   i_pos = pos;
+-  i_len = String.length s;
++  i_len = Bytes.length s;
+   i_offs = -pos;
+-  i_max_len = String.length s;
++  i_max_len = Bytes.length s;
+   i_refill = (fun ib n -> ());
+   i_shared = Bi_share.Rd.create shrlen;
+ }
+ 
++let from_string ?(pos = 0) ?(shrlen = 16) s =
++  from_bytes ~pos ~shrlen (Bytes.of_string s)
++
+ (*
+   Like Pervasives.really_input but returns the number of bytes
+   read instead of raising End_of_file when the end of file is reached.
+@@ -87,7 +90,7 @@ let refill_from_channel ic ib n =
+     let rem_len = ib.i_len - ib.i_pos in
+     if rem_len < n then
+       let s = ib.i_s in
+-      String.blit s ib.i_pos s 0 rem_len;
++      Bytes.blit s ib.i_pos s 0 rem_len;
+       let to_read = n - rem_len in
+       let really_read = not_really_input ic s rem_len to_read 0 in
+       ib.i_offs <- ib.i_offs + ib.i_pos;
+@@ -96,7 +99,7 @@ let refill_from_channel ic ib n =
+   )
+ 
+ let from_channel ?(len = 4096) ?(shrlen = 16) ic = {
+-  i_s = String.create len;
++  i_s = Bytes.create len;
+   i_pos = 0;
+   i_len = 0;
+   i_offs = 0;
diff -r dbc8b306a830 -r f449632d058c devel/ocaml-biniou/patches/patch-bi__inbuf.mli
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/ocaml-biniou/patches/patch-bi__inbuf.mli    Sun Mar 11 02:30:34 2018 +0000
@@ -0,0 +1,33 @@
+$NetBSD: patch-bi__inbuf.mli,v 1.1 2018/03/11 02:30:34 dholland Exp $
+
+Fix up mutable strings to make it build with ocaml 4.06.
+
+--- bi_inbuf.mli~      2017-05-04 17:38:05.000000000 +0000
++++ bi_inbuf.mli
+@@ -1,7 +1,7 @@
+ (** Input buffer *)
+ 
+ type t = {
+-  mutable i_s : string;
++  mutable i_s : bytes;
+     (** This is the buffer string.
+        It can be accessed for reading but should normally only
+        be written to or replaced only by the [i_refill] function.
+@@ -92,9 +92,17 @@ val peek : t -> char
+     @raise End_of_input if the end of input has already been reached.
+   *)
+ 
++val from_bytes : ?pos:int -> ?shrlen:int -> bytes -> t
++  (**
++     Create an input buffer from a byte buffer.
++     @param pos     position to start from. Default: 0.
++     @param shrlen  initial length of the table used to store shared values.
++  *)
++
+ val from_string : ?pos:int -> ?shrlen:int -> string -> t
+   (**
+      Create an input buffer from a string.
++     The string is copied into the internal buffer.
+      @param pos     position to start from. Default: 0.
+      @param shrlen  initial length of the table used to store shared values.
+   *)
diff -r dbc8b306a830 -r f449632d058c devel/ocaml-biniou/patches/patch-bi__io.ml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/ocaml-biniou/patches/patch-bi__io.ml        Sun Mar 11 02:30:34 2018 +0000
@@ -0,0 +1,141 @@
+$NetBSD: patch-bi__io.ml,v 1.1 2018/03/11 02:30:34 dholland Exp $
+
+Fix up mutable strings to make it build with ocaml 4.06.
+
+--- bi_io.ml~  2017-05-04 17:38:05.000000000 +0000
++++ bi_io.ml
+@@ -89,13 +89,13 @@ let write_hashtag ob h has_arg =
+   let h = mask_31bit h in
+   let pos = Bi_outbuf.alloc ob 4 in
+   let s = ob.o_s in
+-  String.unsafe_set s (pos+3) (Char.chr (h land 0xff));
++  Bytes.unsafe_set s (pos+3) (Char.chr (h land 0xff));
+   let h = h lsr 8 in
+-  String.unsafe_set s (pos+2) (Char.chr (h land 0xff));
++  Bytes.unsafe_set s (pos+2) (Char.chr (h land 0xff));
+   let h = h lsr 8 in
+-  String.unsafe_set s (pos+1) (Char.chr (h land 0xff));
++  Bytes.unsafe_set s (pos+1) (Char.chr (h land 0xff));
+   let h = h lsr 8 in
+-  String.unsafe_set s pos (
++  Bytes.unsafe_set s pos (
+     Char.chr (
+       if has_arg then h lor 0x80
+       else h
+@@ -110,12 +110,12 @@ let string_of_hashtag h has_arg =
+ let read_hashtag ib cont =
+   let i = Bi_inbuf.read ib 4 in
+   let s = ib.i_s in
+-  let x0 = Char.code s.[i] in
++  let x0 = Char.code (Bytes.get s i) in
+   let has_arg = x0 >= 0x80 in
+   let x1 = (x0 land 0x7f) lsl 24 in
+-  let x2 = (Char.code s.[i+1]) lsl 16 in
+-  let x3 = (Char.code s.[i+2]) lsl 8 in
+-  let x4 = Char.code s.[i+3] in
++  let x2 = (Char.code (Bytes.get s (i+1))) lsl 16 in
++  let x3 = (Char.code (Bytes.get s (i+2))) lsl 8 in
++  let x4 = Char.code (Bytes.get s (i+3)) in
+   let h = make_signed (x1 lor x2 lor x3 lor x4) in
+ 
+   cont ib h has_arg
+@@ -124,13 +124,13 @@ let read_hashtag ib cont =
+ let read_field_hashtag ib =
+   let i = Bi_inbuf.read ib 4 in
+   let s = ib.i_s in
+-  let x0 = Char.code (String.unsafe_get s i) in
++  let x0 = Char.code (Bytes.unsafe_get s i) in
+   if x0 < 0x80 then
+     Bi_util.error "Corrupted data (invalid field hashtag)";
+   let x1 = (x0 land 0x7f) lsl 24 in
+-  let x2 = (Char.code (String.unsafe_get s (i+1))) lsl 16 in
+-  let x3 = (Char.code (String.unsafe_get s (i+2))) lsl 8 in
+-  let x4 = Char.code (String.unsafe_get s (i+3)) in
++  let x2 = (Char.code (Bytes.unsafe_get s (i+1))) lsl 16 in
++  let x3 = (Char.code (Bytes.unsafe_get s (i+2))) lsl 8 in
++  let x4 = Char.code (Bytes.unsafe_get s (i+3)) in
+   make_signed (x1 lor x2 lor x3 lor x4)
+ 
+ 
+@@ -147,7 +147,7 @@ let write_numtag ob i has_arg =
+ 
+ let read_numtag ib cont =
+   let i = Bi_inbuf.read ib 1 in
+-  let x = Char.code ib.i_s.[i] in
++  let x = Char.code (Bytes.get ib.i_s i) in
+   let has_arg = x >= 0x80 in
+   cont ib (x land 0x7f) has_arg
+ 
+@@ -219,11 +219,11 @@ let read_untagged_float64 ib =
+   (match Lazy.force float_endianness with
+        `Little ->
+        for j = 0 to 7 do
+-         String.unsafe_set (Obj.obj x) (7-j) (String.unsafe_get s (i+j))
++         Bytes.unsafe_set (Obj.obj x) (7-j) (Bytes.unsafe_get s (i+j))
+        done
+      | `Big ->
+        for j = 0 to 7 do
+-         String.unsafe_set (Obj.obj x) j (String.unsafe_get s (i+j))
++         Bytes.unsafe_set (Obj.obj x) j (Bytes.unsafe_get s (i+j))
+        done
+   );
+   (Obj.obj x : float)
+@@ -234,11 +234,11 @@ let write_untagged_float64 ob x =
+   (match Lazy.force float_endianness with
+        `Little ->
+        for j = 0 to 7 do
+-         String.unsafe_set s (i+j) (String.unsafe_get (Obj.magic x) (7-j))
++         Bytes.unsafe_set s (i+j) (Bytes.unsafe_get (Obj.magic x) (7-j))
+        done
+      | `Big ->
+        for j = 0 to 7 do
+-         String.unsafe_set s (i+j) (String.unsafe_get (Obj.magic x) j)
++         Bytes.unsafe_set s (i+j) (Bytes.unsafe_get (Obj.magic x) j)
+        done
+   )
+ 
+@@ -526,16 +526,16 @@ let read_untagged_int8 ib =
+ let read_untagged_int16 ib =
+   let i = Bi_inbuf.read ib 2 in
+   let s = ib.i_s in
+-  ((Char.code s.[i]) lsl 8) lor (Char.code s.[i+1])
++  ((Char.code (Bytes.get s i)) lsl 8) lor (Char.code (Bytes.get s (i+1)))
+ 
+ 
+ let read_untagged_int32 ib =
+   let i = Bi_inbuf.read ib 4 in
+   let s = ib.i_s in
+   let x1 =
+-    Int32.of_int (((Char.code s.[i  ]) lsl 8) lor (Char.code s.[i+1])) in
++    Int32.of_int (((Char.code (Bytes.get s (i  ))) lsl 8) lor (Char.code (Bytes.get s (i+1)))) in
+   let x2 =
+-    Int32.of_int (((Char.code s.[i+2]) lsl 8) lor (Char.code s.[i+3])) in
++    Int32.of_int (((Char.code (Bytes.get s (i+2))) lsl 8) lor (Char.code (Bytes.get s (i+3)))) in
+   Int32.logor (Int32.shift_left x1 16) x2
+ 
+ let read_untagged_float32 ib =
+@@ -565,7 +565,7 @@ let read_untagged_int64 ib =
+ 
+ let read_untagged_string ib =
+   let len = Bi_vint.read_uvint ib in
+-  let str = String.create len in
++  let str = Bytes.create len in
+   let pos = ref 0 in
+   let rem = ref len in
+   while !rem > 0 do
+@@ -573,13 +573,13 @@ let read_untagged_string ib =
+     if bytes_read = 0 then
+       Bi_util.error "Corrupted data (string)"
+     else (
+-      String.blit ib.i_s ib.i_pos str !pos bytes_read;
++      Bytes.blit ib.i_s ib.i_pos str !pos bytes_read;
+       ib.i_pos <- ib.i_pos + bytes_read;
+       pos := !pos + bytes_read;
+       rem := !rem - bytes_read
+     )
+   done;
+-  str
++  Bytes.to_string str



Home | Main Index | Thread Index | Old Index