File: 0003-Fix-compilation-with-OCaml-4.08.0.patch

package info (click to toggle)
pagodacf 0.10-6
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,352 kB
  • sloc: ml: 8,458; ansic: 3,339; makefile: 141
file content (119 lines) | stat: -rw-r--r-- 3,964 bytes parent folder | download | duplicates (3)
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
From: Stephane Glondu <steph@glondu.net>
Date: Sat, 7 Sep 2019 20:32:49 +0200
Subject: Fix compilation with OCaml 4.08.0

---
 cf_message.ml  | 16 ++++++++--------
 cf_message.mli |  2 +-
 cf_seq.ml      |  2 +-
 cf_seq.mli     |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/cf_message.ml b/cf_message.ml
index faf8548..61f7711 100644
--- a/cf_message.ml
+++ b/cf_message.ml
@@ -30,10 +30,10 @@
   OF THE POSSIBILITY OF SUCH DAMAGE. 
  *---------------------------------------------------------------------------*)
 
-type substring = string * int * int and t = substring list
+type substring = bytes * int * int and t = substring list
 
 let sub_invariant_ (s, pos, len) =
-    let size = String.length s in
+    let size = Bytes.length s in
     pos >= 0 && pos < size && len > 0 && pos + len <= size
 
 let rec test_invariant_ = function
@@ -55,13 +55,13 @@ let rec sub_blit_loop_ ?(i = 0) dest =
         ()
     | (s, pos, len) :: tl ->
         assert (sub_invariant_ (dest, i, len));
-        String.blit s pos dest i len;
+        Bytes.blit s pos dest i len;
         let i = i + len in
         sub_blit_loop_ ~i dest tl
 
 let create s =
     let n = String.length s in
-    if n > 0 then [ s, 0, n ] else []
+    if n > 0 then [ Bytes.of_string s, 0, n ] else []
 
 let length =
     let f acc (_, _, len as sub) =
@@ -78,7 +78,7 @@ let contents =
         let n = length tl in
         let s = String.create n in
         sub_blit_loop_ s tl;
-        s
+        Bytes.to_string s
 
 let copy m = create (contents m)
 
@@ -191,7 +191,7 @@ let drain q = Cf_deque.B.to_list q
 
 let drain_seq ?x =
     let rec aux (buf, pos, len) =
-        Cf_seq.limit ?x len (Cf_seq.of_substring buf pos)
+        Cf_seq.limit ?x len (Cf_seq.of_substring (Bytes.to_string buf) pos)
     in
     fun q ->
         Cf_seq.flatten (Cf_seq.map aux (Cf_deque.B.to_seq q))
@@ -235,7 +235,7 @@ let rec unsafe_to_seq ?x m =
     lazy begin
         match m with
         | (buf, pos, _) :: _ as m ->
-            let hd = String.unsafe_get buf pos in
+            let hd = Bytes.unsafe_get buf pos in
             let tl = unsafe_to_seq ?x (unsafe_shift1 m) in
             Cf_seq.P (hd, tl)
         | [] ->
@@ -250,7 +250,7 @@ let unsafe_to_function ?x m =
             raise (match x with None -> End_of_file | Some x -> x)
         | (buf, pos, _) :: _ as m ->
             r := unsafe_shift1 m;
-            String.unsafe_get buf pos
+            Bytes.unsafe_get buf pos
     in
     loop
 
diff --git a/cf_message.mli b/cf_message.mli
index 681f5dd..b2623bc 100644
--- a/cf_message.mli
+++ b/cf_message.mli
@@ -46,7 +46,7 @@
 (** The type of messages, i.e. a list of substrings (a string, the position of
     the first character in the substring, and the length of the substring).
 *)
-type substring = string * int * int and t = substring list
+type substring = bytes * int * int and t = substring list
 
 (** {6 Functions} *)
 
diff --git a/cf_seq.ml b/cf_seq.ml
index 47188d6..c4b52a7 100644
--- a/cf_seq.ml
+++ b/cf_seq.ml
@@ -394,7 +394,7 @@ let to_substring =
     fun s str pos len ->
         if pos < 0 then
             invalid_arg "Cf_seq.to_substring: pos < 0";
-        if pos + len > String.length str then
+        if pos + len > Bytes.length str then
             invalid_arg "Cf_seq.to_substring: pos + len > String.length str";
         lazy (loop str pos len (Lazy.force s))
 
diff --git a/cf_seq.mli b/cf_seq.mli
index c2a6524..a113825 100644
--- a/cf_seq.mli
+++ b/cf_seq.mli
@@ -374,7 +374,7 @@ val to_string: char t -> string
     not describe a valid substring of [str], then [Invalid_argument] is raised.
     The unused portion of the character sequence is returned.
 *)
-val to_substring: char t -> string -> int -> int -> char t
+val to_substring: char t -> bytes -> int -> int -> char t
 
 (** [to_array v] is like [to_string s], except that it constructs an ['a array]
     value instead of a [string] value.