pkgsrc/net/mldonkey/patches/patch-src_utils_cdk_tar.mlcpp
dholland d0f7d58cdf Partial build fixes for ocaml 4.06.
not at all clear this thing is worth the trouble...
2018-03-14 14:05:37 +00:00

112 lines
4 KiB
Text

$NetBSD: patch-src_utils_cdk_tar.mlcpp,v 1.1 2018/03/14 14:05:37 dholland Exp $
Fix build with ocaml 4.06
--- src/utils/cdk/tar.mlcpp.orig 2010-12-19 10:10:24.000000000 +0000
+++ src/utils/cdk/tar.mlcpp
@@ -169,7 +169,7 @@ let align_at_header t =
| None -> ()
| Some h ->
let entry_size = ((h.t_size/blocksize) + 1) * blocksize
- and buf = String.create blocksize
+ and buf = Bytes.create blocksize
and discarded = ref 0 in
while !discarded < entry_size do
let read = t.chan#input buf 0 blocksize in
@@ -177,7 +177,7 @@ let align_at_header t =
done;
t.last_header <- None
-let empty_block = String.make blocksize '\000'
+let empty_block = Bytes.make blocksize '\000'
let compute_chksum buf =
let chksum = ref 256 in (* 256 is the sum of 8 ' ' characters for the chksum field *)
@@ -206,8 +206,9 @@ let read_oldgnu_header header =
}
let read_gnu_header t =
- let buf = String.create blocksize in
+ let buf = Bytes.create blocksize in
t.chan#really_input buf 0 blocksize;
+ let buf = Bytes.to_string buf in
{ t_atime = extract_int32 buf 0 12;
t_ctime = extract_int32 buf 12 12;
t_offset = extract_int32 buf 24 12;
@@ -216,9 +217,10 @@ let read_gnu_header t =
let read_header t =
align_at_header t;
- let buf = String.create blocksize in
+ let buf = Bytes.create blocksize in
t.chan#really_input buf 0 blocksize;
if buf = empty_block then raise End_of_file;
+ let buf = Bytes.to_string buf in
let head1 = { t_name = c_string buf 0;
t_mode = extract_num buf 100 8;
t_uid = extract_num buf 108 8;
@@ -264,14 +266,14 @@ let read_body t =
let header = get_header t in
t.last_header <- None;
if header.t_size = 0 then ""
- else let buf = String.create header.t_size in
+ else let buf = Bytes.create header.t_size in
t.chan#really_input buf 0 header.t_size;
let align = blocksize - (header.t_size mod blocksize) in
if align <> blocksize then begin
- let leftover = String.create blocksize in
+ let leftover = Bytes.create blocksize in
t.chan#really_input leftover 0 align
end;
- buf
+ Bytes.to_string buf
let read_entry t =
let head = read_header t in
@@ -291,7 +293,7 @@ end
#ifdef USE_BZIP2
class bzout_chan o = object
- method output str pos len = Bzip2.output o str pos len
+ method output str pos len = Bzip2.output o (Bytes.to_string str) pos len
method flush () = Bzip2.flush o
method close () = Bzip2.close_out o
end
@@ -390,14 +392,14 @@ let write_gnu_header t buf =
let output t head body =
let size = String.length body in
- let buf = String.copy empty_block in
+ let buf = Bytes.copy empty_block in
write_str buf 0 100 head.t_name;
write_num8 buf 100 head.t_mode;
write_num8 buf 108 head.t_uid;
write_num8 buf 116 head.t_gid;
write_num12 buf 124 size;
write_int32 buf 136 head.t_mtime;
- buf.[156] <- typeflag_to_char head.t_typeflag;
+ Bytes.set buf 156 (typeflag_to_char head.t_typeflag);
write_str buf 157 100 head.t_linkname;
write_magic buf 257 head.t_format;
write_str buf 265 32 head.t_uname;
@@ -407,16 +409,16 @@ let output t head body =
write_str buf 345 155 head.t_prefix;
if head.t_format = OLDGNU_FORMAT then
write_oldgnu_header head buf;
- let chksum = compute_chksum buf in
+ let chksum = compute_chksum (Bytes.to_string buf) in
write_padded_num buf 148 chksum;
t.ochan#output buf 0 blocksize;
- if head.t_format = GNU_FORMAT && isdigit buf.[156] then begin
- let buf2 = String.copy empty_block in
+ if head.t_format = GNU_FORMAT && isdigit (Bytes.get buf 156) then begin
+ let buf2 = Bytes.copy empty_block in
write_gnu_header head buf2;
t.ochan#output buf2 0 blocksize
end;
if size > 0 then begin
- t.ochan#output body 0 size;
+ t.ochan#output (Bytes.of_string body) 0 size;
let align = blocksize - (size mod blocksize) in
if align > 0 && align < blocksize then
t.ochan#output empty_block 0 align