mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
mllib: Add Char.hexdigit function.
Same as the function defined in fish/fish.c.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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. *)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user