Blame SOURCES/0012-common-mltools-move-the-code-for-machine-readable-up.patch

10436e
From 692a752cf3e552790ada8cc07f937036adaa8bf0 Mon Sep 17 00:00:00 2001
10436e
From: Pino Toscano <ptoscano@redhat.com>
10436e
Date: Thu, 21 Mar 2019 17:16:37 +0100
10436e
Subject: [PATCH] common/mltools: move the code for machine readable up
10436e
10436e
Move the code for handling machine readable up in the file, so it can be
10436e
used by other functions.
10436e
10436e
Only code motion, no behaviour changes.
10436e
10436e
(cherry picked from commit 8b06ea0ebc9534e4fda9cc9a33c98f939401af79)
10436e
---
10436e
 common/mltools/tools_utils.ml | 60 +++++++++++++++++------------------
10436e
 1 file changed, 30 insertions(+), 30 deletions(-)
10436e
10436e
diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml
10436e
index 24641369e..5a35708cd 100644
10436e
--- a/common/mltools/tools_utils.ml
10436e
+++ b/common/mltools/tools_utils.ml
10436e
@@ -33,6 +33,36 @@ external c_inspect_decrypt : Guestfs.t -> int64 -> (string * key_store_key) list
10436e
 external c_set_echo_keys : unit -> unit = "guestfs_int_mllib_set_echo_keys" "noalloc"
10436e
 external c_set_keys_from_stdin : unit -> unit = "guestfs_int_mllib_set_keys_from_stdin" "noalloc"
10436e
 
10436e
+type machine_readable_fn = {
10436e
+  pr : 'a. ('a, unit, string, unit) format4 -> 'a;
10436e
+} (* [@@unboxed] *)
10436e
+
10436e
+type machine_readable_output_type =
10436e
+  | NoOutput
10436e
+  | Channel of out_channel
10436e
+  | File of string
10436e
+let machine_readable_output = ref NoOutput
10436e
+let machine_readable_channel = ref None
10436e
+let machine_readable () =
10436e
+  let chan =
10436e
+    if !machine_readable_channel = None then (
10436e
+      let chan =
10436e
+        match !machine_readable_output with
10436e
+        | NoOutput -> None
10436e
+        | Channel chan -> Some chan
10436e
+        | File f -> Some (open_out f) in
10436e
+      machine_readable_channel := chan
10436e
+    );
10436e
+    !machine_readable_channel
10436e
+  in
10436e
+  match chan with
10436e
+  | None -> None
10436e
+  | Some chan ->
10436e
+    let pr fs =
10436e
+      ksprintf (output_string chan) fs
10436e
+    in
10436e
+    Some { pr }
10436e
+
10436e
 (* ANSI terminal colours. *)
10436e
 let istty chan =
10436e
   Unix.isatty (Unix.descr_of_out_channel chan)
10436e
@@ -236,36 +266,6 @@ let human_size i =
10436e
     )
10436e
   )
10436e
 
10436e
-type machine_readable_fn = {
10436e
-  pr : 'a. ('a, unit, string, unit) format4 -> 'a;
10436e
-} (* [@@unboxed] *)
10436e
-
10436e
-type machine_readable_output_type =
10436e
-  | NoOutput
10436e
-  | Channel of out_channel
10436e
-  | File of string
10436e
-let machine_readable_output = ref NoOutput
10436e
-let machine_readable_channel = ref None
10436e
-let machine_readable () =
10436e
-  let chan =
10436e
-    if !machine_readable_channel = None then (
10436e
-      let chan =
10436e
-        match !machine_readable_output with
10436e
-        | NoOutput -> None
10436e
-        | Channel chan -> Some chan
10436e
-        | File f -> Some (open_out f) in
10436e
-      machine_readable_channel := chan
10436e
-    );
10436e
-    !machine_readable_channel
10436e
-  in
10436e
-  match chan with
10436e
-  | None -> None
10436e
-  | Some chan ->
10436e
-    let pr fs =
10436e
-      ksprintf (output_string chan) fs
10436e
-    in
10436e
-    Some { pr }
10436e
-
10436e
 type cmdline_options = {
10436e
   getopt : Getopt.t;
10436e
   ks : key_store;
10436e
-- 
10436e
2.26.2
10436e