From b703b92e3d26690aa6f7b822132049ce5435983e Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 8 May 2025 10:04:21 +0100 Subject: [PATCH] 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. --- augeas-c.c | 4 +++- augeas.ml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 -- 1.8.3.1