summaryrefslogtreecommitdiff
path: root/lang/boomerang/patches/patch-common_hbase_misc.ml
blob: 46dd95a7ade9de5eba7badbfdbbbba45cd4950cc (plain)
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
$NetBSD: patch-common_hbase_misc.ml,v 1.1 2021/08/15 06:38:38 dholland Exp $

Fix build with current ocaml.

--- common/hbase/misc.ml~	2009-08-17 20:39:00.000000000 +0000
+++ common/hbase/misc.ml
@@ -207,20 +207,20 @@ let escape (escapeChar: char -> string) 
   let result = 
     if !n = String.length s then s else 
     begin
-      let s' = String.create !n in   
+      let s' = Bytes.create !n in   
       n := 0;
       for i = 0 to String.length s - 1 do 
         let c = String.get s i in
         let cEscaped = escapeChar c in
         if String.length cEscaped = 1 then begin
-          String.set s' !n c; incr n
+          Bytes.set s' !n c; incr n
         end else
           for i = 0 to String.length cEscaped - 1 do begin
-            String.set s' !n (String.get cEscaped i);
+            Bytes.set s' !n (String.get cEscaped i);
             incr n;
           end done
       done;
-      s'
+      Bytes.to_string s'
     end
   in
   debug(fun () -> Util.format "escape returns %s@\n" result);
@@ -231,10 +231,10 @@ let generic_escape_char escapedchars c =
   if c = '\\' then 
     "\\\\"
   else if String.contains escapedchars c then
-    let str = String.create 2 in
-    String.set str 0 '\\';
-    String.set str 1 c;
-    str
+    let str = Bytes.create 2 in
+    Bytes.set str 0 '\\';
+    Bytes.set str 1 c;
+    Bytes.to_string str
   else
     "-"
 
@@ -251,20 +251,20 @@ let generic_unescape s =
       else
         loop (i + 1) (n + 1)
     in
-    let s' = String.create (loop 0 0) in
+    let s' = Bytes.create (loop 0 0) in
     let rec loop i i' = 
       if i >= String.length s then
         ()
       else if s.[i] = '\\' then begin
-        s'.[i'] <- s.[i+1]; (* assumes that '\' always followed by a char *)
+        Bytes.set s' i' (String.get s (i+1)); (* assumes that '\' always followed by a char *)
         loop (i + 2) (i' + 1)
       end else begin
-        s'.[i'] <- s.[i];
+        Bytes.set s' i' (String.get s i);
         loop (i + 1) (i' + 1)
       end
     in
     loop 0 0;
-    s'
+    Bytes.to_string s'
 
 (* find c, skipping all the escaped characters, e.g., "\;" *)
 let rec index_rec_nonescape s i c = 
@@ -511,9 +511,9 @@ let rec remove_file_or_dir d =
 
 let read_chan chan =
   let nbytes = in_channel_length chan in
-  let string = String.create nbytes in
+  let string = Bytes.create nbytes in
   really_input chan string 0 nbytes;
-  string
+  Bytes.to_string string
 
 let read file =
   if file = "-" then
@@ -584,7 +584,7 @@ let rec cp_dash_r fromhere tohere =
 (* ### Should trap unix errors and do something sensible... *)
 let backup path =
   let newpath = backup_file_name path in
-  if is_dir path or Sys.file_exists path then cp_dash_r path newpath
+  if is_dir path || Sys.file_exists path then cp_dash_r path newpath
 
 (* exec : string -> string *)
 let exec s =