aboutsummaryrefslogtreecommitdiff
path: root/security/sks/files/patch-ocaml408
blob: e423502d534b223920f2cbd97adf38b5bcf32760 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
From e4ebec61064ba85941acec02efe60b98b54eddb1 Mon Sep 17 00:00:00 2001
From: Phil Pennock <codehacks@spodhuis.org>
Date: Mon, 16 Jan 2017 15:31:36 -0500
Subject: [PATCH] Compile with ocaml 4.02.3 (dev-mode fatal warnings)

---
 .hgignore     |  3 ++-
 add_mail.ml   |  2 +-
 bitstring.ml  | 73 ++++++++++++++++++++++++++-------------------------
 channel.ml    | 18 ++++++-------
 dbserver.ml   |  6 ++---
 heap.ml       |  8 +++---
 keyHash.ml    |  8 +++---
 linearAlg.ml  |  4 +--
 mList.ml      |  4 +--
 number.ml     | 20 +++++++-------
 prefixTree.ml | 20 +++++++-------
 rMisc.ml      | 35 +++++++++---------------
 rMisc.mli     |  3 ---
 utils.ml      | 36 +++++++++++--------------
 utils.mli     |  1 -
 wserver.ml    | 68 +++++++++++++++++++++++------------------------
 16 files changed, 147 insertions(+), 162 deletions(-)

diff --git a/add_mail.ml b/add_mail.ml
index 3233af6..f0f54d6 100644
--- add_mail.ml
+++ add_mail.ml
@@ -54,7 +54,7 @@ let dirname =
 (** dumps contents of one file into another *)
 let pipe_file =
   let blocksize = 100 * 1024 in
-  let buf = String.create blocksize in
+  let buf = BytesLabels.create blocksize in
   let rec pipe_file file1 file2 =
     let bytes_read = input file1 buf 0 blocksize in
     if bytes_read <> 0 then (
diff --git a/bitstring.ml b/bitstring.ml
index a6d3dad..5e89dbc 100644
--- bitstring.ml
+++ bitstring.ml
@@ -20,7 +20,8 @@
 (* USA or see <http://www.gnu.org/licenses/>.                          *)
 (***********************************************************************)

-open StdLabels
+open ArrayLabels
+open BytesLabels
 open MoreLabels

 module Unix=UnixLabels
@@ -40,14 +41,14 @@ let bytelength bits =
 let create bits =
   let bytes = bytelength bits
   in
-  { a = String.create bytes;
+  { a = BytesLabels.create bytes;
     bitlength = bits;
   }

 let get ba bit =
   let byte_pos = bit / width
   and bit_pos = bit mod width in
-  let intval = int_of_char (String.get ba.a byte_pos) in
+  let intval = int_of_char (BytesLabels.get ba.a byte_pos) in
   (intval lsr (width - bit_pos - 1)) land 1

 let lget ba bit = get ba bit = 1
@@ -55,27 +56,27 @@ let lget ba bit = get ba bit = 1
 let flip ba bit =
   let byte_pos = bit / width
   and bit_pos = bit mod width in
-  let intval = int_of_char (String.get ba.a byte_pos) in
+  let intval = int_of_char (BytesLabels.get ba.a byte_pos) in
   let new_char = char_of_int ((1 lsl (width - bit_pos - 1)) lxor intval)
   in
-  String.set ba.a byte_pos new_char
+  BytesLabels.set ba.a byte_pos new_char

 let set ba bit =
   let byte_pos = bit / width
   and bit_pos = bit mod width in
-  let intval = int_of_char (String.get ba.a byte_pos) in
+  let intval = int_of_char (BytesLabels.get ba.a byte_pos) in
   let new_char = char_of_int ((1 lsl (width - bit_pos - 1)) lor intval)
   in
-  String.set ba.a byte_pos new_char
+  BytesLabels.set ba.a byte_pos new_char

 let unset ba bit =
   let byte_pos = bit / width
   and bit_pos = bit mod width in
-  let intval = int_of_char (String.get ba.a byte_pos) in
+  let intval = int_of_char (BytesLabels.get ba.a byte_pos) in
   let new_char = char_of_int ((lnot (1 lsl (width - bit_pos - 1)))
                               land intval)
   in
-  String.set ba.a byte_pos new_char
+  BytesLabels.set ba.a byte_pos new_char

 let setval ba bit bool =
   if bool then set ba bit else unset ba bit
@@ -95,12 +96,12 @@ let hexprint ba =
   print_string (Utils.hexstring ba.a)

 let to_bool_array ba =
-  Array.init ~f:(fun i -> lget ba i) ba.bitlength
+  ArrayLabels.init ~f:(fun i -> lget ba i) ba.bitlength

 let to_string ba =
-  let string = String.create ba.bitlength in
+  let string = BytesLabels.create ba.bitlength in
   for i = 0 to ba.bitlength -1 do
-    if get ba i = 0 then string.[i] <- '0' else string.[i] <- '1'
+    if get ba i = 0 then BytesLabels.set string i '0' else BytesLabels.set string i '1'
   done;
   string

@@ -109,21 +110,21 @@ let to_bytes ba =
   for i = ba.bitlength to lastbit do
     unset ba i
   done;
-  String.sub ~pos:0 ~len:(bytelength ba.bitlength) ba.a
+  BytesLabels.sub ~pos:0 ~len:(bytelength ba.bitlength) ba.a

 let of_bytes string bitlength =
   { bitlength = bitlength;
-    a = String.copy string;
+    a = BytesLabels.copy string;
   }

 let of_byte b =
   { bitlength = width;
-    a = String.make 1 (char_of_int (b land 0xFF));
+    a = BytesLabels.make 1 (char_of_int (b land 0xFF));
   }

 let of_bytes_all string =
-  { bitlength = (String.length string) * width;
-    a = String.copy string;
+  { bitlength = (BytesLabels.length string) * width;
+    a = BytesLabels.copy string;
   }

 let of_int i =
@@ -137,7 +138,7 @@ let of_bytes_nocopy string bitlength =
   }

 let of_bytes_all_nocopy string =
-  { bitlength = (String.length string) * width;
+  { bitlength = (BytesLabels.length string) * width;
     a = string;
   }

@@ -152,7 +153,7 @@ let to_bytes_nocopy ba =
 (************************************************************)
 (************************************************************)

-let copy ba = { ba with a = String.copy ba.a }
+let copy ba = { ba with a = BytesLabels.copy ba.a }

 (** returns a copy of bitstring copied into a new bitstring of a new length.
   No guarantees are made as to the contents of the remainder of the bitstring
@@ -160,9 +161,9 @@ let copy ba = { ba with a = String.copy ba.a }
  *)
 let copy_len ba bitlength =
   let bytes = bytelength bitlength in
-  let str = String.create bytes in
-  String.blit ~src:ba.a ~src_pos:0
-    ~dst:str ~dst_pos:0 ~len:(String.length ba.a);
+  let str = BytesLabels.create bytes in
+  BytesLabels.blit ~src:ba.a ~src_pos:0
+    ~dst:str ~dst_pos:0 ~len:(BytesLabels.length ba.a);
   { a = str; bitlength = bitlength }

 (********************************************************************)
@@ -191,17 +192,17 @@ let shift_left_small ba bits =
   if bits > 0 then
     let bytes = bytelength ba.bitlength in
     for i = 0 to bytes-2 do
-      ba.a.[i] <- shift_pair_left ba.a.[i] ba.a.[i+1] bits
+      BytesLabels.set ba.a i (shift_pair_left ba.a.[i] ba.a.[i+1] bits)
     done;
-    ba.a.[bytes-1] <- shift_pair_left ba.a.[bytes-1] '\000' bits
+    BytesLabels.set ba.a (bytes-1) (shift_pair_left ba.a.[bytes-1] '\000' bits)

 let shift_right_small ba bits =
   if bits > 0 then
     let bytes = bytelength ba.bitlength in
     for i = bytes-1 downto 1 do
-      ba.a.[i] <- shift_pair_right ba.a.[i-1] ba.a.[i] bits
+      BytesLabels.set ba.a i (shift_pair_right ba.a.[i-1] ba.a.[i] bits)
     done;
-    ba.a.[0] <-  shift_pair_right '\000' ba.a.[0] bits
+    BytesLabels.set ba.a 0 (shift_pair_right '\000' ba.a.[0] bits)

 (**********************************)

@@ -216,10 +217,10 @@ let rec shift_left ba bits =
   then
     begin
       for i = 0 to bytelength - 1 - bytes do
-        ba.a.[i] <- ba.a.[i+bytes];
+        BytesLabels.set ba.a i ba.a.[i+bytes];
       done;
       for i = bytelength - bytes to bytelength - 1 do
-        ba.a.[i] <- '\000'
+        BytesLabels.set ba.a i '\000'
       done
     end;
   shift_left_small ba bits
@@ -235,10 +236,10 @@ and shift_right ba bits =
     then
       begin
         for i = bytelength - 1 downto bytes do
-          ba.a.[i] <- ba.a.[i-bytes];
+          BytesLabels.set ba.a i ba.a.[i-bytes];
         done;
         for i = bytes - 1 downto 0 do
-          ba.a.[i] <- '\000'
+          BytesLabels.set ba.a i '\000'
         done
       end;
     shift_right_small ba bits
@@ -251,7 +252,7 @@ let num_bytes ba = bytelength ba.bitlength
 (********************************************************************)

 let rmasks =
-  Array.init width ~f:(fun i -> 0xFF lsl (width - i))
+  ArrayLabels.init width ~f:(fun i -> 0xFF lsl (width - i))

 (* Later, extend to have optional initial-position arguments *)
 let blit ~src ~dst ~len =
@@ -266,23 +267,23 @@ let blit ~src ~dst ~len =
   then raise (Invalid_argument "Bitstring.blit: src too short");
   let bytelen = len / width
   and bitlen = len mod width in
-  String.blit
+  BytesLabels.blit
     ~src:src.a ~src_pos:0
     ~dst:dst.a ~dst_pos:0 ~len:bytelen;
   if bitlen > 0 then
-    let srcval = int_of_char (String.get src.a bytelen)
-    and dstval = int_of_char (String.get dst.a bytelen) in
+    let srcval = int_of_char (BytesLabels.get src.a bytelen)
+    and dstval = int_of_char (BytesLabels.get dst.a bytelen) in
     let newdst = (rmasks.(bitlen) land srcval) lor
                  ((lnot rmasks.(bitlen)) land dstval)
     in
-    dst.a.[bytelen] <- char_of_int newdst
+    BytesLabels.set dst.a bytelen (char_of_int newdst)


 (* let full_blit ~src ~src_pos ~dst ~dst_pos ~len =  *)


 let zero_out bs =
-  String.fill bs.a ~pos:0 ~len:(String.length bs.a) '\000'
+  BytesLabels.fill bs.a ~pos:0 ~len:(BytesLabels.length bs.a) '\000'

 (*
 let extract bs ~pos ~len =
diff --git a/channel.ml b/channel.ml
index 95b599b..3c340d7 100644
--- channel.ml
+++ channel.ml
@@ -20,7 +20,7 @@
 (* USA or see <http://www.gnu.org/licenses/>.                          *)
 (***********************************************************************)

-open StdLabels
+open BytesLabels
 open MoreLabels
 open Common
 module Unix=UnixLabels
@@ -50,13 +50,13 @@ let create_nb_really_input inchan =
     let string =
       match !stringopt with
           None ->
-            let string = String.create len in
+            let string = BytesLabels.create len in
             stringopt := Some string;
             pos := 0;
             string
         | Some string -> string
     in
-    if String.length string <> len then
+    if BytesLabels.length string <> len then
       failwith ("create_nb_really_input: attempt to redo incomplete " ^
                 "read with different size");

@@ -125,7 +125,7 @@ let read_all cin ?len ()=
       None -> 1024 * 100
     | Some x -> x
   in
-  let sbuf = String.create len
+  let sbuf = BytesLabels.create len
   and buf = Buffer.create len in
     read_all_rec cin sbuf buf;
     Buffer.contents buf
@@ -167,7 +167,7 @@ object (self)
   method virtual read_string_pos : buf:string -> pos:int -> len:int -> unit
   method virtual read_char : char
   method read_string len =
-    let buf = String.create len in
+    let buf = BytesLabels.create len in
     self#read_string_pos ~buf ~pos:0 ~len;
     buf
   method read_byte = int_of_char self#read_char
@@ -217,7 +217,7 @@ object (self)
   method read_string len = input len
   method read_string_pos ~buf ~pos ~len =
     let s = input len in
-    String.blit ~src:s ~dst:buf ~src_pos:0 ~dst_pos:pos ~len
+    BytesLabels.blit ~src:s ~dst:buf ~src_pos:0 ~dst_pos:pos ~len

   method read_char =
     input_char cin
@@ -257,20 +257,20 @@ object (self)

   method read_string len =
     if pos + len > slength then raise End_of_file;
-    let rval = String.sub string ~pos ~len in
+    let rval = BytesLabels.sub string ~pos ~len in
       pos <- pos + len;
       rval

   method read_rest =
     if pos >= slength then ""
     else
-      let rval = String.sub string ~pos ~len:(slength - pos) in
+      let rval = BytesLabels.sub string ~pos ~len:(slength - pos) in
       pos <- slength;
       rval

   method read_string_pos ~buf ~pos:dst_pos ~len =
     if pos + len > slength then raise End_of_file;
-    String.blit ~src:string ~src_pos:pos
+    BytesLabels.blit ~src:string ~src_pos:pos
       ~dst:buf ~dst_pos ~len;
     pos <- pos + len

diff --git a/dbserver.ml b/dbserver.ml
index 583c484..6fbaedb 100644
--- dbserver.ml
+++ dbserver.ml
@@ -149,8 +149,8 @@ struct
     []

   let get_keys_by_keyid keyid =
-    let keyid_length = String.length keyid in
-    let short_keyid = String.sub ~pos:(keyid_length - 4) ~len:4 keyid in
+    let keyid_length = BytesLabels.length keyid in
+    let short_keyid = BytesLabels.sub ~pos:(keyid_length - 4) ~len:4 keyid in
     let keys = Keydb.get_by_short_subkeyid short_keyid in
     match keyid_length with
       | 4 -> (* 32-bit keyid.  No further filtering required. *)
@@ -396,7 +396,7 @@ struct
     let f = (if binary then open_in_bin else open_in) fname in
     protect ~f:(fun () ->
                   let length = in_channel_length f in
-                  let buf = String.create length in
+                  let buf = BytesLabels.create length in
                   really_input f buf 0 length;
                   buf
                )
diff --git a/heap.ml b/heap.ml
index 292f432..1cd5646 100644
--- heap.ml
+++ heap.ml
@@ -20,7 +20,7 @@
 (* USA or see <http://www.gnu.org/licenses/>.                          *)
 (***********************************************************************)

-open StdLabels
+open ArrayLabels
 open MoreLabels

 (* Adapted from CLR *)
@@ -57,7 +57,7 @@ let exchange heap i j =
 let resize heap =
   if heap.length > Array.length heap.a
   then heap.a <-
-    Array.init ((Array.length heap.a) * 2)
+    ArrayLabels.init ((Array.length heap.a) * 2)
     ~f:(fun i ->
           if i < (Array.length heap.a)
           then heap.a.(i)
@@ -67,7 +67,7 @@ let resize heap =
     if heap.length <= (Array.length heap.a)/3
       && (Array.length heap.a)/2 >= heap.minsize
     then heap.a <-
-      Array.init ((Array.length heap.a)/ 2) ~f:(fun i -> heap.a.(i))
+      ArrayLabels.init ((Array.length heap.a)/ 2) ~f:(fun i -> heap.a.(i))


 (***************************************************************)
@@ -146,7 +146,7 @@ let push heap ~key ~data =
 (***************************************************************)

 let empty cmp i =
-  { a = Array.create i None;
+  { a = Array.make i None;
     length = 0;
     minsize = i;
     cmp = cmp;
diff --git a/keyHash.ml b/keyHash.ml
index ca7c6d6..0a85b6d 100644
--- keyHash.ml
+++ keyHash.ml
@@ -72,12 +72,12 @@ let hexchar_to_int c =
   )

 let dehexify s =
-  let s = String.uppercase s in
-  let ns = String.create (String.length s / 2) in (* new string *)
-  for i = 0 to String.length ns - 1 do
+  let s = BytesLabels.uppercase s in
+  let ns = BytesLabels.create (BytesLabels.length s / 2) in (* new string *)
+  for i = 0 to BytesLabels.length ns - 1 do
     let first = hexchar_to_int s.[2 * i]
     and second = hexchar_to_int s.[2 * i + 1]
     in
-    ns.[i] <- char_of_int ((first lsl 4) + second)
+    BytesLabels.set ns i (char_of_int ((first lsl 4) + second))
   done;
   ns
diff --git a/linearAlg.ml b/linearAlg.ml
index 81a9d88..a4aba71 100644
--- linearAlg.ml
+++ linearAlg.ml
@@ -20,9 +20,9 @@
 (* USA or see <http://www.gnu.org/licenses/>.                          *)
 (***********************************************************************)

-open StdLabels
 open MoreLabels
 module Unix=UnixLabels
+module Array=ArrayLabels
 open Printf
 open ZZp.Infix

@@ -62,7 +62,7 @@ struct
   let copy m = { m with array = Array.copy m.array; }

   let make ~columns ~rows init =
-    let array = Array.create (columns * rows) init in
+    let array = Array.make (columns * rows) init in
     { columns = columns;
       rows = rows;
       array = array;
diff --git a/mList.ml b/mList.ml
index f473a64..c0d4c79 100644
--- mList.ml
+++ mList.ml
@@ -200,7 +200,7 @@ let pri_split pri list =
   (low,exact,high)

 let has_dups list =
-  let slist = Sort.list (fun x y -> x < y) list in
+  let slist = List.sort compare list in
   let rec dup_scan list = match list with
     [] -> false
   | hd::[] -> false
@@ -208,7 +208,7 @@ let has_dups list =
   in dup_scan slist

 let dedup list =
-  let slist = Sort.list (fun x y -> x < y) list in
+  let slist = List.sort compare list in
   let rec dedup ~list ~partial = match list with
       [] -> partial
     | hd::[] -> dedup ~list:[] ~partial:(hd::partial)
diff --git a/number.ml b/number.ml
index 3e33077..fc9d5ba 100644
--- number.ml
+++ number.ml
@@ -22,7 +22,7 @@
 (***********************************************************************)

 open Big_int
-open StdLabels
+open BytesLabels
 open MoreLabels
 open Printf
 open Common
@@ -59,31 +59,31 @@ let width = 8
 let width_pow = power_int_positive_int 2 width

 let revstring s =
-  let len = String.length s in
-  let copy = String.create len in
+  let len = BytesLabels.length s in
+  let copy = BytesLabels.create len in
   for i = 0 to len - 1 do
-    copy.[i] <- s.[len - 1 - i]
+    BytesLabels.set copy i s.[len - 1 - i]
   done;
   copy

 let revstring_inplace s =
-  let len = String.length s in
+  let len = BytesLabels.length s in
   for i = 0 to (len - 2)/2 do
     let j = len - 1 - i in
     let tmp = s.[i] in
-    s.[i] <- s.[j];
-    s.[j] <- tmp
+    BytesLabels.set s i s.[j];
+    BytesLabels.set s j tmp
   done

 let to_bytes ~nbytes n =
   if sign_big_int n = -1
   then raise (Invalid_argument "N.to_bytes: negative argument");
-  let string = String.create nbytes in
+  let string = BytesLabels.create nbytes in
   let rec loop n i =
     if i < 0 then string
     else
       let (a,b) = quomod_big_int n width_pow in
-      string.[i] <- char_of_int (int_of_big_int b);
+      BytesLabels.set string i (char_of_int (int_of_big_int b));
       loop a (i - 1)
   in
   let str = loop n (nbytes - 1) in
@@ -92,7 +92,7 @@ let to_bytes ~nbytes n =

 let of_bytes str =
   let str = revstring str in
-  let nbytes = String.length str in
+  let nbytes = BytesLabels.length str in
   let rec loop n i =
     if i >= nbytes then n
     else
diff --git a/prefixTree.ml b/prefixTree.ml
index 4aa4fbb..6721c28 100644
--- prefixTree.ml
+++ prefixTree.ml
@@ -20,11 +20,13 @@
 (* USA or see <http://www.gnu.org/licenses/>.                          *)
 (***********************************************************************)

-open StdLabels
+open BytesLabels
 open MoreLabels
 open Printf
 open Common
 module Unix=UnixLabels
+module Array=ArrayLabels
+module List=ListLabels
 (*module ZZp = RMisc.ZZp *)
 module Set = PSet.Set
 module ZSet = ZZp.Set
@@ -161,7 +163,7 @@ let unmarshal_of_string ~f s =

 let samesize set =
   let sizes = Set.fold ~init:Set.empty set
-                ~f:(fun string set -> Set.add (String.length string) set)
+                ~f:(fun string set -> Set.add (BytesLabels.length string) set)
   in
   let nsizes = Set.cardinal sizes in
   nsizes = 1 || nsizes = 0
@@ -728,11 +730,11 @@ let split_at_depth t zz zzs node depth =
 (******************************************************************)

 let pad string bytes =
-  let len = String.length string in
+  let len = BytesLabels.length string in
   if bytes > len then
-    let nstr = String.create bytes in
-    String.fill nstr ~pos:len ~len:(bytes - len) '\000';
-    String.blit ~src:string ~dst:nstr ~src_pos:0 ~dst_pos:0 ~len;
+    let nstr = BytesLabels.create bytes in
+    BytesLabels.fill nstr ~pos:len ~len:(bytes - len) '\000';
+    BytesLabels.blit ~src:string ~dst:nstr ~src_pos:0 ~dst_pos:0 ~len;
     nstr
   else
     string
@@ -819,11 +821,11 @@ let rec insert_at_depth t zz zzs node marray depth =

 let insert_both t txn zz zzs =
   let zzs = pad zzs (ZZp.num_bytes ()) in
-  if String.length zzs <> ZZp.num_bytes ()
+  if BytesLabels.length zzs <> ZZp.num_bytes ()
   then raise (Invalid_argument
                 (sprintf "%s.  %d found, %d expected"
                    "PrefixTree.insert_both: zzs has wrong length"
-                   (String.length zzs) (ZZp.num_bytes ())
+                   (BytesLabels.length zzs) (ZZp.num_bytes ())
                 ));
   let marray = ZZp.add_el_array ~points:t.points zz in
   let root = t.root in
@@ -875,7 +877,7 @@ let rec delete_at_depth t txn zz zzs node marray depth =

 let delete_both t txn zz zzs =
   let zzs = pad zzs (ZZp.num_bytes ()) in
-  if String.length zzs <> ZZp.num_bytes ()
+  if BytesLabels.length zzs <> ZZp.num_bytes ()
   then raise (Invalid_argument
                 "PrefixTree.delete_both: zzs has wrong length");
   let marray = ZZp.del_el_array ~points:t.points zz in
diff --git a/rMisc.ml b/rMisc.ml
index 63792c1..e8278fc 100644
--- rMisc.ml
+++ rMisc.ml
@@ -22,9 +22,10 @@
 (* USA or see <http://www.gnu.org/licenses/>.                          *)
 (***********************************************************************)

-open StdLabels
+open BytesLabels
 open MoreLabels
 module Unix=UnixLabels
+module List=ListLabels

 (** deterministic RNG *)
 let det_rng = Random.State.make [|104|]
@@ -56,15 +57,15 @@ let rec fill_random_string rfunc string ~pos ~len =
     (* CR yminsky: I think this has the same bug as the function with the same name in Utils *)
     let _bits = rfunc () in
       for i = 0 to steps - 1 do
-        string.[pos + i] <-
-        char_of_int (0xFF land ((rfunc ()) lsr (8 * i)))
+        BytesLabels.set string (pos + i) (
+        char_of_int (0xFF land ((rfunc ()) lsr (8 * i))))
       done;
       fill_random_string rfunc string ~pos:(pos + steps) ~len
   else
     ()

 let random_string rfunc len =
-  let string = String.create len in
+  let string = BytesLabels.create len in
     fill_random_string rfunc string ~pos:0 ~len;
     string

@@ -114,19 +115,15 @@ let print_string_set set =
   List.iter ~f:(fun string -> print_string string; print_newline ())
 *)

-let add_sarray ~data sarray =
-  Array.fold_right ~f:(fun string set -> Set.add string set)
-    sarray ~init:data
-
 (*****************************************************************)
 (*****************************************************************)

 let pad string bytes =
-  let len = String.length string in
+  let len = BytesLabels.length string in
   if bytes > len then
-    let nstr = String.create bytes in
-    String.fill nstr ~pos:len ~len:(bytes - len) '\000';
-    String.blit ~src:string ~dst:nstr ~src_pos:0 ~dst_pos:0 ~len;
+    let nstr = BytesLabels.create bytes in
+    BytesLabels.fill nstr ~pos:len ~len:(bytes - len) '\000';
+    BytesLabels.blit ~src:string ~dst:nstr ~src_pos:0 ~dst_pos:0 ~len;
     nstr
   else
     string
@@ -137,10 +134,10 @@ let padset stringset bytes =
     ~init:Set.empty stringset

 let truncate string bytes =
-  let len = String.length string in
+  let len = BytesLabels.length string in
   if bytes < len then
-    let nstr = String.create bytes in
-    String.blit ~src:string ~dst:nstr ~src_pos:0 ~dst_pos:0 ~len:bytes;
+    let nstr = BytesLabels.create bytes in
+    BytesLabels.blit ~src:string ~dst:nstr ~src_pos:0 ~dst_pos:0 ~len:bytes;
     nstr
   else
     string
@@ -157,14 +154,6 @@ let truncset stringset bytes =

 let order_string = "530512889551602322505127520352579437339"

-(** Printing Functions *)
-
-let print_ZZp_list list =
-  let list = Sort.list (fun x y -> compare x y < 0) list in
-  MList.print2 ~f:ZZp.print list
-
-let print_ZZp_set set = print_ZZp_list (Set.elements set)
-

 (*************  Initialization code ****************************)

diff --git a/rMisc.mli b/rMisc.mli
index cc7b6e1..6ddddad 100644
--- rMisc.mli
+++ rMisc.mli
@@ -15,11 +15,8 @@ val det_string_set : bytes:int -> size:int -> string PSet.Set.t
 val rand_string_set : bytes:int -> size:int -> string PSet.Set.t
 val localize_string_set :
   bytes:int -> diff:int -> string PSet.Set.t -> string PSet.Set.t
-val add_sarray : data:'a PSet.Set.t -> 'a array -> 'a PSet.Set.t
 val pad : string -> int -> string
 val padset : string PSet.Set.t -> int -> string PSet.Set.t
 val truncate : string -> int -> string
 val truncset : string PSet.Set.t -> int -> string PSet.Set.t
 val order_string : string
-val print_ZZp_list : ZZp.zz list -> unit
-val print_ZZp_set : ZZp.zz PSet.Set.t -> unit
diff --git a/utils.ml b/utils.ml
index b9b4347..38a642c 100644
--- utils.ml
+++ utils.ml
@@ -20,11 +20,12 @@
 (* USA or see <http://www.gnu.org/licenses/>.                          *)
 (***********************************************************************)

-open StdLabels
+open BytesLabels
 open MoreLabels
 module Unix=UnixLabels
 module Set = PSet.Set
 module Map = PMap.Map
+module List = StdLabels.List

 open Printf

@@ -104,8 +105,8 @@ let is_alnum char =


 let rec extract_words_rec s ~start ~len partial =
-  let one () = Set.add (String.lowercase (String.sub s start len)) partial in
-  if start + len = String.length s
+  let one () = Set.add (BytesLabels.lowercase (BytesLabels.sub s start len)) partial in
+  if start + len = BytesLabels.length s
   then ( if len = 0 then partial
          else one ())
   else (
@@ -173,12 +174,12 @@ let random_int low high =
 let char_width = 8

 let hexstring digest =
-  let result = String.create (String.length digest * 2) in
+  let result = BytesLabels.create (BytesLabels.length digest * 2) in
   let hex = "0123456789ABCDEF" in
-    for i = 0 to String.length digest - 1 do
+    for i = 0 to BytesLabels.length digest - 1 do
       let c = Char.code digest.[i] in
-        result.[2*i] <- hex.[c lsr 4];
-        result.[2*i+1] <- hex.[c land 0xF]
+        set result (2*i) hex.[c lsr 4];
+        set result (2*i+1) hex.[c land 0xF]
     done;
     result

@@ -192,11 +193,11 @@ let int_from_bstring string ~pos ~len =
   int_from_bstring_rec string ~pos ~len 0

 let bstring_of_int i =
-     let s = String.create 4 in
-     s.[3] <- char_of_int (i land 0xFF);
-     s.[2] <- char_of_int ((i lsr 8) land 0xFF);
-     s.[1] <- char_of_int ((i lsr 16) land 0xFF);
-     s.[0] <- char_of_int ((i lsr 24) land 0xFF);
+     let s = BytesLabels.create 4 in
+     set s 3 (char_of_int (i land 0xFF));
+     set s 2 (char_of_int ((i lsr 8) land 0xFF));
+     set s 1 (char_of_int ((i lsr 16) land 0xFF));
+     set s 0 (char_of_int ((i lsr 24) land 0xFF));
      s

 (* tail recursive *)
@@ -220,12 +221,6 @@ let create_rand_bits () =

 let rbit = create_rand_bits ()

-(* FIX: this depends on the interals of the sort mechanism.
-   A rather cheap trick, really. It does work at present, though *)
-let permute list =
-  let cmp i j = (rbit ()) * 2 - 1 in
-    List.sort ~cmp list
-
 (* Exception Handling *)

 exception FinalDouble of exn * exn
@@ -265,15 +260,16 @@ let rec fill_random_string rfunc string ~pos ~len =
        the random generation being deterministic *)
     let _bits = rfunc () in
     for i = 0 to steps - 1 do
-      string.[pos + i] <-
+      set string (pos + i) (
         char_of_int (0xFF land ((rfunc ()) lsr (8 * i)))
+      )
     done;
     fill_random_string rfunc string ~pos:(pos + steps) ~len
   else
     ()

 let random_string rfunc len =
-  let string = String.create len in
+  let string = BytesLabels.create len in
     fill_random_string rfunc string ~pos:0 ~len;
     string

diff --git a/utils.mli b/utils.mli
index bcc6aed..3924541 100644
--- utils.mli
+++ utils.mli
@@ -24,7 +24,6 @@ val apply : int -> ('a -> 'a) -> 'a -> 'a
 val get_bit : pos:int -> int -> int
 val create_rand_bits : unit -> unit -> int
 val rbit : unit -> int
-val permute : 'a list -> 'a list
 exception FinalDouble of exn * exn
 exception Final of exn
 val try_finally : f:(unit -> 'a) -> finally:(unit -> 'b) -> 'a
diff --git a/wserver.ml b/wserver.ml
index 6ccfc62..e04a201 100644
--- wserver.ml
+++ wserver.ml
@@ -53,49 +53,49 @@ let hexa_val conf =

 let decode s =
   let rec need_decode i =
-    if i < String.length s then
+    if i < BytesLabels.length s then
       match s.[i] with
         '%' | '+' -> true
       | _ -> need_decode (succ i)
     else false
   in
   let rec compute_len i i1 =
-    if i < String.length s then
+    if i < BytesLabels.length s then
       let i =
         match s.[i] with
-          '%' when i + 2 < String.length s -> i + 3
+          '%' when i + 2 < BytesLabels.length s -> i + 3
         | _ -> succ i
       in
       compute_len i (succ i1)
     else i1
   in
   let rec copy_decode_in s1 i i1 =
-    if i < String.length s then
+    if i < BytesLabels.length s then
       let i =
         match s.[i] with
-          '%' when i + 2 < String.length s ->
+          '%' when i + 2 < BytesLabels.length s ->
             let v = hexa_val s.[i + 1] * 16 + hexa_val s.[i + 2] in
-            s1.[i1] <- Char.chr v; i + 3
-        | '+' -> s1.[i1] <- ' '; succ i
-        | x -> s1.[i1] <- x; succ i
+            BytesLabels.set s1 i1 (Char.chr v); i + 3
+        | '+' -> BytesLabels.set s1 i1 ' '; succ i
+        | x -> BytesLabels.set s1 i1 x; succ i
       in
       copy_decode_in s1 i (succ i1)
     else s1
   in
   let rec strip_heading_and_trailing_spaces s =
-    if String.length s > 0 then
+    if BytesLabels.length s > 0 then
       if s.[0] == ' ' then
         strip_heading_and_trailing_spaces
-          (String.sub s 1 (String.length s - 1))
-      else if s.[String.length s - 1] == ' ' then
+          (BytesLabels.sub s 1 (BytesLabels.length s - 1))
+      else if s.[BytesLabels.length s - 1] == ' ' then
         strip_heading_and_trailing_spaces
-          (String.sub s 0 (String.length s - 1))
+          (BytesLabels.sub s 0 (BytesLabels.length s - 1))
       else s
     else s
   in
   if need_decode 0 then
     let len = compute_len 0 0 in
-    let s1 = String.create len in
+    let s1 = BytesLabels.create len in
     strip_heading_and_trailing_spaces (copy_decode_in s1 0 0)
   else s

@@ -104,54 +104,54 @@ let special x = List.mem x ['='; '&'; '"'; '\r'; '\n'; '+']

 let encode s =
   let rec need_code i =
-    if i < String.length s then
+    if i < BytesLabels.length s then
       match s.[i] with
         ' ' -> true
       | x -> if special x then true else need_code (succ i)
     else false
   in
   let rec compute_len i i1 =
-    if i < String.length s then
+    if i < BytesLabels.length s then
       let i1 = if special s.[i] then i1 + 3 else succ i1 in
       compute_len (succ i) i1
     else i1
   in
   let rec copy_code_in s1 i i1 =
-    if i < String.length s then
+    if i < BytesLabels.length s then
       let i1 =
         match s.[i] with
-          ' ' -> s1.[i1] <- '+'; succ i1
+          ' ' -> BytesLabels.set s1 i1 '+'; succ i1
         | c ->
             if special c then
               begin
-                s1.[i1] <- '%';
-                s1.[i1 + 1] <- hexa_digit (Char.code c / 16);
-                s1.[i1 + 2] <- hexa_digit (Char.code c mod 16);
+                BytesLabels.set s1 i1 '%';
+                BytesLabels.set s1 (i1 + 1) (hexa_digit (Char.code c / 16));
+                BytesLabels.set s1 (i1 + 2) (hexa_digit (Char.code c mod 16));
                 i1 + 3
               end
-            else begin s1.[i1] <- c; succ i1 end
+            else begin BytesLabels.set s1 i1 c; succ i1 end
       in
       copy_code_in s1 (succ i) i1
     else s1
   in
   if need_code 0 then
-    let len = compute_len 0 0 in copy_code_in (String.create len) 0 0
+    let len = compute_len 0 0 in copy_code_in (BytesLabels.create len) 0 0
   else s

 let stripchars = Set.of_list [ ' '; '\t'; '\n'; '\r' ]

 let strip s =
   let start = ref 0 in
-  while (!start < String.length s
+  while (!start < BytesLabels.length s
          && Set.mem s.[!start] stripchars) do
     incr start
   done;
-  let stop = ref (String.length s - 1) in
+  let stop = ref (BytesLabels.length s - 1) in
   while (!stop >= 0 && Set.mem s.[!stop] stripchars) do
     decr stop
   done;
   if !stop >= !start then
-    String.sub s ~pos:!start ~len:(!stop - !start + 1)
+    BytesLabels.sub s ~pos:!start ~len:(!stop - !start + 1)
   else
     ""

@@ -180,7 +180,7 @@ let parse_post headers cin =
     if len > max_post_length
     then raise (Entity_too_large (sprintf "POST data too long: %f megs"
                               (float len /. 1024. /. 1024.)));
-    let rest = String.create len in
+    let rest = BytesLabels.create len in
     really_input cin rest 0 len;
     rest
   with
@@ -188,20 +188,20 @@ let parse_post headers cin =
         failwith "parse_post failed for lack of a content-length header"

 let is_blank line =
-  String.length line = 0 || line.[0] = '\r'
+  BytesLabels.length line = 0 || line.[0] = '\r'

 let rec parse_headers map cin =
   let line = input_line cin in (* DoS attack: input_line is unsafe on sockets *)
   if is_blank line then map
   else
-    let colonpos = try String.index line ':' with
+    let colonpos = try BytesLabels.index line ':' with
         Not_found -> failwith "Error parsing headers: no colon found"
     in
-    let key = String.sub line ~pos:0 ~len:colonpos
-    and data = String.sub line ~pos:(colonpos + 1)
-                 ~len:(String.length line - colonpos - 1)
+    let key = BytesLabels.sub line ~pos:0 ~len:colonpos
+    and data = BytesLabels.sub line ~pos:(colonpos + 1)
+                 ~len:(BytesLabels.length line - colonpos - 1)
     in
-    parse_headers (map |< (String.lowercase key, strip data)) cin
+    parse_headers (map |< (BytesLabels.lowercase key, strip data)) cin

 let parse_request cin =
   let line = input_line cin in (* DoS attack: input_line is unsafe on sockets *)
@@ -217,7 +217,7 @@ let headers_to_string map =
   let pieces = List.map ~f:(fun (x,y) -> sprintf "%s:%s" x y)
                  (Map.to_alist map)
   in
-  "\n" ^ (String.concat "\n" pieces)
+  "\n" ^ (BytesLabels.concat "\n" pieces)

 let request_to_string request =
   let (kind,req,headers) =
@@ -296,7 +296,7 @@ let send_result cout ?(error_code = 200) ?(content_type = "text/html; charset=UT
   fprintf cout "Cache-Control: no-cache\r\n";
   fprintf cout "Pragma: no-cache\r\n";
   fprintf cout "Expires: 0\r\n";
-  fprintf cout "Content-length: %u\r\n" (String.length body + 2);
+  fprintf cout "Content-length: %u\r\n" (BytesLabels.length body + 2);
   if count >= 0 then
     fprintf cout "X-HKP-Results-Count: %d\r\n" count;
   fprintf cout "Content-type: %s\r\n" content_type;