Blame SOURCES/0035-mllib-Add-Char.hexdigit-function.patch

90a56e
From 0279339ee9a7b61ebcb3f64846d94f8171872737 Mon Sep 17 00:00:00 2001
90a56e
From: "Richard W.M. Jones" <rjones@redhat.com>
90a56e
Date: Tue, 11 Apr 2017 08:32:04 +0100
90a56e
Subject: [PATCH] mllib: Add Char.hexdigit function.
90a56e
90a56e
Same as the function defined in fish/fish.c.
90a56e
90a56e
(cherry picked from commit ef261d69ed199cc07474a36c890f63df461b35a7)
90a56e
---
90a56e
 mllib/common_utils.ml  | 19 +++++++++++++++++++
90a56e
 mllib/common_utils.mli |  4 ++++
90a56e
 2 files changed, 23 insertions(+)
90a56e
90a56e
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
90a56e
index e1d6329..4593614 100644
90a56e
--- a/mllib/common_utils.ml
90a56e
+++ b/mllib/common_utils.ml
90a56e
@@ -70,6 +70,25 @@ module Char = struct
90a56e
       | 'a'..'z' -> true
90a56e
       | 'A'..'Z' -> true
90a56e
       | _ -> false
90a56e
+
90a56e
+    let hexdigit = function
90a56e
+      | '0' -> 0
90a56e
+      | '1' -> 1
90a56e
+      | '2' -> 2
90a56e
+      | '3' -> 3
90a56e
+      | '4' -> 4
90a56e
+      | '5' -> 5
90a56e
+      | '6' -> 6
90a56e
+      | '7' -> 7
90a56e
+      | '8' -> 8
90a56e
+      | '9' -> 9
90a56e
+      | 'a' | 'A' -> 10
90a56e
+      | 'b' | 'B' -> 11
90a56e
+      | 'c' | 'C' -> 12
90a56e
+      | 'd' | 'D' -> 13
90a56e
+      | 'e' | 'E' -> 14
90a56e
+      | 'f' | 'F' -> 15
90a56e
+      | _ -> -1
90a56e
 end
90a56e
 
90a56e
 module String = struct
90a56e
diff --git a/mllib/common_utils.mli b/mllib/common_utils.mli
90a56e
index 1cd38ba..ec41a8f 100644
90a56e
--- a/mllib/common_utils.mli
90a56e
+++ b/mllib/common_utils.mli
90a56e
@@ -43,6 +43,10 @@ module Char : sig
90a56e
     (** Return true if the character is a US ASCII 7 bit alphabetic. *)
90a56e
     val isalnum : char -> bool
90a56e
     (** Return true if the character is a US ASCII 7 bit alphanumeric. *)
90a56e
+
90a56e
+    val hexdigit : char -> int
90a56e
+    (** Return the value of a hex digit.  If the char is not in
90a56e
+        the set [[0-9a-fA-F]] then this returns [-1]. *)
90a56e
 end
90a56e
 (** Override the Char module from stdlib. *)
90a56e
 
90a56e
-- 
90a56e
2.9.4
90a56e