Skip to content

Commit

Permalink
Merge pull request #86 from mirage/fmt-fix
Browse files Browse the repository at this point in the history
Replace deprecated functions of `fmt` library
  • Loading branch information
dinosaure authored Oct 12, 2021
2 parents f55a772 + 48123d3 commit 530f613
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion fuzz/fuzz_encoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let rec value t x =
| `Bool true -> Prettym.string t "true"
| `Bool false -> Prettym.string t "false"
| `Null -> Prettym.string t "null"
| `Float f -> Prettym.string t (Fmt.strf "%.16g" f)
| `Float f -> Prettym.string t (Fmt.str "%.16g" f)
| `String s -> Prettym.eval t Prettym.[ char $ '"'; !!string; char $ '"' ] s
| `A a -> Prettym.eval t Prettym.[ char $ '['; !!arr; char $ ']' ] a
| `O o -> Prettym.eval t Prettym.[ char $ '{'; !!obj; char $ '}' ] o
Expand Down
2 changes: 1 addition & 1 deletion lib/content_encoding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let equal a b =
module Decoder = struct
open Angstrom

let invalid_token token = Fmt.kstrf fail "invalid token: %s" token
let invalid_token token = Fmt.kstr fail "invalid token: %s" token

let of_string s a =
match parse_string ~consume:Consume.All a s with
Expand Down
4 changes: 2 additions & 2 deletions lib/content_type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ module Parameters = struct

let pp ppf t =
let pp ppf (key, value) = Fmt.pf ppf "%a=%a" pp_key key pp_value value in
Fmt.list ~sep:(Fmt.always ";@ ") pp ppf (Map.bindings t)
Fmt.list ~sep:(Fmt.any ";@ ") pp ppf (Map.bindings t)

let of_escaped_character = function
| '\x61' -> '\x07' (* "\a" *)
Expand Down Expand Up @@ -410,7 +410,7 @@ let equal a b =
module Decoder = struct
open Angstrom

let invalid_token token = Fmt.kstrf fail "invalid token: %s" token
let invalid_token token = Fmt.kstr fail "invalid token: %s" token

let of_string s a =
match parse_string ~consume:Consume.All a s with
Expand Down
6 changes: 3 additions & 3 deletions lib/date.ml
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ module Zone = struct

let to_string = function
| TZ (hh, mm) ->
if hh >= 0 then Fmt.strf "+%02d%02d" hh mm
else Fmt.strf "-%02d%02d" (abs hh) mm
if hh >= 0 then Fmt.str "+%02d%02d" hh mm
else Fmt.str "-%02d%02d" (abs hh) mm
| Military_zone c -> String.make 1 c
| x -> Fmt.to_to_string pp x

Expand Down Expand Up @@ -1036,7 +1036,7 @@ module Encoder = struct
let month = using Month.to_string string

let time ppf (hours, minutes, seconds) =
let string_of_number = Fmt.strf "%02d" in
let string_of_number = Fmt.str "%02d" in
let number ppf x =
eval ppf [ cut; !!(using string_of_number string); cut ] x
in
Expand Down
2 changes: 1 addition & 1 deletion lib/encoded_word.ml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ module Decoder = struct
| Quoted_printable -> normalize_quoted_printable ?chunk ~charset raw
| Base64 -> normalize_base64 ?chunk ~charset raw

let invalid_encoding = Fmt.kstrf fail "Invalid encoding '%c'"
let invalid_encoding = Fmt.kstr fail "Invalid encoding '%c'"

(* From RFC 2047
Expand Down
2 changes: 1 addition & 1 deletion lib/header.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type t = Field.field Location.with_location list

let pp = Fmt.(list ~sep:(always "@\n") (using Location.prj Field.pp))
let pp = Fmt.(list ~sep:(any "@\n") (using Location.prj Field.pp))

let assoc field_name header =
let f acc (Field.Field (field_name', _, _) as field) =
Expand Down
2 changes: 1 addition & 1 deletion lib/rfc2046.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let discard_all_to_delimiter boundary =
| Some _ -> advance 1 *> m (* impossible case? *)
| None -> return ()

let nothing_to_do = Fmt.kstrf fail "nothing to do"
let nothing_to_do = Fmt.kstr fail "nothing to do"
let crlf = string "\r\n"

let possible_boundary boundary =
Expand Down
2 changes: 1 addition & 1 deletion mrmime.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "2.7"}
"rresult"
"fmt"
"fmt" {>= "0.8.7"}
"ke" {>= "0.4"}
"unstrctrd" {>= "0.2"}
"ptime" {>= "0.8.2"}
Expand Down
2 changes: 1 addition & 1 deletion test/rfc2045.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let ( <.> ) f g x = f (g x)
let parse_content_type x =
let parser =
let open Angstrom in
let failf fmt = Fmt.kstrf fail fmt in
let failf fmt = Fmt.kstr fail fmt in
let buf = Bytes.create 0x7f in
Unstrctrd_parser.unstrctrd buf >>= fun v ->
let res =
Expand Down
2 changes: 1 addition & 1 deletion test/rfc5322.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ let parse_and_print_header x =

let header_tests =
let make idx input =
Alcotest.test_case (Fmt.strf "header %d" idx) `Quick @@ fun () ->
Alcotest.test_case (Fmt.str "header %d" idx) `Quick @@ fun () ->
Alcotest.(check pass) input (parse_and_print_header input) ()
in
List.mapi make header_tests
Expand Down
2 changes: 1 addition & 1 deletion test/test_date.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let parse_date x =
Angstrom.parse_string ~consume:Angstrom.Consume.All parser (x ^ "\r\n")

let make raw expect =
Alcotest.test_case (Fmt.strf "%S" raw) `Quick @@ fun () ->
Alcotest.test_case (Fmt.str "%S" raw) `Quick @@ fun () ->
match parse_date raw with
| Ok value -> Alcotest.(check date) raw expect value
| Error err -> Fmt.invalid_arg "Invalid date value (%s): %s." err raw
Expand Down

0 comments on commit 530f613

Please sign in to comment.