This commit is contained in:
1 parent
04ba4437f0
commit
8645471410
2 files changed
+19
-4
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
(name totpin)
|
||||
|
||||
(version 1.0)
|
||||
(version 1.1)
|
||||
|
||||
(generate_opam_files true)
|
||||
|
||||
|
||||
+18
-3
@@ -21,7 +21,13 @@ let rec map_result f = function
|
||||
Ok (y :: ys)
|
||||
|
||||
let ocamlfind args = Cmd.(v "ocamlfind" %% of_list args)
|
||||
let lines cmd = OS.Cmd.(run_out cmd |> to_lines)
|
||||
let chop_cr s =
|
||||
let n = String.length s in
|
||||
if n > 0 && s.[n - 1] = '\r' then String.sub s 0 (n - 1) else s
|
||||
|
||||
let lines cmd =
|
||||
let* l = OS.Cmd.(run_out cmd |> to_lines) in
|
||||
Ok (List.map chop_cr l)
|
||||
|
||||
let line cmd =
|
||||
let* l = lines cmd in
|
||||
@@ -29,9 +35,18 @@ let line cmd =
|
||||
| x :: _ -> Ok x
|
||||
| [] -> msg "no output from: %s" (Cmd.to_string cmd)
|
||||
|
||||
(* Windows writes paths with backslashes, and drive letters in either case. *)
|
||||
(* Windows writes paths with backslashes (doubled in the .changes files, where
|
||||
they are escaped), and drive letters in either case. *)
|
||||
let normalize s =
|
||||
String.lowercase_ascii (String.map (function '\\' -> '/' | c -> c) 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
|
||||
|
||||
let starts_with ~prefix s =
|
||||
String.length s >= String.length prefix
|
||||
|
||||
Reference in new issue
Block a user