Skip to content

Commit

Permalink
Add support for OCaml 5.1.1 (#1124)
Browse files Browse the repository at this point in the history
Marshal compression flag support
  • Loading branch information
kit-ty-kate committed Nov 27, 2023
1 parent cb65367 commit 56d59d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions build/prefilter.ml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
let (major, minor, extra) =
let (major, minor, micro, extra) =
Scanf.sscanf Sys.ocaml_version
"%d.%d.%d%s" (fun j n _ s -> (j, n, s))
"%d.%d.%d%s" (fun j n m s -> (j, n, m, s))

let filter_cookie_re =
Str.regexp "^##V\\([<>]?=?\\)\\([^#]+\\)##"
let version_re =
Str.regexp "\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?"
Str.regexp "\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?\\(\\.\\([0-9]+\\)\\)?"

(* We track line count in the input source, to print location
directives for the OCaml lexer:
Expand Down Expand Up @@ -57,7 +57,8 @@ let rec process_line loc line =
if Str.string_match version_re ver_string 0 then
let ver_maj = int_of_string (Str.matched_group 1 ver_string) in
let ver_min = try int_of_string (Str.matched_group 3 ver_string) with _ -> 0 in
cmp (major*100+minor) (ver_maj*100+ver_min)
let ver_mic = try int_of_string (Str.matched_group 5 ver_string) with _ -> 0 in
cmp (major*10000+minor*100+micro) (ver_maj*10000+ver_min*100+ver_mic)
else if ver_string = "multicore" then
cmp (if has_domains ~extra then 5 else major) 5
else
Expand Down
4 changes: 2 additions & 2 deletions src/batMarshal.mli
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type extern_flags = Marshal.extern_flags =
No_sharing (** Don't preserve sharing *)
| Closures (** Send function closures *)
##V>=4.1## | Compat_32 (** Ensure 32-bit compatibility *)
##V>=5.1## | Compression (** Compress the output if possible *)
##V>=5.1####V<5.1.1## | Compression (** Compress the output if possible *)
(** The flags to the [Marshal.to_*] functions below. *)


Expand Down Expand Up @@ -101,7 +101,7 @@ val output: _ BatInnerIO.output -> ?sharing:bool -> ?closures:bool -> 'a -> unit
@since 2.3.0
*)

##V>=5.1##val compression_supported : unit -> bool
##V>=5.1####V<5.1.1##val compression_supported : unit -> bool

external to_string :
'a -> extern_flags list -> string = "caml_output_value_to_string"
Expand Down

0 comments on commit 56d59d7

Please sign in to comment.