Skip to content

Commit 8ae7840

Browse files
committed
xapi-stdext-std: Do not include String functions in XStringext
Also remove all indiscriminate opens against it Signed-off-by: Pau Ruiz Safont <pau.ruizsafont@cloud.com> Signed-off-by: Pau Ruiz Safont <pau.safont@vates.tech>
1 parent 91b39a0 commit 8ae7840

39 files changed

Lines changed: 54 additions & 96 deletions

ocaml/database/parse_db_conf.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*)
1414
(* !!! This needs to be moved out of xapi and into the database directory; probably being merged with db_connections !!! *)
1515

16-
open Xapi_stdext_std.Xstringext
1716
open Xapi_stdext_unix
1817

1918
module D = Debug.Make (struct let name = "parse_db_conf" end)

ocaml/database/redo_log.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414
open Xapi_stdext_pervasives.Pervasiveext
15-
open Xapi_stdext_std.Xstringext
1615
open Xapi_stdext_unix
1716

1817
let with_lock = Xapi_stdext_threads.Threadext.Mutex.execute

ocaml/doc/dune

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(executable
22
(modes exe)
33
(name jsapi)
4-
(libraries
4+
(libraries
55
mustache
66
rpclib.core
77
rpclib.json
@@ -10,7 +10,6 @@
1010
xapi-consts
1111
xapi-datamodel
1212
xapi-stdext-pervasives
13-
xapi-stdext-std
1413
xapi-stdext-unix
1514
)
1615
(preprocess (pps ppx_deriving_rpc))

ocaml/doc/jsapi.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414

15-
open Xapi_stdext_std.Xstringext
1615
open Xapi_stdext_pervasives.Pervasiveext
1716
module Unixext = Xapi_stdext_unix.Unixext
1817
open Datamodel_types

ocaml/idl/ocaml_backend/gen_rbac.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ let role_uuid name = Option.get (hash2uuid name)
7070
let permission_description = "A basic permission"
7171

7272
let permission_name wire_name =
73-
let open Xapi_stdext_std in
7473
let s1 = replace_char (Printf.sprintf "permission_%s" wire_name) '.' '_' in
7574
let s2 = replace_char s1 '/' '_' in
76-
let s3 = Xstringext.String.replace "*" "WILDCHAR" s2 in
77-
Xstringext.String.replace ":" "_" s3
75+
let s3 = Xapi_stdext_std.Xstringext.String.replace "*" "WILDCHAR" s2 in
76+
replace_char s3 ':' '_'
7877

7978
let permission_index = ref 0
8079

ocaml/libs/xapi-stdext/lib/xapi-stdext-std/xstringext.ml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,27 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414
module String = struct
15-
include String
16-
1715
let of_char c = String.make 1 c
1816

1917
let rev_map f string =
20-
let n = length string in
18+
let n = String.length string in
2119
String.init n (fun i -> f string.[n - i - 1])
2220

2321
let rev_iter f string =
24-
for i = length string - 1 downto 0 do
22+
for i = String.length string - 1 downto 0 do
2523
f string.[i]
2624
done
2725

2826
let fold_left f accu string =
2927
let accu = ref accu in
30-
for i = 0 to length string - 1 do
28+
for i = 0 to String.length string - 1 do
3129
accu := f !accu string.[i]
3230
done ;
3331
!accu
3432

3533
let fold_right f string accu =
3634
let accu = ref accu in
37-
for i = length string - 1 downto 0 do
35+
for i = String.length string - 1 downto 0 do
3836
accu := f string.[i] !accu
3937
done ;
4038
!accu
@@ -65,17 +63,6 @@ module String = struct
6563
|> List.of_seq
6664
|> List.rev
6765

68-
let index_opt s c =
69-
let rec loop i =
70-
if String.length s = i then
71-
None
72-
else if s.[i] = c then
73-
Some i
74-
else
75-
loop (i + 1)
76-
in
77-
loop 0
78-
7966
let sub_to_end s start =
8067
let length = String.length s in
8168
String.sub s start (length - start)

ocaml/libs/xapi-stdext/lib/xapi-stdext-std/xstringext.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
* GNU Lesser General Public License for more details.
1313
*)
1414
module String : sig
15-
include module type of String
16-
1715
val of_char : char -> string
1816

1917
val rev_map : (char -> char) -> string -> string

ocaml/quicktest/quicktest_http.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module Uds = struct
3434
with_channel_aux fd func
3535

3636
let http_response_code d =
37-
match Xapi_stdext_std.Xstringext.String.split_on_char ' ' d with
37+
match String.split_on_char ' ' d with
3838
| _ :: code :: _ ->
3939
int_of_string code
4040
| _ ->

ocaml/xapi/authx.ml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ module AuthX : Auth_signature.AUTH_MODULE = struct
6565
| [] ->
6666
raise Not_found
6767
| line :: lines -> (
68-
let recs =
69-
Xapi_stdext_std.Xstringext.String.split_on_char ':' line
70-
in
68+
let recs = String.split_on_char ':' line in
7169
let username = List.nth recs 0 in
7270
let uid = List.nth recs 2 in
7371
match fn username uid recs with
@@ -293,9 +291,8 @@ module AuthX : Auth_signature.AUTH_MODULE = struct
293291
| _ ->
294292
raise Not_found
295293

296-
(*
297-
In addition, there are some event hooks that auth modules implement as follows:
298-
*)
294+
(* In addition, there are some event hooks that auth modules implement as
295+
follows: *)
299296

300297
(* unit on_enable(((string*string) list) config_params)
301298

ocaml/xapi/config_file_sync.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
module D = Debug.Make (struct let name = "config_file_sync" end)
1616

1717
open D
18-
open Xapi_stdext_std.Xstringext
1918

2019
let superuser = "root"
2120

0 commit comments

Comments
 (0)