On Mon, Feb 25, 2019 at 05:22:50PM +0100, Pino Toscano wrote: > diff --git a/common/mlpcre/pcre_tests.ml b/common/mlpcre/pcre_tests.ml > index 346019c40..f199ad63a 100644 > --- a/common/mlpcre/pcre_tests.ml > +++ b/common/mlpcre/pcre_tests.ml > @@ -18,6 +18,10 @@ > > open Printf > > +let optget def = function > + | None -> def > + | Some v -> v
This is the same as Option.default (from Std_utils), so this function isn't needed. But in any case OCaml will do this automatically for you: > +let matches ?offset re str = let matches ?(offset = 0) re str = will replace offset by 0 if the labelled parameter wasn't given. > + eprintf "PCRE.matches %s, %d ->%!" str (optget 0 offset); > + let r = PCRE.matches ?offset re str in With the change above, the type of offset is int so you can pass it to PCRE.matches using ~offset instead of ?offset. However in general this patch is fine, so ACK if you fix the above. Rich. > eprintf " %b\n%!" r; > r > > @@ -103,6 +107,11 @@ let () = > assert (subi 1 = (2, 3)); > assert (subi 2 = (3, 3)); > > + assert (matches ~offset:5 re0 "aaabcabc" = true); > + assert (sub 0 = "ab"); > + > + assert (matches ~offset:5 re0 "aaabcbaac" = false); > + > assert (replace re0 "dd" "abcabcaabccca" = "ddcabcaabccca"); > assert (replace ~global:true re0 "dd" "abcabcaabccca" = "ddcddcddccca"); > > -- > 2.20.1 > > _______________________________________________ > Libguestfs mailing list > Libguestfs@redhat.com > https://www.redhat.com/mailman/listinfo/libguestfs -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/ _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs