Wed Mar 14 08:58:43 2018 UTC ()
Fix build with ocaml 4.06.


(dholland)
diff -r1.4 -r1.5 pkgsrc/www/swiftsurf/distinfo
diff -r0 -r1.1 pkgsrc/www/swiftsurf/patches/patch-request.ml
diff -r0 -r1.1 pkgsrc/www/swiftsurf/patches/patch-src_activebuffer.ml
diff -r0 -r1.1 pkgsrc/www/swiftsurf/patches/patch-src_activebuffer.mli
diff -r0 -r1.1 pkgsrc/www/swiftsurf/patches/patch-src_answer.ml
diff -r0 -r1.1 pkgsrc/www/swiftsurf/patches/patch-src_dns.ml
diff -r0 -r1.1 pkgsrc/www/swiftsurf/patches/patch-src_utils.ml

cvs diff -r1.4 -r1.5 pkgsrc/www/swiftsurf/distinfo (expand / switch to unified diff)

--- pkgsrc/www/swiftsurf/distinfo 2015/11/04 02:47:39 1.4
+++ pkgsrc/www/swiftsurf/distinfo 2018/03/14 08:58:43 1.5
@@ -1,8 +1,14 @@ @@ -1,8 +1,14 @@
1$NetBSD: distinfo,v 1.4 2015/11/04 02:47:39 agc Exp $ 1$NetBSD: distinfo,v 1.5 2018/03/14 08:58:43 dholland Exp $
2 2
3SHA1 (swiftsurf-1.2.5.tar.gz) = bf58a2afcbb8d9ee4cbeb9b8a6ebe00ab6f3d9c8 3SHA1 (swiftsurf-1.2.5.tar.gz) = bf58a2afcbb8d9ee4cbeb9b8a6ebe00ab6f3d9c8
4RMD160 (swiftsurf-1.2.5.tar.gz) = 243c9c05352e83b5f7b64a8398ea1373e7f8dc59 4RMD160 (swiftsurf-1.2.5.tar.gz) = 243c9c05352e83b5f7b64a8398ea1373e7f8dc59
5SHA512 (swiftsurf-1.2.5.tar.gz) = 3e6edc84624a134e5e4ada149e9d6a5444c9e1a57fa3b8b5dfde179c13c58e4bfdcfd4c00a2d563446e56804f3e00f9f373320710544a89e868304d95715ab04 5SHA512 (swiftsurf-1.2.5.tar.gz) = 3e6edc84624a134e5e4ada149e9d6a5444c9e1a57fa3b8b5dfde179c13c58e4bfdcfd4c00a2d563446e56804f3e00f9f373320710544a89e868304d95715ab04
6Size (swiftsurf-1.2.5.tar.gz) = 31950 bytes 6Size (swiftsurf-1.2.5.tar.gz) = 31950 bytes
7SHA1 (patch-aa) = 7882d5c8542e8ebab40100462ecfaaf3f282f5a2 7SHA1 (patch-aa) = 7882d5c8542e8ebab40100462ecfaaf3f282f5a2
 8SHA1 (patch-request.ml) = 3d5e97a15be8b197682001fc3a694cb94a896fe9
8SHA1 (patch-src_Makefile) = e4dad6b60ca5da10b27a9d90b868b3c0f2845cec 9SHA1 (patch-src_Makefile) = e4dad6b60ca5da10b27a9d90b868b3c0f2845cec
 10SHA1 (patch-src_activebuffer.ml) = 9d36c013f177161f34b178ee6e2bd82c7064d395
 11SHA1 (patch-src_activebuffer.mli) = fb7ff84dc8ac5a5550dce06470faf7ba6ce00f68
 12SHA1 (patch-src_answer.ml) = 6deec06a5d460dd3794e281660534980c38434a5
 13SHA1 (patch-src_dns.ml) = 3e5b277329a0be090c45b571e0096a39ea6957d8
 14SHA1 (patch-src_utils.ml) = 8d590c70402e48ebc51b82860d60e510a1aa12ad

File Added: pkgsrc/www/swiftsurf/patches/patch-request.ml
$NetBSD: patch-request.ml,v 1.1 2018/03/14 08:58:43 dholland Exp $

Fix build with ocaml 4.06.

--- src/request.ml~	2002-03-04 11:46:08.000000000 +0000
+++ src/request.ml
@@ -68,7 +68,7 @@ let goto_content conn =
   try
     conn.prof <- Conf.get_profile conn.auth;
     if conn.prof.req_in then
-      (print_string (String.sub conn.read_req.buffer 0
+      (print_bytes (Bytes.sub conn.read_req.buffer 0
                        conn.read_req.pos_fin);
        flush stdout);
     if conn.prof.req_1 then
@@ -101,12 +101,12 @@ let verif_auth conn deb len =
     let rec aux i =
       if i == len2
       then true
-      else str.[i] == (Char.lowercase conn.read_req.buffer.[deb+i])
+      else str.[i] == (Char.lowercase_ascii (Bytes.get conn.read_req.buffer (deb+i)))
           && aux (i+1) in
     if aux 0
     then
-      (conn.auth <- decode64 (String.sub conn.read_req.buffer
-                                (deb+len2+6) (len-len2-8));
+      (conn.auth <- decode64 (Bytes.to_string (Bytes.sub conn.read_req.buffer
+                                (deb+len2+6) (len-len2-8)));
        false)
     else true
   with _ -> false
@@ -203,7 +203,7 @@ let rec compute_read conn =
   | CMD_LINE ->
       (try
         let pos = index conn.read_req '\n' in
-        let cmd = String.sub conn.read_req.buffer 0 (pos+1) in
+        let cmd = Bytes.to_string (Bytes.sub conn.read_req.buffer 0 (pos+1)) in
         conn.read_req.pos_deb <- pos+1;
         gere_cmdline cmd conn;
         match conn.state_req with
@@ -237,8 +237,8 @@ let rec compute_read conn =
       (try
         let pos = index conn.read_req '\n' in
         let len = pos + 1 - conn.read_req.pos_deb in
-        let header = String.sub conn.read_req.buffer
-            conn.read_req.pos_deb len in
+        let header = Bytes.to_string (Bytes.sub conn.read_req.buffer
+            conn.read_req.pos_deb len) in
         let deb = conn.read_req.pos_deb in
         conn.read_req.pos_deb <- pos+1;
         if len <= 2 then
@@ -393,7 +393,7 @@ let gere_conns time active_read active_w
       let nb = Unix.write conn.server str pos len in
       if nb > 0 then
         (if conn.prof.req_out then
-           print_string (String.sub str pos nb);
+           print_bytes (Bytes.sub str pos nb);
          sub conn.write_req nb (len - nb);
          conn.size_req <- min (conn.size_req + nb) buf_size;
          conn.timeout <- time +. !Types.timeout);
@@ -419,7 +419,7 @@ let gere_conns time active_read active_w
           false
       | nb ->
           if conn.prof.req_in then
-            print_string (String.sub str pos nb);
+            print_bytes (Bytes.sub str pos nb);
           after_read conn.read_req nb;
           conn.timeout <- time +. !Types.timeout;
           conn.size_req <- conn.size_req - nb;

File Added: pkgsrc/www/swiftsurf/patches/patch-src_activebuffer.ml
$NetBSD: patch-src_activebuffer.ml,v 1.1 2018/03/14 08:58:43 dholland Exp $

Fix build with ocaml 4.06.

--- src/activebuffer.ml~	2002-01-02 17:14:42.000000000 +0000
+++ src/activebuffer.ml
@@ -1,7 +1,7 @@
 (* Active buffers : can grow and reduce *)
 
 type t = {
-    mutable buffer : string;
+    mutable buffer : bytes;
     mutable pos_deb : int;
     mutable pos_fin : int;
     mutable size : int
@@ -14,15 +14,15 @@ let create n =
    else if n > Sys.max_string_length 
    then Sys.max_string_length 
    else n in
- let s = String.create n in
+ let s = Bytes.create n in
  { buffer = s; pos_deb = 0; pos_fin = 0; size = n }
 
 let activebuffer_of_string str =
   let n = String.length str in
-  { buffer = str; pos_deb = 0; pos_fin = n; size = n }
+  { buffer = (Bytes.of_string str); pos_deb = 0; pos_fin = n; size = n }
 
 let contents b =
-  String.sub b.buffer b.pos_deb (b.pos_fin - b.pos_deb)
+  Bytes.to_string (Bytes.sub b.buffer b.pos_deb (b.pos_fin - b.pos_deb))
 
 let length b = b.pos_fin - b.pos_deb
 
@@ -34,19 +34,19 @@ let resize b more =
   let len = b.pos_fin - b.pos_deb in
   if len + more <= b.size
   then (* no need to resize *)
-    String.blit b.buffer b.pos_deb b.buffer 0 len
+    Bytes.blit b.buffer b.pos_deb b.buffer 0 len
   else
     (let new_len = ref b.size in
      while len + more > !new_len do new_len := 2 * !new_len done;
-     let new_buffer = String.create !new_len in
-     String.blit b.buffer b.pos_deb new_buffer 0 len;
+     let new_buffer = Bytes.create !new_len in
+     Bytes.blit b.buffer b.pos_deb new_buffer 0 len;
      b.buffer <- new_buffer;
      b.size <- !new_len);
   b.pos_deb <- 0; b.pos_fin <- len
       
 let add_char b c =
   if b.pos_fin >= b.size then resize b 1;
-  b.buffer.[b.pos_fin] <- c;
+  Bytes.set b.buffer b.pos_fin c;
   b.pos_fin <- b.pos_fin + 1
 
 let add_substring b s offset len =
@@ -56,14 +56,27 @@ let add_substring b s offset len =
   String.blit s offset b.buffer b.pos_fin len;
   b.pos_fin <- b.pos_fin + len
 
+let add_subbytes b s offset len =
+  if offset < 0 || len < 0 || offset + len > Bytes.length s
+  then invalid_arg "Buffer.add_subbytes";
+  if b.pos_fin + len > b.size then resize b len;
+  Bytes.blit s offset b.buffer b.pos_fin len;
+  b.pos_fin <- b.pos_fin + len
+
 let add_string b s =
   let len = String.length s in
   if b.pos_fin + len > b.size then resize b len;
   String.blit s 0 b.buffer b.pos_fin len;
   b.pos_fin <- b.pos_fin + len
   
+let add_bytes b s =
+  let len = Bytes.length s in
+  if b.pos_fin + len > b.size then resize b len;
+  Bytes.blit s 0 b.buffer b.pos_fin len;
+  b.pos_fin <- b.pos_fin + len
+  
 let add_buffer b bs =
-  add_substring b bs.buffer bs.pos_deb (bs.pos_fin - bs.pos_deb)
+  add_subbytes b bs.buffer bs.pos_deb (bs.pos_fin - bs.pos_deb)
 
 let add_channel b ic len =
   if b.pos_fin + len > b.size then resize b len;
@@ -75,7 +88,7 @@ let output_buffer oc b =
 
 (* the follwing functions do not exist in the original buffer module *)
 let add_subbuffer b bs offset len =
-  add_substring b bs.buffer (bs.pos_deb + offset) len
+  add_subbytes b bs.buffer (bs.pos_deb + offset) len
 
 let sub b offset len =
   if offset < 0 || len < 0 || offset + len > b.pos_fin - b.pos_deb
@@ -96,7 +109,7 @@ let after_read b len =
 
 let rec index_rec s lim i c =
   if i >= lim then raise Not_found else
-  if String.unsafe_get s i = c then i else index_rec s lim (i+1) c;;
+  if Bytes.unsafe_get s i = c then i else index_rec s lim (i+1) c;;
 
 let index b chr =
   index_rec b.buffer b.pos_fin b.pos_deb chr

File Added: pkgsrc/www/swiftsurf/patches/patch-src_activebuffer.mli
$NetBSD: patch-src_activebuffer.mli,v 1.1 2018/03/14 08:58:43 dholland Exp $

Fix build with ocaml 4.06.

--- src/activebuffer.mli~	2002-01-02 17:14:42.000000000 +0000
+++ src/activebuffer.mli
@@ -1,5 +1,5 @@
 type t = {
-    mutable buffer : string;
+    mutable buffer : bytes;
     mutable pos_deb : int;
     mutable pos_fin : int;
     mutable size : int
@@ -22,6 +22,9 @@ val add_char : t -> char -> unit
 val add_string : t -> string -> unit
      (*d [add_string b s] appends the string [s] at the end of
         the buffer [b]. *)
+val add_bytes : t -> bytes -> unit
+     (*d [add_bytes b s] appends the bytes [s] at the end of
+        the buffer [b]. *)
 val add_substring : t -> string -> int -> int -> unit
      (*d [add_substring b s ofs len] takes [len] characters from offset
         [ofs] in string [s] and appends them at the end of the buffer [b]. *)
@@ -50,7 +53,7 @@ val sub : t -> int -> int -> unit
         starting at offset [pos] and of length [len]. This function
         does not copy nor create strings. Raise [Invalid_argument]
         if [pos] and [len] do not designate a valid sub_part of the buffer *)
-val buffer : t -> string*int
+val buffer : t -> bytes*int
     (*d [buffer b] gives the internal string used by the buffer and the
        starting active posistion. It can be used in conjunction with
        [sub] when doing [write] in order to avoid unnecessary copy.
@@ -58,7 +61,7 @@ val buffer : t -> string*int
         let str, pos = buffer b in
         let nb_written = write fds str pos len in
         sub b nb_written (len - nb_written)] *)
-val before_read : t -> int -> string*int
+val before_read : t -> int -> bytes*int
 val after_read : t -> int -> unit
     (*d [buffer b] gives the internal string used by the buffer and the
        starting active posistion. It can be used in conjunction with

File Added: pkgsrc/www/swiftsurf/patches/patch-src_answer.ml
$NetBSD: patch-src_answer.ml,v 1.1 2018/03/14 08:58:43 dholland Exp $

Fix build with ocaml 4.06.

--- src/answer.ml~	2002-02-25 18:27:15.000000000 +0000
+++ src/answer.ml
@@ -21,12 +21,12 @@ let rec compute_read conn =
   | CMD_LINE ->
       (try
         let pos = index conn.read_ans '\n' in
-        let cmd = String.sub conn.read_ans.buffer 0 (pos+1) in
+        let cmd = Bytes.sub conn.read_ans.buffer 0 (pos+1) in
         conn.read_ans.pos_deb <- pos+1;
-        Activebuffer.add_string conn.write_ans cmd;
+        Activebuffer.add_bytes conn.write_ans cmd;
         conn.state_ans <- HEADERS;
         if conn.prof.ans_1 then
-          (print_string cmd; flush stdout);
+          (print_bytes cmd; flush stdout);
         compute_read conn
       with Not_found ->
         (* the command line is not finished *)
@@ -34,20 +34,20 @@ let rec compute_read conn =
   | HEADERS ->
       (try
         let pos = index conn.read_ans '\n' in
-        let header = String.sub conn.read_ans.buffer
+        let header = Bytes.sub conn.read_ans.buffer
             conn.read_ans.pos_deb (pos+1-conn.read_ans.pos_deb) in
         conn.read_ans.pos_deb <- pos+1;
-        if String.length header <= 2 then
+        if Bytes.length header <= 2 then
           (* last line of headers *)
           (if conn.prof.ans_1 then
-            (print_string header; flush stdout);
+            (print_bytes header; flush stdout);
            conn.state_ans <- CONTENT;
-           Activebuffer.add_string conn.write_ans header)
+           Activebuffer.add_bytes conn.write_ans header)
         else
-          (if ok_ans_header header then
+          (if ok_ans_header (Bytes.to_string header) then
             (if conn.prof.ans_1 then
-              (print_string header; flush stdout);
-             Activebuffer.add_string conn.write_ans header));
+              (print_bytes header; flush stdout);
+             Activebuffer.add_bytes conn.write_ans header));
         compute_read conn
       with Not_found ->
         (* this line of headers is not finished *)
@@ -100,7 +100,7 @@ let gere_conns time active_read conns =
       let nb = Unix.write conn.client str pos len in
       if nb > 0 then
         (if conn.prof.ans_out then
-           print_string (String.sub str pos nb);
+           print_bytes (Bytes.sub str pos nb);
          sub conn.write_ans nb (len - nb);
          conn.size_ans <- min (conn.size_ans + nb) buf_size;
          conn.timeout <- time +. !Types.timeout)
@@ -134,7 +134,7 @@ let gere_conns time active_read conns =
           false
       | nb ->
           if conn.prof.ans_in then
-            print_string (String.sub str pos nb);
+            print_bytes (Bytes.sub str pos nb);
           after_read conn.read_ans nb;
           conn.timeout <- time +. !Types.timeout;
           conn.size_ans <- conn.size_ans - nb;

File Added: pkgsrc/www/swiftsurf/patches/patch-src_dns.ml
$NetBSD: patch-src_dns.ml,v 1.1 2018/03/14 08:58:43 dholland Exp $

Fix build with ocaml 4.06.

--- src/dns.ml~	2002-02-25 18:27:15.000000000 +0000
+++ src/dns.ml
@@ -59,7 +59,7 @@ let read_value fds =
   let header = really_read fds Marshal.header_size in
   let ds = Marshal.data_size header 0 in
   let data = really_read fds ds in
-  Marshal.from_string (header^data) 0
+  Marshal.from_string ((Bytes.to_string header) ^ (Bytes.to_string data)) 0
 
 (*************)
 (* dns cache *)

File Added: pkgsrc/www/swiftsurf/patches/patch-src_utils.ml
$NetBSD: patch-src_utils.ml,v 1.1 2018/03/14 08:58:43 dholland Exp $

Fix build with ocaml 4.06.

--- src/utils.ml~	2002-02-06 21:32:06.000000000 +0000
+++ src/utils.ml
@@ -55,7 +55,7 @@ let finish conn str =
 let read_file name =
   let chan = open_in_bin name in
   let buf_size = ref 1024 in
-  let buf = ref (String.create !buf_size) in
+  let buf = ref (Bytes.create !buf_size) in
   let nb_read = ref 0 in
   let cont = ref true in
   while !cont do
@@ -66,11 +66,11 @@ let read_file name =
       (nb_read := !nb_read + tmp;
        if !nb_read = !buf_size
        then
-         (buf := !buf ^ (String.create !buf_size);
+         (buf := Bytes.extend !buf 0 !buf_size;
           buf_size := 2 * !buf_size))
   done;
   close_in chan;
-  String.sub !buf 0 !nb_read
+  Bytes.to_string (Bytes.sub !buf 0 !nb_read)
 
 (* hack for using the parser *)
 let pars = ref (fun x -> assert false)
@@ -97,7 +97,7 @@ let match_pattern str pat =
         | '*' ->
             match_aux (pos_s+1) pos_p
         | '?' -> match_aux (pos_s+1) (pos_p+1)
-        | x -> x = (Char.lowercase str.[pos_s])
+        | x -> x = (Char.lowercase_ascii str.[pos_s])
               && match_aux (pos_s+1) (pos_p+1))))
   in
   match_aux 0 0
@@ -116,7 +116,7 @@ let decode64 s =
       | _ -> failwith "not a base64 string" in
     let len = String.length s in
     let len_res = len * 3 / 4 in
-    let res = String.create len_res in
+    let res = Bytes.create len_res in
     for i=0 to len/4 - 1 do
       let i1 = 4*i and i2 = 3*i in
       let v1 = (val64 s.[i1]) lsl 18 in
@@ -124,15 +124,15 @@ let decode64 s =
       let v3 = (val64 s.[i1 + 2]) lsl 6 in
       let v4 = val64 s.[i1 + 3] in
       let v = v1 lor v2 lor v3 lor v4 in
-      res.[i2] <- Char.chr (v lsr 16);
-      res.[i2 + 1] <- Char.chr (v lsr 8 land 0xFF);
-      res.[i2 + 2] <- Char.chr (v land 0xFF)
+      Bytes.set res i2  (Char.chr (v lsr 16));
+      Bytes.set res (i2 + 1) (Char.chr (v lsr 8 land 0xFF));
+      Bytes.set res (i2 + 2) (Char.chr (v land 0xFF))
     done;
     let nb_keep =
       if s.[len-1] = '=' then
         if s.[len-2] = '=' then len_res - 2 else len_res - 1
       else len_res in
-    String.sub res 0 nb_keep
+    Bytes.to_string (Bytes.sub res 0 nb_keep)
 
 (* encode passwd for authentication *)
 let encode64 s =
@@ -144,25 +144,25 @@ let encode64 s =
        '0'; '1'; '2'; '3'; '4'; '5'; '6'; '7'; '8'; '9'; '+'; '/' |] in
   let len = String.length s in
   let lenres = if len = 0 then 0 else ((len - 1) / 3 + 1) * 4 in
-  let res = String.make lenres '=' in
+  let res = Bytes.make lenres '=' in
   for i = 0 to len / 3 - 1 do
     let v = (Char.code (s.[3*i]) lsl 16) +
         (Char.code (s.[3*i+1]) lsl 8) + (Char.code (s.[3*i+2])) in
-    res.[4*i] <- b64.(v lsr 18);
-    res.[4*i+1] <- b64.((v lsr 12) mod 64);
-    res.[4*i+2] <- b64.((v lsr 6) mod 64);
-    res.[4*i+3] <- b64.(v mod 64)
+    Bytes.set res (4*i) (b64.(v lsr 18));
+    Bytes.set res (4*i+1) (b64.((v lsr 12) mod 64));
+    Bytes.set res (4*i+2) (b64.((v lsr 6) mod 64));
+    Bytes.set res (4*i+3) (b64.(v mod 64))
   done;
   (match len mod 3 with
   | 0 -> ()
   | 1 ->
       let v = Char.code s.[len-1] in
-      res.[lenres-4] <- b64.(v lsr 2);
-      res.[lenres-3] <- b64.((v mod 4) lsl 4)
+      Bytes.set res (lenres-4) (b64.(v lsr 2));
+      Bytes.set res (lenres-3) (b64.((v mod 4) lsl 4))
   | 2 ->
       let v = (Char.code (s.[len-2]) lsl 8) + (Char.code (s.[len-1])) in
-      res.[lenres-4] <- b64.(v lsr 10);
-      res.[lenres-3] <- b64.((v lsr 4) mod 64);
-      res.[lenres-2] <- b64.((v mod 16) lsl 2)
+      Bytes.set res (lenres-4) (b64.(v lsr 10));
+      Bytes.set res (lenres-3) (b64.((v lsr 4) mod 64));
+      Bytes.set res (lenres-2) (b64.((v mod 16) lsl 2))
   | _ -> assert false);
-  res
+  Bytes.to_string res