summaryrefslogtreecommitdiff
path: root/sid.ml
diff options
context:
space:
mode:
Diffstat (limited to 'sid.ml')
-rw-r--r--sid.ml37
1 files changed, 20 insertions, 17 deletions
diff --git a/sid.ml b/sid.ml
index 430393d..a2590fd 100644
--- a/sid.ml
+++ b/sid.ml
@@ -85,23 +85,26 @@ module StringFmt = struct
Error
(Printf.sprintf
"Invalid SID: ā€˜%sā€™ too short to be a SID in string format" s)
- else
- expect_char s 'S' 0;
- expect_char s '-' 1;
- expect_char s '1' 2;
- expect_char s '-' 3;
- let p = 4 in
- let p, ia = read_decimal_u64 s p in
- let sa = ref [] and p' = ref p in
- while !p' < n && List.length !sa < max_subauth_count do
- expect_char s '-' !p';
- let np, d = read_decimal_u32 s (!p' + 1) in
- sa := d :: !sa;
- p' := np
- done;
- Ok { sid_ident_auth = ia
- ; sid_sub_auths = Array.of_list (List.rev !sa)
- }
+ else begin
+ try
+ expect_char s 'S' 0;
+ expect_char s '-' 1;
+ expect_char s '1' 2;
+ expect_char s '-' 3;
+ let p = 4 in
+ let p, ia = read_decimal_u64 s p in
+ let sa = ref [] and p' = ref p in
+ while !p' < n && List.length !sa < max_subauth_count do
+ expect_char s '-' !p';
+ let np, d = read_decimal_u32 s (!p' + 1) in
+ sa := d :: !sa;
+ p' := np
+ done;
+ Ok { sid_ident_auth = ia
+ ; sid_sub_auths = Array.of_list (List.rev !sa)
+ }
+ with Invalid_argument e -> Error e;
+ end
let fmt_ident_auth b ia =
Buffer.add_string b (U64.to_string ia)