From: Richard W.M. Jones Date: Thu, 8 May 2025 09:04:21 +0000 (+0100) Subject: augeas: Return matches list in order X-Git-Tag: v0.7~2 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=b703b92e3d26690aa6f7b822132049ce5435983e;p=ocaml-augeas.git augeas: Return matches list in order We built the list of matches in reverse order (compared to what Augeas itself gives us). So we have to reverse the list after building it so they are in the normal order. --- diff --git a/augeas-c.c b/augeas-c.c index 679bcb5..702613a 100644 --- a/augeas-c.c +++ b/augeas-c.c @@ -440,7 +440,9 @@ ocaml_augeas_match (value tv, value pathv) if (r == -1) raise_error (t, "Augeas.matches"); - /* Copy the paths to a list. */ + /* Copy the paths to a list. + * This builds the list in reverse order, but we call List.rev later. + */ rv = Val_int (0); for (i = 0; i < r; ++i) { v = caml_copy_string (matches[i]); diff --git a/augeas.ml b/augeas.ml index aa5a182..8b34641 100644 --- a/augeas.ml +++ b/augeas.ml @@ -76,8 +76,9 @@ external label : t -> path -> string option = "ocaml_augeas_label" external rm : t -> path -> int = "ocaml_augeas_rm" -external matches : t -> path -> path list +external matches' : t -> path -> path list = "ocaml_augeas_match" +let matches aug path = List.rev (matches' aug path) external count_matches : t -> path -> int = "ocaml_augeas_count_matches" external save : t -> unit