Skip to content

Commit 5331c7e

Browse files
authored
Merge pull request #32 from djs55/fixes
Fix warnings and build with `-safe-string`
2 parents e3e203a + 50b8970 commit 5331c7e

File tree

10 files changed

+11
-42
lines changed

10 files changed

+11
-42
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ env:
1010
- OCAML_VERSION=4.02
1111
- OCAML_VERSION=4.03
1212
- OCAML_VERSION=4.04
13+
- OCAML_VERSION=4.06
1314
os:
1415
- linux

ezjsonm-lwt.opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ build: [
1818

1919
depends: [
2020
"ezjsonm"
21-
"ocamlfind" {build}
2221
"jbuilder" {build & >="1.0+beta9"}
2322
"alcotest" {test & >= "0.4.0"}
2423
"jsonm" {>= "0.9.1"}

ezjsonm-lwt.version

Lines changed: 0 additions & 1 deletion
This file was deleted.

ezjsonm.version

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/META

Lines changed: 0 additions & 22 deletions
This file was deleted.

lib/ezjsonm-lwt.mllib

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/ezjsonm.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,22 +244,24 @@ let map f t path =
244244
| h::tl ->
245245
match t with
246246
| `O d -> Some (`O (map_dict (fun t -> aux t tl) d h))
247-
| j -> None in
247+
| _ -> None in
248248
match aux t path with
249249
| None -> raise Not_found
250250
| Some j -> j
251251

252252
let update t path v =
253253
map (fun _ -> v) t path
254254

255+
exception Not_utf8
256+
255257
let is_valid_utf8 str =
256258
try
257259
Uutf.String.fold_utf_8 (fun _ _ -> function
258-
| `Malformed _ -> raise (Failure "utf8")
260+
| `Malformed _ -> raise Not_utf8
259261
| _ -> ()
260262
) () str;
261263
true
262-
with Failure "utf8" -> false
264+
with Not_utf8 -> false
263265

264266
let encode_string str =
265267
if is_valid_utf8 str
@@ -271,7 +273,7 @@ let encode_string str =
271273
let decode_string = function
272274
| `String str -> Some str
273275
| `O [ "hex", `String str ] -> Some (Hex.to_string (`Hex str))
274-
| j -> None
276+
| _ -> None
275277

276278
let decode_string_exn j =
277279
match decode_string j with

lib/ezjsonm.mllib

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/ezjsonm_lwt.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ let from_stream (stream: string Lwt_stream.t): value Lwt_stream.t =
2929
Lwt_stream.get stream >>= function
3030
| None -> Lwt.fail (Escape (Jsonm.decoded_range d, (`Expected `Value)))
3131
| Some str ->
32-
Jsonm.Manual.src d str 0 (String.length str);
32+
let bytes = Bytes.of_string str in
33+
Jsonm.Manual.src d bytes 0 (Bytes.length bytes);
3334
dec ()
3435
in
3536
let rec value v k = match v with
@@ -56,7 +57,7 @@ let from_stream (stream: string Lwt_stream.t): value Lwt_stream.t =
5657
let open_stream () =
5758
dec () >>= function
5859
| `As -> Lwt.return_unit
59-
| l -> Lwt.fail (Escape (Jsonm.decoded_range d, `Expected (`Aval true)))
60+
| _ -> Lwt.fail (Escape (Jsonm.decoded_range d, `Expected (`Aval true)))
6061
in
6162
let get () =
6263
dec () >>= fun v ->

lib_test/test.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
open Alcotest
2-
31
(* Check we're compatible with sexplib *)
42
type test = {
53
foo: Ezjsonm.value;
@@ -29,7 +27,7 @@ let random_string len =
2927
for i = 0 to Bytes.length s - 1 do
3028
Bytes.set s i @@ Char.chr (random_int 127)
3129
done;
32-
s
30+
Bytes.to_string s
3331

3432
let random_list len gen =
3533
Array.to_list (Array.init len gen)

0 commit comments

Comments
 (0)