Previously, the file Rust.ml used the function String.starts_with. But this function is not available in older versions of OCaml. So an identical function (string_starts_with) has been created in utils.ml to be used instead. --- generator/utils.ml | 11 +++++++++++ generator/utils.mli | 3 +++ 2 files changed, 14 insertions(+)
diff --git a/generator/utils.ml b/generator/utils.ml index 96c15ac..9f97aa7 100644 --- a/generator/utils.ml +++ b/generator/utils.ml @@ -570,3 +570,14 @@ let camel_case name = a ^ String.uppercase_ascii (Str.first_chars x 1) ^ String.lowercase_ascii (Str.string_after x 1) ) "" xs + +(* Copied from OCaml's stdlib because it was not available in earlier versions + of OCaml. *) +let string_starts_with ~prefix s = + let len_s = String.length s + and len_pre = String.length prefix in + let rec aux i = + if i = len_pre then true + else if String.unsafe_get s i <> String.unsafe_get prefix i then false + else aux (i + 1) + in len_s >= len_pre && aux 0 diff --git a/generator/utils.mli b/generator/utils.mli index c7681a9..d2def0b 100644 --- a/generator/utils.mli +++ b/generator/utils.mli @@ -80,3 +80,6 @@ val pod2text : cache_key -> cache_value (* Convert C function name to upper-camel-case name. *) val camel_case : string -> string + +(* Same as [String.starts_with] in later versions of OCaml. *) +val string_starts_with : prefix:string -> string -> bool -- 2.42.0 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs