Skip to content

Commit

Permalink
Fixes for OCaml 4.01
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Jun 1, 2015
1 parent 3694850 commit 248f960
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions tcp/log.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ let enable t = t.enabled <- true
let disable t = t.enabled <- false
let enabled t = t.enabled
let name t = t.name

let rec pp_print_list ?(pp_sep = Format.pp_print_cut) pp_v ppf = function
| [] -> ()
| [v] -> pp_v ppf v
| v :: vs ->
pp_v ppf v;
pp_sep ppf ();
pp_print_list ~pp_sep pp_v ppf vs
11 changes: 11 additions & 0 deletions tcp/log.mli
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,14 @@ val name: t -> string

val f: t -> ('a, Format.formatter, unit) format -> 'a
(** Print some information on a logger. *)

val pp_print_list:
?pp_sep:(Format.formatter -> unit -> unit) ->
(Format.formatter -> 'a -> unit) -> (Format.formatter -> 'a list -> unit)
(** [pp_print_list ?pp_sep pp_v ppf l] prints the list [l]. [pp_v] is
used on the elements of [l] and each element is separated by
a call to [pp_sep] (defaults to {!pp_print_cut}). Does nothing on
empty lists.
@since 4.02.0
*)
4 changes: 2 additions & 2 deletions tcp/options.ml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ let marshal buf ts =

let pp_sack fmt x =
let pp_v fmt (l, r) = Format.fprintf fmt "[%lu,%lu]" l r in
Format.pp_print_list pp_v fmt x
Log.pp_print_list pp_v fmt x

let pp fmt = function
| Noop -> Format.fprintf fmt "Noop"
Expand All @@ -174,5 +174,5 @@ let pp fmt = function
let pps fmt = function
| [] -> Format.fprintf fmt "[]"
| x ->
let ppl fmt x = Format.pp_print_list pp fmt x in
let ppl fmt x = Log.pp_print_list pp fmt x in
Format.fprintf fmt "[ %a ]" ppl x
2 changes: 1 addition & 1 deletion tcp/segment.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module Rx(Time:V1_LWT.TIME) = struct
let pp_v fmt seg =
Format.fprintf fmt "%a[%d]" Sequence.pp seg.sequence (len seg)
in
Format.pp_print_list pp_v fmt (S.elements t.segs)
Log.pp_print_list pp_v fmt (S.elements t.segs)

(* If there is a FIN flag at the end of this segment set. TODO:
should look for a FIN and chop off the rest of the set as they
Expand Down

0 comments on commit 248f960

Please sign in to comment.