Same as the function defined in fish/fish.c.
---
mllib/common_utils.ml | 19 +++++++++++++++++++
mllib/common_utils.mli | 4 ++++
2 files changed, 23 insertions(+)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 73546d773..63d8dd92e 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -70,6 +70,25 @@ module Char = struct
| 'a'..'z' -> true
| 'A'..'Z' -> true
| _ -> false
+
+ let hexdigit = function
+ | '0' -> 0
+ | '1' -> 1
+ | '2' -> 2
+ | '3' -> 3
+ | '4' -> 4
+ | '5' -> 5
+ | '6' -> 6
+ | '7' -> 7
+ | '8' -> 8
+ | '9' -> 9
+ | 'a' | 'A' -> 10
+ | 'b' | 'B' -> 11
+ | 'c' | 'C' -> 12
+ | 'd' | 'D' -> 13
+ | 'e' | 'E' -> 14
+ | 'f' | 'F' -> 15
+ | _ -> -1
end
module String = struct
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
index 1cd38ba83..ec41a8ff8 100644
--- a/mllib/common_utils.mli
+++ b/mllib/common_utils.mli
@@ -43,6 +43,10 @@ module Char : sig
(** Return true if the character is a US ASCII 7 bit alphabetic. *)
val isalnum : char -> bool
(** Return true if the character is a US ASCII 7 bit alphanumeric. *)
+
+ val hexdigit : char -> int
+ (** Return the value of a hex digit. If the char is not in
+ the set [[0-9a-fA-F]] then this returns [-1]. *)
end
(** Override the Char module from stdlib. *)
--
2.12.0