diff --git a/tools/gen_licenses.ml b/tools/gen_licenses.ml index 308c8a0..7344e78 100644 --- a/tools/gen_licenses.ml +++ b/tools/gen_licenses.ml @@ -33,16 +33,10 @@ let line cmd = (* Windows writes paths with backslashes (doubled in the .changes files, where they are escaped), and drive letters in either case. *) +let slashes = Re.compile (Re.rep1 (Re.set "/\\")) + let normalize s = - let b = Buffer.create (String.length s) in - String.iter - (fun c -> - let c = if c = '\\' then '/' else Char.lowercase_ascii c in - let n = Buffer.length b in - if not (c = '/' && n > 0 && Buffer.nth b (n - 1) = '/') then - Buffer.add_char b c) - s; - Buffer.contents b + String.lowercase_ascii (Re.replace_string slashes ~by:"/" s) let starts_with ~prefix s = String.length s >= String.length prefix