[Libguestfs] [PATCH v2 14/18] v2v: -i ova: Use PCRE to match lines in manifest files.

Richard W.M. Jones rjones at redhat.com
Thu Sep 21 14:54:09 UTC 2017


---
 v2v/input_ova.ml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/v2v/input_ova.ml b/v2v/input_ova.ml
index 9ec991ba7..d521a9fc8 100644
--- a/v2v/input_ova.ml
+++ b/v2v/input_ova.ml
@@ -209,7 +209,7 @@ object
 
     (* Read any .mf (manifest) files and verify sha1. *)
     let mf = find_files exploded ".mf" in
-    let rex = Str.regexp "\\(SHA1\\|SHA256\\)(\\(.*\\))= \\([0-9a-fA-F]+\\)\r?" in
+    let rex = PCRE.compile "^(SHA1|SHA256)\\((.*)\\)= ([0-9a-fA-F]+)\r?$" in
     List.iter (
       fun mf ->
         debug "processing manifest %s" mf;
@@ -218,10 +218,10 @@ object
         let chan = open_in mf in
         let rec loop () =
           let line = input_line chan in
-          if Str.string_match rex line 0 then (
-            let mode = Str.matched_group 1 line in
-            let disk = Str.matched_group 2 line in
-            let expected = Str.matched_group 3 line in
+          if PCRE.matches rex line then (
+            let mode = PCRE.sub 1
+            and disk = PCRE.sub 2
+            and expected = PCRE.sub 3 in
             let csum = Checksums.of_string mode expected in
             try
               if partial then
-- 
2.13.2




More information about the Libguestfs mailing list