Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ocaml-extlib for openSUSE:Factory checked in at 2021-04-29 01:36:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ocaml-extlib (Old) and /work/SRC/openSUSE:Factory/.ocaml-extlib.new.12324 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ocaml-extlib" Thu Apr 29 01:36:44 2021 rev:8 rq:867933 version:1.7.8 Changes: -------- --- /work/SRC/openSUSE:Factory/ocaml-extlib/ocaml-extlib.changes 2019-11-12 16:11:49.631778652 +0100 +++ /work/SRC/openSUSE:Factory/.ocaml-extlib.new.12324/ocaml-extlib.changes 2021-04-29 01:37:11.294475351 +0200 @@ -1,0 +2,10 @@ +Thu Jan 21 21:21:21 UTC 2021 - [email protected] + +- Update to version 1.7.8 + * sync with OCaml 4.12 + * ExtList.find_map type updated to match stdlib + * minimal (recommended) build of extlib now excludes Base64 module + * String: fold_left and fold_right without allocations +- use ocaml-extlib.patch to build with dune + +------------------------------------------------------------------- Old: ---- ocaml-extlib-1.7.6.tar.xz New: ---- ocaml-extlib-1.7.8.tar.xz ocaml-extlib.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ocaml-extlib.spec ++++++ --- /var/tmp/diff_new_pack.pdkQMg/_old 2021-04-29 01:37:11.790476054 +0200 +++ /var/tmp/diff_new_pack.pdkQMg/_new 2021-04-29 01:37:11.794476060 +0200 @@ -1,7 +1,7 @@ # # spec file for package ocaml-extlib # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2021 SUSE LLC # Copyright (c) 2011 Andrew Psaltis <ampsaltis at gmail dot com> # # All modifications and additions to the file contributed by third parties @@ -18,18 +18,19 @@ Name: ocaml-extlib -Version: 1.7.6 +Version: 1.7.8 Release: 0 %{?ocaml_preserve_bytecode} Summary: OCaml ExtLib additions to the standard library License: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception Group: Development/Languages/OCaml -Url: https://github.com/ygrek/ocaml-extlib +URL: https://opam.ocaml.org/packages/extlib Source0: %{name}-%{version}.tar.xz +Patch0: %{name}.patch BuildRequires: ocaml BuildRequires: ocaml-cppo BuildRequires: ocaml-dune -BuildRequires: ocaml-rpm-macros >= 20191101 +BuildRequires: ocaml-rpm-macros >= 20210121 %description ExtLib is a project aiming at providing a complete - yet small - @@ -53,6 +54,7 @@ %build dune_release_pkgs='extlib' +mv opam ${dune_release_pkgs}.opam %ocaml_dune_setup %ocaml_dune_build ++++++ _service ++++++ --- /var/tmp/diff_new_pack.pdkQMg/_old 2021-04-29 01:37:11.822476099 +0200 +++ /var/tmp/diff_new_pack.pdkQMg/_new 2021-04-29 01:37:11.822476099 +0200 @@ -1,10 +1,13 @@ <services> <service name="tar_scm" mode="disabled"> - <param name="url">https://github.com/dune-universe/ocaml-extlib.git</param> - <param name="scm">git</param> - <param name="versionformat">1.7.6</param> - <param name="revision">duniverse-1.7.6</param> <param name="filename">ocaml-extlib</param> + <param name="revision">079e7a8f58bd77990df46e3a27791f9853e072fe</param> + <param name="scm">git</param> + <param name="submodules">disable</param> + <param name="url">https://github.com/ygrek/ocaml-extlib.git</param> + <param name="versionformat">@PARENT_TAG@</param> + <param name="versionrewrite-pattern">[v]?([^+]+)(.*)</param> + <param name="versionrewrite-replacement">\1</param> </service> <service name="recompress" mode="disabled"> <param name="file">*.tar</param> ++++++ ocaml-extlib-1.7.6.tar.xz -> ocaml-extlib-1.7.8.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/.travis.yml new/ocaml-extlib-1.7.8/.travis.yml --- old/ocaml-extlib-1.7.6/.travis.yml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/.travis.yml 2021-01-20 00:51:04.000000000 +0100 @@ -4,29 +4,25 @@ script: bash -ex .travis-opam.sh matrix: include: - - env: OCAML_VERSION=4.02 - os: osx - - env: OCAML_VERSION=4.03 - os: osx - - env: OCAML_VERSION=4.04 - os: osx - - env: OCAML_VERSION=4.05 - os: osx - - env: OCAML_VERSION=4.06 + - env: OCAML_VERSION=4.09 os: osx - env: OCAML_VERSION=4.02 os: linux - - env: OCAML_VERSION=4.03 + - env: OCAML_VERSION=4.08 os: linux - - env: OCAML_VERSION=4.04 + - env: OCAML_VERSION=4.11 os: linux - - env: OCAML_VERSION=4.05 - os: linux - - env: OCAML_VERSION=4.06 + - env: OCAML_VERSION=4.12 os: linux - env: OCAML_VERSION=4.06 OPAM_SWITCH=4.06.1+32bit os: linux addons: apt: + packages: + - gcc-multilib + - env: OCAML_VERSION=4.10 OPAM_SWITCH=4.10.2+32bit + os: linux + addons: + apt: packages: - gcc-multilib diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/CHANGES new/ocaml-extlib-1.7.8/CHANGES --- old/ocaml-extlib-1.7.6/CHANGES 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/CHANGES 2021-01-20 00:51:04.000000000 +0100 @@ -1,3 +1,13 @@ +1.7.8 (2021-01-19) +* sync with OCaml 4.12 +* breaking change: ExtList.find_map type updated to match stdlib (following deprecation in previous release) +* breaking change: minimal (recommended) build of extlib now excludes Base64 module + +1.7.7 (2020-04-24) +* sync with OCaml 4.10 +* mark ExtList.find_map deprecated in anticipation of type breakage in next release to match OCaml 4.10 function with same name +* String: fold_left and fold_right without allocations + 1.7.6 (2019-03-03) * fix Dllist.skip with negative argument (Virgile Robles) * fix IO.read_bits 31 (Dan Korostelev) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/Makefile new/ocaml-extlib-1.7.8/Makefile --- old/ocaml-extlib-1.7.6/Makefile 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/Makefile 2021-01-20 00:51:04.000000000 +0100 @@ -1,6 +1,6 @@ VERSION:=$(shell git --git-dir=.git describe --always --long) -RELEASE:=1.7.6 +RELEASE:=1.7.8 ifndef VERSION VERSION:=$(RELEASE) @@ -32,4 +32,46 @@ release: git tag -a -m $(RELEASE) $(RELEASE) git archive --prefix=$(NAME)/ $(RELEASE) | gzip > $(NAME).tar.gz - gpg -a -b $(NAME).tar.gz + gpg -a -b $(NAME).tar.gz -o $(NAME).tar.gz.asc + +.PHONY: sw_test_all sw_deps_all + +define gen_sw = +sw_test_all:: sw_test_$(1) +sw_deps_all:: sw_deps_$(1) + +.PHONY: sw_deps_$(1) +sw_deps_$(1): + opam install --switch=$(1) -y --deps-only . + +.PHONY: sw_test_$(1) +sw_test_$(1): + -opam exec --switch=$(1) -- make clean build test >/dev/null 2>/dev/null +# expected to fail < 4.03.0 +ifneq "$(1)" "3.12.1" +ifneq "$(1)" "4.00.1" +ifneq "$(1)" "4.01.0" +ifneq "$(1)" "4.02.3" + -opam exec --switch=$(1) -- ocaml test/std.ml +endif +endif +endif +endif +endef + +$(foreach version,\ + 3.12.1\ + 4.00.1\ + 4.01.0\ + 4.02.3\ + 4.03.0\ + 4.04.2\ + 4.05.0\ + 4.06.1\ + 4.07.1\ + 4.08.0\ + 4.09.1\ + 4.10.2\ + 4.11.1\ + 4.12.0~beta1\ +,$(eval $(call gen_sw,$(version)))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/README.md new/ocaml-extlib-1.7.8/README.md --- old/ocaml-extlib-1.7.6/README.md 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/README.md 2021-01-20 00:51:04.000000000 +0100 @@ -1,7 +1,7 @@ OCaml Extended standard Library - ExtLib. ========================================= -[](https://travis-ci.org/ygrek/ocaml-extlib) +[](https://travis-ci.com/ygrek/ocaml-extlib) [](https://ci.appveyor.com/project/ygrek/ocaml-extlib/branch/master) ``` @@ -25,12 +25,15 @@ ---------------- ExtLib is a set of additional useful functions and modules for OCaml. +Current goal is to maintain compatibility, new software is encouraged to not use extlib since stdlib +is now seeing many additions and improvements which make many parts of extlib obsolete. +For tail-recursion safety consider using other libraries e.g. containers. Project page : https://github.com/ygrek/ocaml-extlib Online API documentation : - http://ygrek.org.ua/p/extlib/doc/ + https://ygrek.org/p/extlib/doc/ Dependencies ------------ @@ -50,7 +53,7 @@ `make minimal=1 all install` -`minimal=1` will exclude from build several modules (namely `Unzip` `UChar` `UTF8`) potentially +`minimal=1` will exclude from build several modules (namely `Base64` `Unzip` `UChar` `UTF8`) potentially conflicting with other well established OCaml libraries. If your code is expecting to find these modules in extlib - omit this parameter during build to produce the full library. @@ -62,6 +65,9 @@ Release ------- +* Check for changes in stdlib (e.g. with ocaml test/std.ml) +* Update sw_test_all target for new OCaml release +* `make sw_test_all` * Review `git log` and update CHANGES * Update version in Makefile * Commit diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/dune-project new/ocaml-extlib-1.7.8/dune-project --- old/ocaml-extlib-1.7.6/dune-project 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/dune-project 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -(lang dune 1.0) -(name extlib) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/extlib.opam new/ocaml-extlib-1.7.8/extlib.opam --- old/ocaml-extlib-1.7.6/extlib.opam 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/extlib.opam 1970-01-01 01:00:00.000000000 +0100 @@ -1,38 +0,0 @@ -opam-version: "2.0" -maintainer: "[email protected]" -homepage: "https://github.com/ygrek/ocaml-extlib" -dev-repo: "git://github.com/ygrek/ocaml-extlib.git" -bug-reports: "https://github.com/ygrek/ocaml-extlib/issues" -doc: ["http://ygrek.org.ua/p/extlib/doc/"] -license: "LGPL-2.1 with OCaml linking exception" -synopsis: "A complete yet small extension for OCaml standard library" -authors: [ - "Nicolas Cannasse" - "Brian Hurt" - "Yamagata Yoriyuki" - "Markus Mottl" - "Jesse Guardiani" - "John Skaller" - "Bardur Arantsson" - "Janne Hellsten" - "Richard W.M. Jones" - "ygrek" - "Gabriel Scherer" - "Pietro Abate" -] -build: [ - [make "minimal=1" "build"] - [make "test"] {with-test} - [make "doc"] {with-doc} -] -install: [ [make "minimal=1" "install"] ] -remove: [ - ["ocamlfind" "remove" "extlib"] -] -depends: [ - "ocaml" - "ocamlfind" {build} - "cppo" {build} - "base-bytes" {build} -] -flags: light-uninstall diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/opam new/ocaml-extlib-1.7.8/opam --- old/ocaml-extlib-1.7.6/opam 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-extlib-1.7.8/opam 2021-01-20 00:51:04.000000000 +0100 @@ -0,0 +1,39 @@ +opam-version: "2.0" +maintainer: "[email protected]" +homepage: "https://github.com/ygrek/ocaml-extlib" +dev-repo: "git://github.com/ygrek/ocaml-extlib.git" +bug-reports: "https://github.com/ygrek/ocaml-extlib/issues" +doc: ["https://ygrek.org/p/extlib/doc/"] +license: "LGPL-2.1-only with OCaml-LGPL-linking-exception" +synopsis: "A complete yet small extension for OCaml standard library" +authors: [ + "Nicolas Cannasse" + "Brian Hurt" + "Yamagata Yoriyuki" + "Markus Mottl" + "Jesse Guardiani" + "John Skaller" + "Bardur Arantsson" + "Janne Hellsten" + "Richard W.M. Jones" + "ygrek" + "Gabriel Scherer" + "Pietro Abate" +] +build: [ + [make "minimal=1" "build"] + [make "minimal=1" "test"] {with-test} + [make "minimal=1" "doc"] {with-doc} +] +install: [ [make "minimal=1" "install"] ] +depends: [ + "ocaml" + "ocamlfind" {build} + "cppo" {build} + "base-bytes" {build} +] +description: """ +The purpose of this library is to add new functions to OCaml standard library +modules, to modify some functions in order to get better performances or +safety (tail-recursive) and also to provide new modules which should be useful +for day to day programming.""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/Makefile new/ocaml-extlib-1.7.8/src/Makefile --- old/ocaml-extlib-1.7.6/src/Makefile 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/Makefile 2021-01-20 00:51:04.000000000 +0100 @@ -6,7 +6,7 @@ global IO option pMap std uChar uTF8 base64 unzip refList optParse dllist extLib ifdef minimal -MODULES := $(filter-out unzip uChar uTF8, $(MODULES)) +MODULES := $(filter-out base64 unzip uChar uTF8, $(MODULES)) endif CPPO_ARGS := $(shell ocaml configure.ml -cppo-args) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/configure.ml new/ocaml-extlib-1.7.8/src/configure.ml --- old/ocaml-extlib-1.7.6/src/configure.ml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/configure.ml 2021-01-20 00:51:04.000000000 +0100 @@ -1,17 +1,18 @@ open Printf +let show_bytes s = + let (_:int) = Sys.command (sprintf "ocamlfind query -format %s bytes" (Filename.quote s)) in () + let () = match Sys.argv with | [|_;"-cppo-args"|] -> let version = Scanf.sscanf Sys.ocaml_version "%d.%d." (fun major minor -> major * 100 + minor) in - printf "-D\n"; - printf "OCAML %d\n" version; - if Sys.word_size = 32 then (print_endline "-D"; print_endline "WORD_SIZE_32 "); - print_endline "-D"; - print_endline "WITH_BYTES"; + printf "-D \\\"OCAML %d\\\"\n" version; + print_endline (if Sys.word_size = 32 then "-D WORD_SIZE_32 " else ""); + show_bytes "-D WITH_BYTES"; exit 0 | [|_;"-compile-args"|] -> if Sys.ocaml_version >= "4.00.0" then print_endline "-bin-annot"; - print_endline "-package bytes"; + show_bytes "-package bytes"; exit 0 | _ -> failwith "not gonna happen" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/dune new/ocaml-extlib-1.7.8/src/dune --- old/ocaml-extlib-1.7.6/src/dune 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/dune 1970-01-01 01:00:00.000000000 +0100 @@ -1,18 +0,0 @@ -(library - (name extlib) - (public_name extlib) - (modules :standard \ configure install uChar uTF8) - (flags :standard -w -3-6-9-27-32-33-35-39-50) - (preprocess - (action - (run %{bin:cppo} %{read-lines:compat-level} %{input-file}))) - (wrapped false)) - -(rule - (targets compat-level) - (deps - (:< configure.ml)) - (action - (with-stdout-to - %{targets} - (run ocaml %{<} -cppo-args)))) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extArray.ml new/ocaml-extlib-1.7.8/src/extArray.ml --- old/ocaml-extlib-1.7.6/src/extArray.ml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extArray.ml 2021-01-20 00:51:04.000000000 +0100 @@ -20,6 +20,10 @@ module Array = struct +#if OCAML < 408 +type 'a t = 'a array +#endif + include Array let rev_in_place xs = @@ -108,6 +112,30 @@ let find_all = filter +#if OCAML < 411 + +let for_all2 p l1 l2 = + let n1 = length l1 + and n2 = length l2 in + if n1 <> n2 then invalid_arg "Array.for_all2" + else let rec loop i = + if i = n1 then true + else if p (unsafe_get l1 i) (unsafe_get l2 i) then loop (succ i) + else false in + loop 0 + +let exists2 p l1 l2 = + let n1 = length l1 + and n2 = length l2 in + if n1 <> n2 then invalid_arg "Array.exists2" + else let rec loop i = + if i = n1 then false + else if p (unsafe_get l1 i) (unsafe_get l2 i) then true + else loop (succ i) in + loop 0 + +#endif + let partition p xs = let n = length xs in (* Use a bitset to store which elements will be in which final array. *) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extArray.mli new/ocaml-extlib-1.7.8/src/extArray.mli --- old/ocaml-extlib-1.7.6/src/extArray.mli 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extArray.mli 2021-01-20 00:51:04.000000000 +0100 @@ -28,6 +28,8 @@ module Array : sig + type 'a t = 'a array + (** {6 New functions} *) val rev : 'a array -> 'a array (** Array reversal. *) @@ -130,6 +132,14 @@ end #endif + val for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool + (** Same as {!Array.for_all}, but for a two-argument predicate. + @raise Invalid_argument if the two arrays have different lengths. *) + + val exists2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool + (** Same as {!Array.exists}, but for a two-argument predicate. + @raise Invalid_argument if the two arrays have different lengths. *) + (** {6 Old functions} *) (** These functions are already part of the Ocaml standard library diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extBuffer.mli new/ocaml-extlib-1.7.8/src/extBuffer.mli --- old/ocaml-extlib-1.7.6/src/extBuffer.mli 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extBuffer.mli 2021-01-20 00:51:04.000000000 +0100 @@ -89,4 +89,22 @@ val of_seq : char Seq.t -> t #endif +#if OCAML >= 408 +(** [add_*int*] functions were introduced in OCaml 4.08.0, and are _not_ implemented in extlib for older OCaml versions *) +val add_uint8 : t -> int -> unit +val add_int8 : t -> int -> unit +val add_uint16_ne : t -> int -> unit +val add_uint16_be : t -> int -> unit +val add_uint16_le : t -> int -> unit +val add_int16_ne : t -> int -> unit +val add_int16_be : t -> int -> unit +val add_int16_le : t -> int -> unit +val add_int32_ne : t -> int32 -> unit +val add_int32_be : t -> int32 -> unit +val add_int32_le : t -> int32 -> unit +val add_int64_ne : t -> int64 -> unit +val add_int64_be : t -> int64 -> unit +val add_int64_le : t -> int64 -> unit +#endif + end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extHashtbl.ml new/ocaml-extlib-1.7.8/src/extHashtbl.ml --- old/ocaml-extlib-1.7.6/src/extHashtbl.ml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extHashtbl.ml 2021-01-20 00:51:04.000000000 +0100 @@ -22,7 +22,7 @@ module Hashtbl = struct -#if OCAML >= 400 +#if OCAML >= 400 && OCAML < 412 external old_hash_param : int -> int -> 'a -> int = "caml_hash_univ_param" "noalloc" #endif @@ -114,7 +114,11 @@ (* compatibility with old hash tables *) if Obj.size (Obj.repr h) >= 3 then (seeded_hash_param 10 100 (h_conv h).seed key) land (Array.length (h_conv h).data - 1) + #if OCAML >= 412 + else failwith "Old hash function not supported anymore" + #else else (old_hash_param 10 100 key) mod (Array.length (h_conv h).data) + #endif #else let key_index h key = (hash key) mod (Array.length (h_conv h).data) #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extHashtbl.mli new/ocaml-extlib-1.7.8/src/extHashtbl.mli --- old/ocaml-extlib-1.7.6/src/extHashtbl.mli 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extHashtbl.mli 2021-01-20 00:51:04.000000000 +0100 @@ -122,6 +122,10 @@ val of_seq : ('a * 'b) Seq.t -> ('a, 'b) t #endif +#if OCAML >= 412 +val rebuild : ?random:bool -> ('a, 'b) t -> ('a, 'b) t +#endif + (** Functor interface forwards directly to stdlib implementation (i.e. no enum functions) *) #if OCAML >= 407 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extList.ml new/ocaml-extlib-1.7.8/src/extList.ml --- old/ocaml-extlib-1.7.6/src/extList.ml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extList.ml 2021-01-20 00:51:04.000000000 +0100 @@ -22,6 +22,10 @@ module List = struct +#if OCAML < 408 +type 'a t = 'a list +#endif + exception Empty_list exception Invalid_index of int exception Different_list_size of string @@ -30,7 +34,7 @@ (* Thanks to Jacques Garrigue for suggesting the following structure *) type 'a mut_list = { - hd: 'a; + hd: 'a; mutable tl: 'a list } external inj : 'a mut_list -> 'a list = "%identity" @@ -162,12 +166,48 @@ loop dummy l; dummy.tl -let rec find_map f = function +let rec find_map_exn f = function | [] -> raise Not_found | x :: xs -> match f x with | Some y -> y - | None -> find_map f xs + | None -> find_map_exn f xs + +let rec find_map_opt f = function + | [] -> None + | x :: xs -> + match f x with + | Some _ as y -> y + | None -> find_map_opt f xs + +let find_map = find_map_opt + +let filteri f l = + let rec findnext i dst = function + | [] -> () + | h :: t -> + if f i h then + let r = { hd = h; tl = [] } in + dst.tl <- inj r; + findnext (i+1) r t + else + findnext (i+1) dst t + in + let dummy = dummy_node () in + findnext 0 dummy l; + dummy.tl + +let fold_left_map f accu l = + let dummy = dummy_node () in + let rec aux accu l_accu = function + | [] -> accu, dummy.tl + | x :: l -> + let accu, x = f accu x in + let r = { hd = x; tl = [] } in + l_accu.tl <- inj r; + aux accu r l + in + aux accu dummy l let fold_right_max = 1000 @@ -367,7 +407,7 @@ loop dummy l1 l2; dummy.tl -let sort ?(cmp=compare) = List.sort cmp +let sort ?(cmp=Pervasives.compare) = List.sort cmp #if OCAML < 406 let rec init size f = @@ -557,6 +597,34 @@ #endif +#if OCAML < 410 +let concat_map f l = + let rec aux f acc = function + | [] -> rev acc + | x :: l -> + let xs = f x in + aux f (rev_append xs acc) l + in aux f [] l +#endif + +#if OCAML < 412 +let rec equal eq l1 l2 = + match l1, l2 with + | [], [] -> true + | [], _::_ | _::_, [] -> false + | a1::l1, a2::l2 -> eq a1 a2 && equal eq l1 l2 + +let rec compare cmp l1 l2 = + match l1, l2 with + | [], [] -> 0 + | [], _::_ -> -1 + | _::_, [] -> 1 + | a1::l1, a2::l2 -> + let c = cmp a1 a2 in + if c <> 0 then c + else compare cmp l1 l2 +#endif + end let ( @ ) = List.append diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extList.mli new/ocaml-extlib-1.7.8/src/extList.mli --- old/ocaml-extlib-1.7.6/src/extList.mli 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extList.mli 2021-01-20 00:51:04.000000000 +0100 @@ -31,6 +31,11 @@ module List : sig + type 'a t = 'a list +#if OCAML >= 408 + = [] | (::) of 'a * 'a list +#endif + (** {6 New functions} *) val init : int -> (int -> 'a) -> 'a list @@ -85,17 +90,36 @@ [f ai = Some bi] (when [f] returns [None], the corresponding element of [l] is discarded). *) - val find_map : ('a -> 'b option) -> 'a list -> 'b - (** [find_map pred list] finds the first element of [list] for which + val find_map_exn : ('a -> 'b option) -> 'a list -> 'b + (** [find_map_exn pred list] finds the first element of [list] for which [pred element] returns [Some r]. It returns [r] immediately once found or raises [Not_found] if no element matches the - predicate. See also {!filter_map}. *) + predicate. See also {!filter_map}. + This function was called [find_map] prior to extlib 1.7.7, but had to + be renamed to stay compatible with OCaml 4.10. + *) + + val find_map_opt : ('a -> 'b option) -> 'a list -> 'b option + (** same as find_map_exn but returning option *) + + val find_map : ('a -> 'b option) -> 'a list -> 'b option + (** same as find_map_opt *) val split_nth : int -> 'a list -> 'a list * 'a list (** [split_nth n l] returns two lists [l1] and [l2], [l1] containing the first [n] elements of [l] and [l2] the others. Raise [Invalid_index] if [n] is outside of [l] size bounds. *) + val filteri : (int -> 'a -> bool) -> 'a list -> 'a list + (** Same as {!List.filter}, but the predicate is applied to the index of + the element as first argument (counting from 0), and the element + itself as second argument. + *) + + val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b list -> 'a * 'c list + (** [fold_left_map] is a combination of [fold_left] and [map] that threads an + accumulator through calls to [f] *) + val remove : 'a list -> 'a -> 'a list (** [remove l x] returns the list [l] without the first element [x] found or returns [l] if no element is equal to [x]. Elements are compared @@ -251,6 +275,51 @@ val of_seq : 'a Seq.t -> 'a list #endif +#if OCAML >= 412 + val partition_map : ('a -> ('b, 'c) Either.t) -> 'a list -> 'b list * 'c list + (** [partition_map f l] returns a pair of lists [(l1, l2)] such that, + for each element [x] of the input list [l]: + - if [f x] is [Left y1], then [y1] is in [l1], and + - if [f x] is [Right y2], then [y2] is in [l2]. + + The output elements are included in [l1] and [l2] in the same + relative order as the corresponding input elements in [l]. + + In particular, [partition_map (fun x -> if f x then Left x else Right x) l] + is equivalent to [partition f l]. + + This function was introduced in OCaml 4.12.0, and is _not_ implemented in extlib for older OCaml versions + *) +#endif + + val concat_map : ('a -> 'b list) -> 'a list -> 'b list + +val equal : ('a -> 'a -> bool) -> 'a list -> 'a list -> bool +(** [equal eq [a1; ...; an] [b1; ..; bm]] holds when + the two input lists have the same length, and for each + pair of elements [ai], [bi] at the same position we have + [eq ai bi]. + + Note: the [eq] function may be called even if the + lists have different length. If you know your equality + function is costly, you may want to check {!compare_lengths} + first. +*) + +val compare : ('a -> 'a -> int) -> 'a list -> 'a list -> int +(** [compare cmp [a1; ...; an] [b1; ...; bm]] performs + a lexicographic comparison of the two input lists, + using the same ['a -> 'a -> int] interface as {!Stdlib.compare}: + + - [a1 :: l1] is smaller than [a2 :: l2] (negative result) + if [a1] is smaller than [a2], or if they are equal (0 result) + and [l1] is smaller than [l2] + - the empty list [[]] is strictly smaller than non-empty lists + + Note: the [cmp] function will be called even if the lists have + different lengths. +*) + (** {6 Exceptions} *) exception Empty_list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/extString.ml new/ocaml-extlib-1.7.8/src/extString.ml --- old/ocaml-extlib-1.7.6/src/extString.ml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/extString.ml 2021-01-20 00:51:04.000000000 +0100 @@ -213,24 +213,22 @@ done #endif -(* fold_left and fold_right by Eric C. Cooper *) -let fold_left f init str = - let n = String.length str in - let rec loop i result = +let fold_left = + let rec loop str f i n result = if i = n then result - else loop (i + 1) (f result str.[i]) + else + loop str f (i + 1) n (f result (String.unsafe_get str i)) in - loop 0 init + fun f init str -> loop str f 0 (String.length str) init -let fold_right f str init = - let n = String.length str in - let rec loop i result = +let fold_right = + let rec loop str f i result = if i = 0 then result else let i' = i - 1 in - loop i' (f str.[i'] result) + loop str f i' (f (String.unsafe_get str i') result) in - loop n init + fun f str init -> loop str f (String.length str) init (* explode and implode from the OCaml Expert FAQ. *) let explode s = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/src/refList.ml new/ocaml-extlib-1.7.8/src/refList.ml --- old/ocaml-extlib-1.7.6/src/refList.ml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/src/refList.ml 2021-01-20 00:51:04.000000000 +0100 @@ -116,12 +116,12 @@ let index pred rl = let index = ref (-1) in - let _ = List.find (fun it -> incr index; pred it; ) !rl in + List.find (fun it -> incr index; pred it; ) !rl; !index let index_of rl item = let index = ref (-1) in - let _ = List.find (fun it -> incr index; it = item; ) !rl in + List.find (fun it -> incr index; it = item; ) !rl; !index let at_index rl pos = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/test/Makefile new/ocaml-extlib-1.7.8/test/Makefile --- old/ocaml-extlib-1.7.6/test/Makefile 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/test/Makefile 2021-01-20 00:51:04.000000000 +0100 @@ -6,7 +6,7 @@ TESTS := $(wildcard test_*.ml) ifdef minimal -TESTS := $(filter-out test_Unzip.ml test_UChar.ml test_UTF8.ml, $(TESTS)) +TESTS := $(filter-out test_Base64.ml test_Unzip.ml test_UChar.ml test_UTF8.ml, $(TESTS)) endif all: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-extlib-1.7.6/test/test_ExtList.ml new/ocaml-extlib-1.7.8/test/test_ExtList.ml --- old/ocaml-extlib-1.7.6/test/test_ExtList.ml 2019-05-27 02:26:37.000000000 +0200 +++ new/ocaml-extlib-1.7.8/test/test_ExtList.ml 2021-01-20 00:51:04.000000000 +0100 @@ -123,36 +123,36 @@ assert (a = b) done -let test_find_map () = +let test_find_map_exn () = let f = function "this", v -> Some v | _ -> None in (try - let r = List.find_map f [ "a", 1; "b", 2; "this", 3; "d", 4 ] in + let r = List.find_map_exn f [ "a", 1; "b", 2; "this", 3; "d", 4 ] in assert (3 = r); - let r = List.find_map f [ "this", 1; "b", 2; "c", 3; "d", 4 ] in + let r = List.find_map_exn f [ "this", 1; "b", 2; "c", 3; "d", 4 ] in assert (1 = r); - let r = List.find_map f [ "a", 1; "b", 2; "c", 3; "this", 4 ] in + let r = List.find_map_exn f [ "a", 1; "b", 2; "c", 3; "this", 4 ] in assert (4 = r); - let r = List.find_map f [ "this", 1; "b", 2; "c", 3; "this", 4 ] in + let r = List.find_map_exn f [ "this", 1; "b", 2; "c", 3; "this", 4 ] in assert (1 = r); - let r = List.find_map f [ "a", 1; "b", 2; "this", 3; "this", 4 ] in + let r = List.find_map_exn f [ "a", 1; "b", 2; "this", 3; "this", 4 ] in assert (3 = r); - let r = List.find_map f [ "this", 5 ] in + let r = List.find_map_exn f [ "this", 5 ] in assert (5 = r) with Not_found -> assert false ); (try - ignore (List.find_map f []); assert false + ignore (List.find_map_exn f []); assert false with Not_found -> () ); (try - ignore (List.find_map f [ "a", 1 ]); assert false + ignore (List.find_map_exn f [ "a", 1 ]); assert false with Not_found -> () ); (try - ignore (List.find_map f [ "a", 1; "b", 2 ]); assert false + ignore (List.find_map_exn f [ "a", 1; "b", 2 ]); assert false with Not_found -> () ) @@ -172,6 +172,6 @@ "fold_right", test_fold_right; "fold_right2", test_fold_right2; "map", test_map; - "find_map", test_find_map; + "find_map_exn", test_find_map_exn; "make", test_make; ] ++++++ ocaml-extlib.patch ++++++ --- /dev/null +++ b/dune-project @@ -0,0 +1,2 @@ +(lang dune 1.0) +(name extlib) --- a/src/configure.ml +++ b/src/configure.ml @@ -1,18 +1,17 @@ open Printf -let show_bytes s = - let (_:int) = Sys.command (sprintf "ocamlfind query -format %s bytes" (Filename.quote s)) in () - let () = match Sys.argv with | [|_;"-cppo-args"|] -> let version = Scanf.sscanf Sys.ocaml_version "%d.%d." (fun major minor -> major * 100 + minor) in - printf "-D \\\"OCAML %d\\\"\n" version; - print_endline (if Sys.word_size = 32 then "-D WORD_SIZE_32 " else ""); - show_bytes "-D WITH_BYTES"; + printf "-D\n"; + printf "OCAML %d\n" version; + if Sys.word_size = 32 then (print_endline "-D"; print_endline "WORD_SIZE_32 "); + print_endline "-D"; + print_endline "WITH_BYTES"; exit 0 | [|_;"-compile-args"|] -> if Sys.ocaml_version >= "4.00.0" then print_endline "-bin-annot"; - show_bytes "-package bytes"; + print_endline "-package bytes"; exit 0 | _ -> failwith "not gonna happen" --- /dev/null +++ b/src/dune @@ -0,0 +1,18 @@ +(library + (name extlib) + (public_name extlib) + (modules :standard \ configure install uChar uTF8) + (flags :standard -w -3-6-9-27-32-33-35-39-50) + (preprocess + (action + (run %{bin:cppo} %{read-lines:compat-level} %{input-file}))) + (wrapped false)) + +(rule + (targets compat-level) + (deps + (:< configure.ml)) + (action + (with-stdout-to + %{targets} + (run ocaml %{<} -cppo-args)))) --- a/src/refList.ml +++ b/src/refList.ml @@ -116,12 +116,12 @@ module Index = struct let index pred rl = let index = ref (-1) in - List.find (fun it -> incr index; pred it; ) !rl; + let _ = List.find (fun it -> incr index; pred it; ) !rl in !index let index_of rl item = let index = ref (-1) in - List.find (fun it -> incr index; it = item; ) !rl; + let _ = List.find (fun it -> incr index; it = item; ) !rl in !index let at_index rl pos =
