[Libguestfs] [PATCH] common/mlstdutils: Implement StringSet.

Richard W.M. Jones rjones at redhat.com
Fri Jul 21 16:11:58 UTC 2017


---
 builder/sources.ml                           |  2 --
 common/mlstdutils/Makefile.am                |  4 ++-
 common/mlstdutils/stringSet.ml               | 19 ++++++++++++
 common/mlstdutils/stringSet.mli              | 46 ++++++++++++++++++++++++++++
 dib/elements.ml                              |  2 --
 sysprep/sysprep_operation_ca_certificates.ml |  1 -
 sysprep/sysprep_operation_kerberos_data.ml   |  1 -
 sysprep/sysprep_operation_rpm_db.ml          |  1 -
 sysprep/sysprep_operation_user_account.ml    |  2 --
 v2v/create_libvirt_xml.ml                    |  2 --
 10 files changed, 68 insertions(+), 12 deletions(-)

diff --git a/builder/sources.ml b/builder/sources.ml
index 4c9ea0fff..48687bb26 100644
--- a/builder/sources.ml
+++ b/builder/sources.ml
@@ -34,8 +34,6 @@ and source_format =
 | FormatNative
 | FormatSimpleStreams
 
-module StringSet = Set.Make (String)
-
 let parse_conf file =
   debug "trying to read %s" file;
   let sections = Ini_reader.read_ini ~error_suffix:"[ignored]" file in
diff --git a/common/mlstdutils/Makefile.am b/common/mlstdutils/Makefile.am
index a6357bf6c..108adcc52 100644
--- a/common/mlstdutils/Makefile.am
+++ b/common/mlstdutils/Makefile.am
@@ -24,13 +24,15 @@ EXTRA_DIST = \
 
 SOURCES_MLI = \
 	std_utils.mli \
-	stringMap.mli
+	stringMap.mli \
+	stringSet.mli
 
 SOURCES_ML = \
 	guestfs_config.ml \
 	$(OCAML_BYTES_COMPAT_ML) \
 	libdir.ml \
 	stringMap.ml \
+	stringSet.ml \
 	std_utils.ml
 
 # We pretend that we're building a C library.  automake handles the
diff --git a/common/mlstdutils/stringSet.ml b/common/mlstdutils/stringSet.ml
new file mode 100644
index 000000000..b63965705
--- /dev/null
+++ b/common/mlstdutils/stringSet.ml
@@ -0,0 +1,19 @@
+(* virt-v2v
+ * Copyright (C) 2009-2017 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+include Set.Make (String)
diff --git a/common/mlstdutils/stringSet.mli b/common/mlstdutils/stringSet.mli
new file mode 100644
index 000000000..e2889d86e
--- /dev/null
+++ b/common/mlstdutils/stringSet.mli
@@ -0,0 +1,46 @@
+(* virt-v2v
+ * Copyright (C) 2009-2017 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+type elt = String.t
+type t = Set.Make(String).t
+
+val empty : t
+val is_empty : t -> bool
+val mem : elt -> t -> bool
+val add : elt -> t -> t
+val singleton: elt -> t
+val remove: elt -> t -> t
+val union: t -> t -> t
+val inter: t -> t -> t
+val diff: t -> t -> t
+val compare: t -> t -> int
+val equal: t -> t -> bool
+val subset: t -> t -> bool
+val iter: (elt -> unit) -> t -> unit
+val map: (elt -> elt) -> t -> t
+val fold: (elt -> 'a -> 'a) -> t -> 'a -> 'a
+val for_all: (elt -> bool) -> t -> bool
+val exists: (elt -> bool) -> t -> bool
+val filter: (elt -> bool) -> t -> t
+val partition: (elt -> bool) -> t -> t * t
+val cardinal: t -> int
+val elements: t -> elt list
+val min_elt: t -> elt
+val max_elt: t -> elt
+val choose: t -> elt
+val split: elt -> t -> t * bool * t
diff --git a/dib/elements.ml b/dib/elements.ml
index d237eeb7f..6d668ea64 100644
--- a/dib/elements.ml
+++ b/dib/elements.ml
@@ -26,8 +26,6 @@ open Utils
 
 open Printf
 
-module StringSet = Set.Make (String)
-
 type element = {
   directory : string;
   hooks : hooks_map;
diff --git a/sysprep/sysprep_operation_ca_certificates.ml b/sysprep/sysprep_operation_ca_certificates.ml
index 1d85fda6c..e481cebf8 100644
--- a/sysprep/sysprep_operation_ca_certificates.ml
+++ b/sysprep/sysprep_operation_ca_certificates.ml
@@ -19,7 +19,6 @@
 open Sysprep_operation
 open Common_gettext.Gettext
 
-module StringSet = Set.Make (String)
 module G = Guestfs
 
 let ca_certificates_perform (g : Guestfs.guestfs) root side_effects =
diff --git a/sysprep/sysprep_operation_kerberos_data.ml b/sysprep/sysprep_operation_kerberos_data.ml
index 9dc794fd4..bee39f7ff 100644
--- a/sysprep/sysprep_operation_kerberos_data.ml
+++ b/sysprep/sysprep_operation_kerberos_data.ml
@@ -19,7 +19,6 @@
 open Sysprep_operation
 open Common_gettext.Gettext
 
-module StringSet = Set.Make (String)
 module G = Guestfs
 
 let kerberos_data_perform (g : Guestfs.guestfs) root side_effects =
diff --git a/sysprep/sysprep_operation_rpm_db.ml b/sysprep/sysprep_operation_rpm_db.ml
index 81190e0b8..be4740686 100644
--- a/sysprep/sysprep_operation_rpm_db.ml
+++ b/sysprep/sysprep_operation_rpm_db.ml
@@ -19,7 +19,6 @@
 open Sysprep_operation
 open Common_gettext.Gettext
 
-module StringSet = Set.Make (String)
 module G = Guestfs
 
 let rpm_db_perform (g : Guestfs.guestfs) root side_effects =
diff --git a/sysprep/sysprep_operation_user_account.ml b/sysprep/sysprep_operation_user_account.ml
index 2a633f5d8..3102a6267 100644
--- a/sysprep/sysprep_operation_user_account.ml
+++ b/sysprep/sysprep_operation_user_account.ml
@@ -28,8 +28,6 @@ open Sysprep_operation
 
 module G = Guestfs
 
-module StringSet = Set.Make (String)
-
 let remove_users = ref StringSet.empty
 let keep_users = ref StringSet.empty
 let add_users set users =
diff --git a/v2v/create_libvirt_xml.ml b/v2v/create_libvirt_xml.ml
index f5dca2d57..1551e259c 100644
--- a/v2v/create_libvirt_xml.ml
+++ b/v2v/create_libvirt_xml.ml
@@ -27,8 +27,6 @@ open Types
 open Utils
 open DOM
 
-module StringSet = Set.Make (String)
-
 let string_set_of_list =
   List.fold_left (fun set x -> StringSet.add x set) StringSet.empty
 
-- 
2.13.2




More information about the Libguestfs mailing list