diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-11-03 10:45:58 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-11-09 22:06:32 +0000 |
commit | a0a575767e23de1e2cf357e7c8743ebcba57bd68 (patch) | |
tree | 891b3d89d5d780e2423b2469f60112ad194eb080 /resize/utils.ml | |
parent | 57ec81a9f33e0eaabeca50a966f680820c519d52 (diff) | |
download | libguestfs-a0a575767e23de1e2cf357e7c8743ebcba57bd68.tar.gz libguestfs-a0a575767e23de1e2cf357e7c8743ebcba57bd68.tar.xz libguestfs-a0a575767e23de1e2cf357e7c8743ebcba57bd68.zip |
resize: Remove requirement for ocaml Pcre library.
This library is not available in RHEL 6, and in any case removing the
dependency is a simple change.
(cherry picked from commit ffbafadcb8dfebcaba529cb8d7e2da52dd032d8a)
Diffstat (limited to 'resize/utils.ml')
-rw-r--r-- | resize/utils.ml | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/resize/utils.ml b/resize/utils.ml index dc134be6..c11740fd 100644 --- a/resize/utils.ml +++ b/resize/utils.ml @@ -102,23 +102,16 @@ let feature_available (g : Guestfs.guestfs) names = (* Parse the size field from --resize and --resize-force options. *) let parse_size = - let const_re = Pcre.regexp "^([.\\d]+)([bKMG])$" - and plus_const_re = Pcre.regexp "^\\+([.\\d]+)([bKMG])$" - and minus_const_re = Pcre.regexp "^-([.\\d]+)([bKMG])$" - and percent_re = Pcre.regexp "^([.\\d]+)%$" - and plus_percent_re = Pcre.regexp "^\\+([.\\d]+)%$" - and minus_percent_re = Pcre.regexp "^-([.\\d]+)%$" + let const_re = Str.regexp "^\\([.0-9]+\\)\\([bKMG]\\)$" + and plus_const_re = Str.regexp "^\\+\\([.0-9]+\\)\\([bKMG]\\)$" + and minus_const_re = Str.regexp "^-\\([.0-9]+\\)\\([bKMG]\\)$" + and percent_re = Str.regexp "^\\([.0-9]+\\)%$" + and plus_percent_re = Str.regexp "^\\+\\([.0-9]+\\)%$" + and minus_percent_re = Str.regexp "^-\\([.0-9]+\\)%$" in fun oldsize field -> - let subs = ref None in - let matches rex = - try subs := Some (Pcre.exec ~rex field); true - with Not_found -> false - in - let sub i = - match !subs with None -> assert false - | Some subs -> Pcre.get_substring subs i - in + let matches rex = Str.string_match rex field 0 in + let sub i = Str.matched_group i field in let size_scaled f = function | "b" -> Int64.of_float f | "K" -> Int64.of_float (f *. 1024.) |