diff --git a/src/transform/intro_vc_vars_counterexmp.ml b/src/transform/intro_vc_vars_counterexmp.ml index df7a57032f08d4acc1d629c8c166acfa78529926..e94d5cce0bd7e9b49b23a58ab30b94c6506fa843 100644 --- a/src/transform/intro_vc_vars_counterexmp.ml +++ b/src/transform/intro_vc_vars_counterexmp.ml @@ -194,12 +194,6 @@ let () = Trans.register_transform "intro_vc_vars_counterexmp" intro_vc_vars_counterexmp ~desc:"Introduce." -let rec string_join sep l = - match l with - | [] -> "" - | [x] -> x - | x :: rest -> x ^ sep ^ string_join sep rest - let get_location_of_vc task = let meta_args = Task.on_meta_excl meta_vc_location task in match meta_args with @@ -214,7 +208,7 @@ let get_location_of_vc task = let line = int_of_string line in let col1 = int_of_string col1 in let col2 = int_of_string col2 in - let filename = string_join ":" (List.rev rest) in + let filename = Strings.join ":" (List.rev rest) in Some (Loc.user_position filename line col1 col2) | _ -> None in loc diff --git a/src/util/strings.ml b/src/util/strings.ml index f541f9eea9329c4e38292ef6aa72f0b73dbb79a4..c8481488982d0aae1cc9b2bc87cdcc5fceb42804 100644 --- a/src/util/strings.ml +++ b/src/util/strings.ml @@ -39,6 +39,12 @@ let rev_bounded_split c s n = let bounded_split c s n = List.rev (rev_bounded_split c s n) +let rec join sep l = + match l with + | [] -> "" + | [x] -> x + | x :: rest -> x ^ sep ^ join sep rest + let ends_with s suf = let rec aux s suf suflen offset i = i >= suflen || (s.[i + offset] = suf.[i] diff --git a/src/util/strings.mli b/src/util/strings.mli index ef6a32ad46fb2ac80e96dd02b5a29ae9449644ab..00727a50262418e9122a8ca20496ce5c5923695f 100644 --- a/src/util/strings.mli +++ b/src/util/strings.mli @@ -32,6 +32,10 @@ val bounded_split : char -> string -> int -> string list [n] substring at most. The concatenation of returned substrings is equal to the string s.*) +val join : string -> string list -> string +(** [join sep l] joins all the strings in [l] together, in the same + order, separating them by [sep] *) + val ends_with : string -> string -> bool (** test if a string ends with another *)