@@ -13,7 +13,7 @@ let is_ascii s =
1313
1414let normalize = Uunf_string. normalize_utf_8 `NFKC
1515
16- let fold_uchars f acc str =
16+ let foldi_uchars ~ f acc str =
1717 let len = String. length str in
1818 let rec loop pos acc =
1919 if pos == len then acc
@@ -25,19 +25,22 @@ let fold_uchars f acc str =
2525 loop (pos + char_length) acc in
2626 loop 0 acc
2727
28- let iter_uchars s f =
28+ let iteri_uchars ~ f str =
2929 let f' buf pos c =
3030 f pos c;
3131 Buffer. add_utf_8_uchar buf c;
3232 buf in
3333 let s_after =
34- Buffer. contents @@ fold_uchars f' (Buffer. create (String. length s)) s in
34+ Buffer. contents
35+ @@ foldi_uchars ~f: f' (Buffer. create (String. length str)) str in
3536 (* another sanity check *)
36- if not (String. equal s s_after) then
37+ if not (String. equal str s_after) then
3738 Core. (
3839 ICE. internal_compiler_error
3940 [% message
40- " Failed to round-trip unicode string!" (s : string ) (s_after : string )])
41+ " Failed to round-trip unicode string!"
42+ (str : string )
43+ (s_after : string )])
4144
4245(* WIP:
4346
@@ -60,7 +63,7 @@ let confusable x y =
6063 (* TODO!! replace with prototype - need data? *)
6164 Buffer. add_utf_8_uchar acc c;
6265 acc in
63- let buf = fold_uchars f (Buffer. create (String. length x)) x in
66+ let buf = foldi_uchars ~ f (Buffer. create (String. length x)) x in
6467 let x = Buffer. contents buf in
6568 let x = Uunf_string. normalize_utf_8 `NFD x in
6669 x in
@@ -98,7 +101,7 @@ let restriction_level x =
98101 let scripts =
99102 Uucp.Script. script_extensions c |> ScriptSet. of_list |> extended in
100103 scripts :: acc in
101- let soss = fold_uchars f [] x in
104+ let soss = foldi_uchars ~ f [] x in
102105 let resolved = List. fold_right ScriptSet. inter soss all in
103106 if not @@ ScriptSet. is_empty resolved then `Single
104107 else `Unrestricted (* TODO implement levels 3-5 *)
0 commit comments