diff options
author | pboutill <pboutill@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-05-23 14:41:24 +0000 |
---|---|---|
committer | pboutill <pboutill@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2012-05-23 14:41:24 +0000 |
commit | 8837c2365c382adb0a74bfedabb1659eeb472adc (patch) | |
tree | 88761584df9487ab39fe2bc2627c029d67acc229 /lib/util.ml | |
parent | 24473ef1954c856907ba8907a4d2c910505125a1 (diff) |
Revert copy/pasted function in to minilib thanks to clib.cma
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@15352 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib/util.ml')
-rw-r--r-- | lib/util.ml | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml index 85ff2cbc4..ddc88e83b 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -67,6 +67,12 @@ let strip s = let a = lstrip_rec 0 and b = rstrip_rec (n-1) in String.sub s a (b-a+1) +let string_map f s = + let l = String.length s in + let r = String.create l in + for i= 0 to (l - 1) do r.[i] <- f (s.[i]) done; + r + let drop_simple_quotes s = let n = String.length s in if n > 2 & s.[0] = '\'' & s.[n-1] = '\'' then String.sub s 1 (n-2) else s @@ -125,6 +131,17 @@ let parse_loadpath s = invalid_arg "parse_loadpath: find an empty dir in loadpath"; l +let subst_command_placeholder s t = + let buff = Buffer.create (String.length s + String.length t) in + let i = ref 0 in + while (!i < String.length s) do + if s.[!i] = '%' & !i+1 < String.length s & s.[!i+1] = 's' + then (Buffer.add_string buff t;incr i) + else Buffer.add_char buff s.[!i]; + incr i + done; + Buffer.contents buff + module Stringset = Set.Make(struct type t = string let compare (x:t) (y:t) = compare x y end) module Stringmap = Map.Make(struct type t = string let compare (x:t) (y:t) = compare x y end) |