Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Sep 2021 08:04:21 GMT
From:      Alexey Dokuchaev <danfe@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: fbf7b485af84 - main - net-p2p/liberator: use proper string types to match OCaml I/O library.
Message-ID:  <202109030804.18384LC4066009@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by danfe:

URL: https://cgit.FreeBSD.org/ports/commit/?id=fbf7b485af84c0236981c6e9269123547421556a

commit fbf7b485af84c0236981c6e9269123547421556a
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2021-09-03 08:03:12 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2021-09-03 08:03:15 +0000

    net-p2p/liberator: use proper string types to match OCaml I/O library.
---
 net-p2p/liberator/files/patch-immutable-strings | 141 ++++++++++++++++++++++++
 1 file changed, 141 insertions(+)

diff --git a/net-p2p/liberator/files/patch-immutable-strings b/net-p2p/liberator/files/patch-immutable-strings
new file mode 100644
index 000000000000..9f9262637989
--- /dev/null
+++ b/net-p2p/liberator/files/patch-immutable-strings
@@ -0,0 +1,141 @@
+--- config.ml.orig	2003-04-09 23:32:54 UTC
++++ config.ml
+@@ -381,7 +381,7 @@ class configure ~defaults ~files ~required =
+       let len = in_channel_length file in
+       let data = String.create len in
+       really_input file data 0 len;
+-      let tokens = tokenize data in
++      let tokens = tokenize (Bytes.to_string data) in
+       if not default then
+ 	self#parse_tokens tokens
+       else self#parse_tokens_default tokens
+--- fcp.ml.orig	2003-04-09 23:32:54 UTC
++++ fcp.ml
+@@ -82,7 +82,7 @@ class transact connect = object (self)
+       begin try really_input in_chan data 0 len
+       with Sys_error _ -> raise Io_error
+       end;
+-      data
++      Bytes.to_string data
+     end
+   method private recv_soft len =
+     if not opened then raise Closed
+@@ -91,7 +91,7 @@ class transact connect = object (self)
+       let rlen =
+ 	try input in_chan data 0 len
+ 	with Sys_error _ -> raise Io_error
+-      in String.sub data 0 rlen
++      in Bytes.sub_string data 0 rlen
+   method private recv_line =
+     if not opened then raise Closed
+     else try input_line in_chan
+--- fstream.ml.orig	2003-04-09 23:32:54 UTC
++++ fstream.ml
+@@ -18,8 +18,8 @@ class virtual fstream_in =
+     method virtual input_line : string
+     method virtual input : int -> string
+     method virtual really_input : int -> string
+-    method virtual input_buf : string -> int -> int -> int
+-    method virtual really_input_buf : string -> int -> int -> unit
++    method virtual input_buf : bytes -> int -> int -> int
++    method virtual really_input_buf : bytes -> int -> int -> unit
+     method virtual seek : int -> unit
+     method virtual pos : int
+   end
+@@ -34,7 +34,7 @@ class fstream_in_channel chan =
+       let buf = String.create len in
+       let len_read = input chan buf 0 len in
+       if len_read > 0 then
+-	String.sub buf 0 len_read
++	Bytes.sub_string buf 0 len_read
+       else
+ 	if self#pos = self#length then
+ 	  raise End_of_file
+@@ -42,7 +42,7 @@ class fstream_in_channel chan =
+     method really_input len =
+       let buf = String.create len in
+       really_input chan buf 0 len;
+-      buf
++      Bytes.to_string buf
+     method input_buf buf off len =
+       try input chan buf off len
+       with Invalid_argument _ ->
+@@ -165,7 +165,7 @@ class fstream_out_channel chan =
+     inherit fstream_out
+     method output_char ch = output_char chan ch
+     method output_string data = output_string chan data
+-    method output_buf buf off len = output chan buf off len
++    method output_buf buf off len = output chan (Bytes.of_string buf) off len
+     method output_byte byte = output_byte chan byte
+     method clear = seek_out chan 0
+   end
+--- fstream.mli.orig	2003-04-09 23:32:54 UTC
++++ fstream.mli
+@@ -17,8 +17,8 @@ class virtual fstream_in : object
+   method virtual input_line : string
+   method virtual input : int -> string
+   method virtual really_input : int -> string
+-  method virtual input_buf : string -> int -> int -> int
+-  method virtual really_input_buf : string -> int -> int -> unit
++  method virtual input_buf : bytes -> int -> int -> int
++  method virtual really_input_buf : bytes -> int -> int -> unit
+   method virtual seek : int -> unit
+   method virtual pos : int
+ end
+@@ -29,8 +29,8 @@ class fstream_in_channel : in_channel -> object
+   method input_line : string
+   method input : int -> string
+   method really_input : int -> string
+-  method input_buf : string -> int -> int -> int
+-  method really_input_buf : string -> int -> int -> unit
++  method input_buf : bytes -> int -> int -> int
++  method really_input_buf : bytes -> int -> int -> unit
+   method seek : int -> unit
+   method pos : int
+ end
+@@ -42,8 +42,8 @@ class fstream_in_string : string -> object
+   method input_line : string
+   method input : int -> string
+   method really_input : int -> string
+-  method input_buf : string -> int -> int -> int
+-  method really_input_buf : string -> int -> int -> unit
++  method input_buf : bytes -> int -> int -> int
++  method really_input_buf : bytes -> int -> int -> unit
+   method seek : int -> unit
+   method pos : int
+ end
+--- hlfreenet.ml.orig	2003-04-09 23:32:54 UTC
++++ hlfreenet.ml
+@@ -653,8 +653,8 @@ let rec insert node_info uri htl map stream =
+ 	  let len = stream#input_buf buf 0 node_info.nin_block_len in
+ 	  if len > 0 then begin
+ 	    if len = node_info.nin_block_len then
+-	      transact#block buf
+-	    else transact#block (String.sub buf 0 len);
++	      transact#block (Bytes.to_string buf)
++	    else transact#block (Bytes.sub_string buf 0 len);
+ 	    step ()
+ 	  end else ()
+ 	with
+@@ -820,8 +820,8 @@ let generate_chk node_info map (stream : fstream_in) =
+       let len = stream#input_buf buf 0 node_info.nin_block_len in
+       if len > 0 then begin
+ 	if len = node_info.nin_block_len then
+-	  transact#block buf
+-	else transact#block (String.sub buf 0 len);
++	  transact#block (Bytes.to_string buf)
++	else transact#block (Bytes.sub_string buf 0 len);
+ 	step ()
+       end else ()
+     with
+--- liber.ml.orig	2003-04-09 23:32:54 UTC
++++ liber.ml
+@@ -463,7 +463,7 @@ let basic_metadata conf (log : Log.log_type) =
+ 	let buf = String.create len in
+ 	really_input channel buf 0 len;
+ 	close_in channel;
+-	fields_parse buf
++	fields_parse (Bytes.to_string buf)
+       with Sys_error _ ->
+ 	raise (Die_msg ("cannot open or read metadata file " ^ file))
+       end



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109030804.18384LC4066009>