summaryrefslogtreecommitdiff
path: root/xxd.ml
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2018-11-06 22:29:44 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2018-11-07 00:32:35 +0100
commit39b9f77dbccecad50fb355cffb0e8e432e28f825 (patch)
treec20e7e5a64bd20a54f4507c453d723ef6c277c84 /xxd.ml
parent9991be9aeea6bc78b60603343e04245d374cbb93 (diff)
downloadocaml-sid-39b9f77dbccecad50fb355cffb0e8e432e28f825.tar.gz
sid: sid_test: handle large ias correctly
In string format, the “identifier authority” is quirky: from 1 << 32 on the spec requires that exactly 12 hex digits be printed.
Diffstat (limited to 'xxd.ml')
-rw-r--r--xxd.ml6
1 files changed, 3 insertions, 3 deletions
diff --git a/xxd.ml b/xxd.ml
index 50e0072..bafc17d 100644
--- a/xxd.ml
+++ b/xxd.ml
@@ -55,7 +55,7 @@ let every n i = i > 0 && i mod n = 0
(* result length can be calculated in advance so we can do
this without realloc() *)
-let xxd_of_bytes ?(blocklen=0) src =
+let of_bytes ?(blocklen=0) src =
let ls = Bytes.length src in
if ls = 0 then "" else
let ld = 2 * ls + if blocklen = 0 then 0 else (ls - 1) / blocklen in
@@ -85,7 +85,7 @@ let int_of_nibble c =
if 'A' <= c && c <= 'F' then Some (int_of_char c - base_upper ) else
None
-let bytes_of_xxd src =
+let bytes_of src =
let ls = String.length src in
if ls = 0 then Bytes.empty else
let buf = Buffer.create bufsiz in
@@ -93,7 +93,7 @@ let bytes_of_xxd src =
if is = ls then
if hi = None then (Buffer.contents buf |> (!!)) else
raise (Invalid_argument
- "bytes_of_xxd: odd number of hex digits in input")
+ "Xxd.bytes_of: odd number of hex digits in input")
else
match String.get src is |> int_of_nibble with
| None -> aux hi (is+1)