diff --git a/dune-project b/dune-project index 15bd978e..971ae457 100644 --- a/dune-project +++ b/dune-project @@ -21,7 +21,7 @@ (name re) (synopsis "RE is a regular expression library for OCaml") (depends - (ocaml (>= 4.12.0)) + (ocaml (>= 4.08.0)) (ppx_expect :with-test) (ounit2 :with-test) (js_of_ocaml :with-test)) diff --git a/lib/emacs.ml b/lib/emacs.ml index c026836f..cc56db60 100644 --- a/lib/emacs.ml +++ b/lib/emacs.ml @@ -21,6 +21,7 @@ *) module Re = Core +open Import exception Parse_error exception Not_supported diff --git a/lib/fake/atomic.ml b/lib/fake/atomic.ml new file mode 100644 index 00000000..021c9023 --- /dev/null +++ b/lib/fake/atomic.ml @@ -0,0 +1,10 @@ +type 'a t = 'a ref + +let make x = ref x +let get x = !x +let set atomic v = atomic := v + +let fetch_and_add atomic n = + let v = !atomic in + atomic := v + n; + v diff --git a/lib/import.ml b/lib/import.ml index ea7bfd66..0fae1da7 100644 --- a/lib/import.ml +++ b/lib/import.ml @@ -1,4 +1,19 @@ -module List = Stdlib.ListLabels +module List = struct + let[@warning "-32"] rec equal ~eq l1 l2 = match l1, l2 with + | [], [] -> true + | [], _::_ | _::_, [] -> false + | x::xs, y::ys -> if eq x y then equal ~eq xs ys else false + + let[@warning "-32"] rec compare ~cmp l1 l2 = match l1, l2 with + | [], [] -> 0 + | [], _::_ -> -1 + | _::_, [] -> 1 + | x::xs, y::ys -> + let r = cmp x y in + if r = 0 then compare ~cmp xs ys else r + + include Stdlib.ListLabels +end module Poly = struct let equal = ( = ) @@ -13,12 +28,13 @@ let ( = ) = Int.equal let ( == ) = [ `Use_phys_equal ] let ( < ) (x : int) (y : int) = x < y let ( > ) (x : int) (y : int) = x > y -let min = Int.min -let max = Int.max +let min (x : int) (y : int) = if x <= y then x else y +let max (x : int) (y : int) = if x >= y then x else y let compare = Int.compare module Int = struct let[@warning "-32"] hash (x : int) = Hashtbl.hash x + let[@warning "-32"] max (x : int) (y : int) = if x >= y then x else y include Stdlib.Int end diff --git a/re.opam b/re.opam index aba1d986..cd0b27f2 100644 --- a/re.opam +++ b/re.opam @@ -23,7 +23,7 @@ homepage: "https://github.com/ocaml/ocaml-re" bug-reports: "https://github.com/ocaml/ocaml-re/issues" depends: [ "dune" {>= "3.15"} - "ocaml" {>= "4.12.0"} + "ocaml" {>= "4.08.0"} "ppx_expect" {with-test} "ounit2" {with-test} "js_of_ocaml" {with-test}