Blob Blame History Raw
From 5c5eff66dfaccb212b8906e769e40633d8b8f5e4 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 13 Feb 2018 08:20:52 +0000
Subject: [PATCH 1/2] Fix Bytes/String for OCaml 4.06.

---
 src/format_ext2_kernel.ml |  4 ++--
 src/mode_build.ml         | 10 ++++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/format_ext2_kernel.ml b/src/format_ext2_kernel.ml
index d5d529d..98bff3a 100644
--- a/src/format_ext2_kernel.ml
+++ b/src/format_ext2_kernel.ml
@@ -290,9 +290,9 @@ and read_leshort chan offset =
 
 and read_string chan offset len =
   seek_in chan offset;
-  let buf = String.create len in
+  let buf = Bytes.create len in
   really_input chan buf 0 len;
-  buf
+  Bytes.to_string buf
 
 and copy_or_symlink_file copy_kernel src dest =
   if not copy_kernel then
diff --git a/src/mode_build.ml b/src/mode_build.ml
index 95869cb..b5f5fa6 100644
--- a/src/mode_build.ml
+++ b/src/mode_build.ml
@@ -299,9 +299,10 @@ and update_appliance appliance lines = function
 (* Determine the [file_type] of [file], or exit with an error. *)
 and get_file_type file =
   let chan = open_in file in
-  let buf = String.create 512 in
-  let len = input chan buf 0 (String.length buf) in
+  let buf = Bytes.create 512 in
+  let len = input chan buf 0 (Bytes.length buf) in
   close_in chan;
+  let buf = Bytes.to_string buf in
 
   if len >= 3 && buf.[0] = '\x1f' && buf.[1] = '\x8b' && buf.[2] = '\x08'
   then                                  (* gzip-compressed file *)
@@ -335,8 +336,9 @@ and get_file_content file buf len =
 and get_compressed_file_content zcat file =
   let cmd = sprintf "%s %s" zcat (quote file) in
   let chan_out, chan_in, chan_err = open_process_full cmd [||] in
-  let buf = String.create 512 in
-  let len = input chan_out buf 0 (String.length buf) in
+  let buf = Bytes.create 512 in
+  let len = input chan_out buf 0 (Bytes.length buf) in
+  let buf = Bytes.to_string buf in
   (* We're expecting the subprocess to fail because we close the pipe
    * early, so:
    *)
-- 
2.19.0.rc0