String.map was added in OCaml 4.00.0. However we use this function
to implement String.lowercase_ascii etc.
Therefore include a definition of the function for older versions of
OCaml. (Debian Wheezy has OCaml 3.12.1.)
(cherry picked from commit 5802c7750ee47b12a0497b45d8ca52e347328207)
---
mllib/common_utils.ml | 8 ++++++++
mllib/common_utils.mli | 2 ++
2 files changed, 10 insertions(+)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 2ba8f9a..4f56c91 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -37,6 +37,14 @@ end
module String = struct
include String
+ let map f s =
+ let len = String.length s in
+ let b = String.create len in
+ for i = 0 to len-1 do
+ unsafe_set b i (f (unsafe_get s i))
+ done;
+ b
+
let lowercase_ascii s = map Char.lowercase_ascii s
let uppercase_ascii s = map Char.uppercase_ascii s
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index ae89fd6..33a46bb 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -56,6 +56,8 @@ module String : sig
val unsafe_get : string -> int -> char
val unsafe_set : string -> int -> char -> unit
+ val map : (char -> char) -> string -> string
+
val lowercase_ascii : string -> string
val uppercase_ascii : string -> string
--
2.7.4