Commit c249ccb9 authored by Johannes Kanig's avatar Johannes Kanig Committed by David Hauzar

OA26-022 move string utility function to string utility module

parent 4868b088
......@@ -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
......
......@@ -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]
......
......@@ -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 *)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment