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-03 10:46:50 +0000 |
commit | ffbafadcb8dfebcaba529cb8d7e2da52dd032d8a (patch) | |
tree | ca7e095c997d061cfae5e569921965418a02a26e /resize | |
parent | 63898268101e5ec91c8dac46651dbee5976272ce (diff) | |
download | libguestfs-ffbafadcb8dfebcaba529cb8d7e2da52dd032d8a.tar.gz libguestfs-ffbafadcb8dfebcaba529cb8d7e2da52dd032d8a.tar.xz libguestfs-ffbafadcb8dfebcaba529cb8d7e2da52dd032d8a.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.
Diffstat (limited to 'resize')
-rw-r--r-- | resize/Makefile.am | 4 | ||||
-rw-r--r-- | resize/utils.ml | 23 |
2 files changed, 9 insertions, 18 deletions
diff --git a/resize/Makefile.am b/resize/Makefile.am index 32c5325c..69103d68 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -25,7 +25,6 @@ EXTRA_DIST = \ CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-resize test.img if HAVE_OCAML -if HAVE_OCAML_PCRE # Alphabetical order. SOURCES = \ @@ -49,7 +48,7 @@ bin_SCRIPTS = virt-resize # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L # option to be passed to gcc, so we don't try linking against an # installed copy of libguestfs. -OCAMLPACKAGES = -package pcre -I $(top_builddir)/src/.libs -I ../ocaml +OCAMLPACKAGES = -package str -I $(top_builddir)/src/.libs -I ../ocaml OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) OCAMLOPTFLAGS = $(OCAMLCFLAGS) @@ -124,7 +123,6 @@ include .depend .PHONY: depend docs endif -endif # Parallel builds don't obey dependencies for some reason we # don't understand. 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.) |