Skip to content

Commit

Permalink
V3 (#933)
Browse files Browse the repository at this point in the history
* Changelog: add review information for #768

* remove exceptions in BatVect.{exists,for_all}

* remove exceptions in BatVect.find

Implementing BatVect.find_opt makes this more efficient (we have at
most one allocation for the result, instead of using exception
handlers for each left subtree), but the function is not exposed
publicly.

* BatVect: expose find_opt and harmonize variable names in .mli section

* remove exceptions in BatVect.Make.{for_all,exists}

* remove exceptions in BatVect.Make.find

* tests for BatVect.Make functions

* expose BatVect.Make.find_opt

* less exceptions in batVect: changelog entry

* Makefile: introduce a QTEST_SEED variable to set qtest random seed

To reproduce a failure that may depend on the seed 1234, you may use

    make test QTEST_SEED=1345

* Fix some issues in the README

* Fix compilation with OCaml 4.05.0

* Fixes based on @gasche's comments

* Add support for new APIs

* Update for compatibility with qcheck 0.6

Unfortunately this does break backwards compatibility with qcheck 0.5,
so there is now an explicit opam dependency on qcheck >= 0.6.

Fixes #756.

* Simplify dependency restriction on qtest

* batText: add tests and fix a bug in `rindex{,_from}`

* batText: add tests for contains_from and fix documentation bug (exception name)

* batText: add tests to rcontains_from and fix bug in passing

* battext changes: ChangeLog entry

* batNum: handle negatives in of_float_string

* ChangeLog entry on BatNum.of_float_string

* BatNum.of_float_string: extra testcase

* Backport new 4.05 functions (#779)

* Backport the new option-returning *_opt functions from 4.05.0

* Bigarray.Array0 cannot be backported from 4.05

(it depends on a runtime change)

* batList: backport compare_length{s,_with} to <4.5 versions

* Printexc.raise_with_backtrace cannot be backported from 4.05

This is a new primitive from the runtime.

* Change entry for #777, #779

* batBytes: minor compatibility fix

* release summary (#782)

* add a "num" dependency to mirror upstream opam file (#783)

See ocaml/opam-repository#9341

Note that, if/when "num" is split off the standard distribution, there
will be the question of keeping it or not in Batteries. It could be
come a separate package (batteries-num, depending on batteries) for
example.

* next release will be 2.7.0

* simplification to the opam file so that it is easier to compare with the one in the opam repository

* added note explaining that BatX is also Batteries.X

* substitued the for a

* added explanation for case when Batteries is opened

* added example illustrating the BatX -> Batteries.X mapping.

For an example, I think it's better to use module that's not listed in the
"Extensions to the Standard Library" section.  That section has its own
specialized message about opening Batteries.  Using a module from this
section as an illustration has a slight risk of suggesting to users
that the BatX->Batteries.X point applies only to this section.

* safe-string: make Lexing safe

* safe-string: make Big_int safe

* safe-string: make Buffer safe

* safe-string: make Digest safe

* safe-string: make Genlex safe

* safe-string: make IO safe

* safe-string: make Format safe

* safe-string: make Int32 safe

* safe-string: make Marshal safe

* safe-string: make Pervasives safe

* safe-string: make Printf safe

* safe-string: make String safe (but String.Cap)

* safe-string: adapt String.Cap

* safe-string: make Unix safe

* safe-string: make Base64 safe

* safe-string: make BitSet safe

* safe-string: make Substring safe

* safe-string: make Text safe

* _tags: actually enforce safe_string

* safe-string: make BatBytes safe

* -safe-string: Changelog

* [minor] exclude compattest.ml from qtest

(Otherwise you cannot run the tests for an OCaml version that does not
pass the compat-test.)

* add 4.06-only Array.Floatarray primitive module

* add 4.06-only Uchar.t functions in Buffer

It would be nicer to make sure that BatUChar is a superset of the
stdlib Uchar module, and that the two types are compatible, but that
requires more work.

* 4.06 Bigarray functions

* 4.06 Unix functions

* 4.06: Changes entry

* fix more FloatArray failures in the test targets

* added BatString.count_char

* added count_string

* safe-string: fix compatibility with OCaml <=4.02

The safe-string compatibility fixes rely on the Bytes package, which
we convincingly mock under OCaml<=4.02, but also on bytes-adapted
functions or just convenience functions that are useful for code
porting: Buffer.add_subbytes, String.init, etc.

Before this commit, the codebase would simply not build on OCaml<=4.02
because of this. What the commit does is to introduce a new module,
BatBytesCompat, meant to contain backward-compatibility implementation
of those functions.

* a prebaked patch to try our inline tests on older OCaml versions

The following command should get Batteries (temporarily) testable with
old qtest versions:

    git apply build/make-our-inline-tests-compatible-with-older-OCaml-versions.patch

* mention count_string

* Revert "added count_string"

This reverts commit 1171462.

The idea is to do the next minor release without the count_* functions
that are not yet ready for inclusion. The commit should be merged back
right after the release.

* missing @SInCE tags

* update scripts/replace_since.sh

* refresh @SInCE NEXT_RELEASE tags with new version

* bump _oasis version number

* Update setup.ml based on _oasis

* Revert "mention count_string"

This reverts commit 0ae9a35.

This has to be pushed again after v2.8.0, in the right Changelog section

* batString: safe-string-ready map_first_char

* first commit after v2.8.0

* Revert "Revert "added count_string""

This reverts commit 10e2dd1.

* Revert "Revert "mention count_string""

This reverts commit bc10ba1.

* move count_string's ChangeLog entry into the new section

* BatInt.Safe_int.mul performance improvements

The fast-path was made less expensive, by getting rid of absolute value
computation (which incurs branching). The downside is that the fast-path
supports only non-negative integers from now on.

* Add ChangeLog entry

* disable print_string_cap_ro/rw to match #673

* Fix: incorrect behaviour of Map.union

In case of binding conflicts, [Map.union m1 m2] should prefer the
value from [m2], as stated in documentation.

* Add a test case for Map.union

* Add ChangeLog entry

* added BatSeq.{to_buffer|to_string|of_string}

* Cosmetic tweaks in BatMap.mli

* Document that Map.extract can raise Not_found. (#825)

* added BatArray.split

* updated ChangeLog

*  Clarified documentation for `next` in LazyList (#810)

* Revised docs for seq, unfold, from_loop in LazyList (#806)

seq: Revised basic description to fit first part of from_loop doc,
which seems clearer.  Also added note that you can create an infinite
list by passing a function that constantly returns true.

from_loop: Gave additional detail about what the next function
is supposed to do, and noted that its result pair might contain
different types.  Added a simple example where the types are
the same.  (This example could be done more simpy using seq.
I still don't understand the purpose of from_loop.)

I moved seq before from_loop because it's a more basic version of this
kind of operation.  from_loop is more specialized, and complicated,
but its name might suggest that it's the normal way of making a lazy
list by repeated application of a function.  Users should see seq
first before trying to work out what from_loop is for.

* improve MultiPMap documentation (#827)

* simpler (and faster?) implementation of BatArray.partition (#829)

* simpler and faster implementation of BatArray.partition (at the cost of using more memory)

* updated changelog

* removed previously added exception types

* updated ocamldoc for BatSeq.of_string

* Compile Batteries with -no-alias-deps

The size cost of using batteries has always been a problem. OCaml 4.02
introduced --no-deps-libs for this exact purpose (see
http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#s%3Amodule-alias).

I couldn't find any discussion relative to this but I'm well aware this is
unlikely to not have been considered already.

Simple test:

```
  % cat toto1.ml
  open Batteries
  let () = Printf.printf "hello\n"
  % cat toto2.ml
  let () = BatPrintf.printf "hello\n"
  % for f in toto1 toto2 ; do \
      ocamlfind ocamlopt $f.ml -o $f.opt -package batteries -linkpkg ;
    done
  % ls -l toto*opt
```

Before the patch:

```
  -rwxr-xr-x 1 rixed 5272428 Feb  7 05:43 toto1.opt*
  -rwxr-xr-x 1 rixed 2006588 Feb  7 05:43 toto2.opt*
```

After:

```
  -rwxr-xr-x 1 rixed 3098452 Feb  7 05:38 toto1.opt*
  -rwxr-xr-x 1 rixed 2006588 Feb  7 05:38 toto2.opt*
```

That's a 40% reduction in size of a program using only BatPrintf from
Batteries, still bigger than a program using explicitly only BatPrintf
because of batPervasives, I assume.

There are several ways i can imagine this patch would break other programs:

- it might break the build of some programs relying on some of their direct
  dependencies to link in others of their direct dependencies, which I would
  qualify as a bug in those builds;

- this could prevent the dynamic linkage of some plugins if it expects the
  whole of batteries to be available from the main program;

- programs relying on any side effects of some otherwise unused batteries
  module initialization code, but that sounds very unlikely.

Note that I'm not familiar with this option so there might be others, more
obvious issues. I'm confident you will know :-)

Note: I have no idea if/how the "pack" option that seems to be present in the
setup.ml could be used for the same purpose.

* Fix: Map.update was broken

Searching for the node to update was broken, as the keys were compared in wrong order.

* Fix: Map.update did not throw an exception on failure

The docstring says "@raise Not_found if [k1] is not bound in [m]",
but there was no raise if [k1] and [k2] were different.

* Fix: Set.update did not throw an exception on failure

The docstring says "@raise Not_found if [x] is not in [s]",
but there was no raise if [x] and [y] were different.

* Fix typo

* Simplify Set.cartesian_product

* Remove a redundant exception from BatOption.ml

* Simplify Text.concat

* Fix typos (#838)

* Fix: Array.insert error message improvement

The function now throws a more relevant message on invalid indices
instead of the generic [invalid_arg "index out of bounds].

The assertion is now documented.

* Implementation of Array.insert now uses unsafe_{get,set}

* Do not depend upon bisect any longer

Rational: bisect is not very actively maintained any more and code coverage
have not been useful (or is not useful any more).

* Corrected documentation for batList {last, hd} (#840)

* Fix docstring of String.right (#849)

* Fix docstring of String.right

* BatInt.Safe_int.mul performance improvements

The previous overflow test from CERT C is notable for avoiding an overflow
while checking for overflow; hovewer, since overflows are perfectly defined
in OCaml, a shorter test from Hacker's Delight is a better option.

* Update ChangeLog

* A clean-up of invalid_arg uses

This patch makes uses of `invalid_arg` more uniform, fixing the following kinds of irregularities:
* Lack of module name in a message (e.g. `Enum.arg_min` threw "arg_min");
* Lack of function name in a message (e.g. `List.reduce` threw "Empty list");
* Wrong module name in a message (e.g. `PathGen` functions threw messages with "Path");
* Wrong function name in a message (e.g. `List.fold_left2` threw a message with "fold_right2");
* Minor style issues: capitalization, punctuation, "Bat" prefixes;
* Use of `raise (Invalid_argument "...")` instead of `invalid_arg "..."`.

* Add ChangeLog entry

* Restructuring of Heap.del_min

Utility functions [find_min_tree] and [del_min_tree] are extended with
an additional argument so as to make it more obvious to the reader that
error messages are correct.

* Optimization of List.unique_cmp

A set should be more efficient than [bool PMap.t].

* Add ChangeLog entry

* Fix docstrings of List.append and List.concat

Stack usage estimates are invalid.

* BatString.ml should use unsafe versions of set and get

* batString: annotate unsafe_{get,set} with static reasoning in comments (partial)

* BatString.ml: annotate unsafe_{get,set} with static assertions

* Remove mention of IO.flush_out that does not exist.

* List.mli: remove erroneous mentions of Different_list_size

* List.ml: clean-up invalid_arg messages

* Add ChangeLog entry

* Add String.cut (#856)

* Add `String.index_after_n : char -> int -> string -> int`

* Add ChangeLog entry for `String.index_after_n`

* fix index_after_n doc

* Add String.cut

* Update documentation for String.{index_after_n,cut}

* Remove spurious empty line before BatString.index_after_n

* Add Changelog entry for String.cut

* Update #856 Changelog with PR number

* Clarify documentation of String.{index_after_n,cut}

* Rename String.cut to cut_on_char

* better exception string in BatString.index_after_n

* better ocamldoc for BatHashtbl.find_default (#859)

* better ocamldoc for BatHashtbl.find_default

so much better with an example

* better ocamldoc for find_default

* Rename cut to cut_on_char in Changelog

* Fix build on OCaml < 4.05

* Fix a regression in BatInt.Safe_int.mul

* Make doc of String.index_from a bit clearer (#864)

* Map.equal used (=) instead of argument

* Changelog entry for #865

* Adding ocamlfind plugin support (#867)

* changelog update for PR 867

* Update batVect.mli

Typo in description of sub. Ordering r m n required to be consistent with function definition

* batInnerWeaktbl: separate interface from Hashtbl for compatibility

* 4.07 compatibility fixes

* testsuite: remove test_interface.ml, subsumed by 'make test-compat'

* beef up Travis checking

* prepare release 2.9.0

* Update setup.ml based on _oasis

* prepare the 2.9.0 release

* Update setup.ml based on _oasis

* first commit after 2.9.0

* extend the Changelog (#877)

* Fix Dllist.skip

skip had the same behavior no matter the sign of the parameter

* batNum: fix the testsuite

* fix a batNum.of_float_sting bug on inputs in ]-1; 0[.

(fixes #886)

* added BatList.fold_while (#889)

* added BatList.fold_while

* Fixing basic typos (#890)

* Gc: add new 4.08 fields

* Array: reorder type and include to avoid error

* re-export Bigarray.*.map_file functions removed in 4.08

* Int32: incorrect primitive names

* Lexing: no support for disabling position-tracking

* Unix: we don't support the new (link ?follow) parameter on older OCamls

* add CI testing for 4.08

* Corrected BatDeque.is_empty documentation.

* Hashtbl merge (#892)

* Addition of Hashtbl.merge and merge_all

Closes #891

* BatString.count_char uses a while loop instead of fold

* Current module name seems Extlib, not Extlibcompat (#873)

https://github.com/ocaml-batteries-team/batteries-included/blob/master/src/extlib.ml

* Add lazylist equal predicate (#811)

added LazyList.equal

* updated ChangeLog

* get rid of >=4.02 syntax in BatHashtbl.merge

* BatHashtbl: avoid |> when possible

* some more files need preprocessing

Hashtbl.statistics is from 4.00.0 and was used in batInnerWeaktbl.ml{i}

* BatArray: 4.07 compat

* BatBuffer: 4.07 and 4.08 compat

* BatBytes: 4.07 and 4.08 compat

* BatInt32: 4.08 compat

* BatInt64: 4.08 compat

* BatLexing: 4.08 compat

* BatList: 4.08 compat

* BatNativeint: 4.08 compat

* BatPrintexc: 4.08 compat

* BatQueue: 4.07 and 4.08 compat

Note to other maintainers: I am not sure take_opt and peek_opt
should be introduced by preprocessing. Maybe we want them added
to all OCaml versions?

* BatString: 4.08 compat

* BatSys: 4.08 compat

* BatUnix: 4.08 compat

* BatString: to_seq{i} and of_seq are from OCaml 4.07, not 4.08

also added NEXT_RELEASE tag for them

* added missing NEXT_RELEASE tags in many places

* next release will be 2.10.0

* Update setup.ml based on _oasis

* updated opam file with bits from the one in opam-repository

* repaired upload-docs target in Makefile

and make it more readable too

* start of next release

* Fix compilation by BER MetaOCaml (#909)

Set.Infix used to have operators `<.` and `>.` (for strict
subset and strict superset), but `>.` is also used as a code
block end-quote by BER.

It's been decided to jettison the whole BatSet.Infix module,
as a simple and future proof fix.

Ref #908

* Add BatFilename (#910)

Also added `Filename.split_extension`

Closes #445

* s/RELASE/RELEASE (#911)

typos

* Improve toplevel printability of predefined sets (#912)

Redefining the modules (instead of using those predefined
in BatSet) was causing the printers for BatSet.Int and friends
useless.

Closes #750

* Remove BatOo (#915)

As it is undocumented, unsupported and unsafe.

Closes #848

* Make BatSeq.Exceptionless.combine really exceptionless (#917)

Now, BatSeq.Exceptionless.combine returns the longest sequence possible
(stopping when one of the input sequence ends).

Closes #418

* BatString.split_on_char and nsplit must never return an empty list (#918)

BatString.split_on_char behavior matches the one of
Legacy.String.split_on_char, and that nsplit behavior matches the one
of split_on_char.

Closes #845
Closes #846

* Add Legacy.Result for OCaml >= 4.8.0 (#913)

Now, users can pattern match Result.t returned from some library using
Legacy.Result.Error while Batteries is opened.

Ref #839

* List.sum [] is now 0 (#916)

List.sum and List.fsum default to 0 (or 0.0) in case the list is empty.
Previously, this was raising Invalid_argument.

Closes #519

* Remove Legacy.Sort for OCaml >= 4.08 (#926)

Closes #925

* Build with -strict-sequence (#927)

* with_locked_file (#904)

* high level file locking file interface
* with_file_lock: now call user function with the opened file

* Release v2.11.0 (#931)

* Fix batFilename for various old OCaml versions

split_extension was relying on remove_extension and extension functions
that were introduced in OCaml 4.04.0.
Also, an ocaml.deprecated annotation needed to be protected by some
preprocessing.

Tested with most of supported compiler versions.

* Prepare Changelog and NEXT_RELEASE placeholder for v2.11.0

* Update setup.ml based on _oasis

Closes #928

* make Unix.sleepf available under all OCaml versions (#930)

* make Unix.sleepf available across all OCaml versions

* the '|>' operator was not available in old versions of the stdlib (e.g. OCaml 4.0.0)

* BatBytes was missing unsafe_blit_string's signature to compile on 4.09.0

* provide signatures of new functions from 4.09.0 in BatPrintexc

* BatSys: change in argv declaration for ocaml >= 4.09.0

* updated opam file

to reflect more the one from opam-repository

* bits for next release

Co-authored-by: Gabriel Scherer <gabriel.scherer@gmail.com>
Co-authored-by: Tej Chajed <tchajed@mit.edu>
Co-authored-by: Anton Yabchinskiy <arn@bestmx.net>
Co-authored-by: Max Mouratov <mmouratov@gmail.com>
Co-authored-by: Milo <iitalics@gmail.com>
Co-authored-by: Thibault Suzanne <thi.suzanne@gmail.com>
Co-authored-by: Marshall Abrams <mars0i@users.noreply.github.com>
Co-authored-by: sapristi <megabigfoutoir@gmail.com>
Co-authored-by: FkHina <36575050+FkHina@users.noreply.github.com>
Co-authored-by: Ralf Vogler <ralf.vogler@gmail.com>
Co-authored-by: Arlen Cox <arlencox@gmail.com>
Co-authored-by: Francois Berenger <unixjunkie@sdf.org>
Co-authored-by: yaseersheriff <yaseer.sheriff@gmail.com>
Co-authored-by: Virgile Robles <virgile.robles@protonmail.ch>
Co-authored-by: Fourchaux <jprodi04@gmail.com>
Co-authored-by: Zachary Palmer <zepalmer@users.noreply.github.com>
Co-authored-by: Catalin Hritcu <catalin.hritcu@gmail.com>
Co-authored-by: Armaël Guéneau <Armael@users.noreply.github.com>
  • Loading branch information
19 people committed Jan 9, 2020
1 parent aef397f commit 2ddbb72
Show file tree
Hide file tree
Showing 19 changed files with 237 additions and 41 deletions.
43 changes: 43 additions & 0 deletions ChangeLog
Expand Up @@ -47,6 +47,45 @@ Changelog
#679
(Cedric Cellier)

## v2.11.0 (minor release)

This minor release fixes a few bugs or interface mismatch with OCaml stdlib,
and is compatible with BER MetaOCaml.

This is the last planned release of the v2 series.
Next planned release (v3.0.0) will introduce some API changes.

Notable changes:

- Add Unix.with_locked_file
#904
(Simon Cruanes, Cedric Cellier, review by Francois Berenger)

- Build with -strict-sequence
#927
(Armaël Guéneau, review by Francois Berenger)

- Add Legacy.Result for OCaml >= 4.8.0
#913
(Cedric Cellier, review by Francois Berenger)

- Remove BatOo
#915
(Cedric Cellier, review by Francois Berenger)

- Add BatFilename
#910
(Cedric Cellier, review by Francois Berenger)

- Make batteries usable with BER MetaOCaml
#909
(Cedric Cellier, review by Francois Berenger and Gabriel Scherer)

- Unix.sleepf is provided across all OCaml versions;
previously it was only for OCaml >= 4.03.0
#930
(Francois Berenger, review by Cedric Cellier)

## v2.10.0 (minor release)

This minor release adds support for OCaml 4.08.0.
Expand Down Expand Up @@ -79,6 +118,10 @@ recommend trying the 'stdcompat' library.
#891
(Cedric Cellier, Francois Berenger, Gabriel Scherer)

- added Unix.with_locked_file
#904
(Cedric Cellier, Francois Berenger)

## v2.9.0 (minor release)

This minor release adds support for OCaml 4.07.0, as well as a certain
Expand Down
2 changes: 1 addition & 1 deletion _tags
Expand Up @@ -12,4 +12,4 @@ true: package(bytes), warn_-3, bin_annot
<src/batOpaqueInnerSys.*>: opaque
true: safe_string
true: no_alias_deps

true: strict_sequence
4 changes: 2 additions & 2 deletions opam
Expand Up @@ -9,7 +9,7 @@ authors: "OCaml batteries-included team"
homepage: "http://batteries.forge.ocamlcore.org/"
bug-reports: "https://github.com/ocaml-batteries-team/batteries-included/issues"
dev-repo: "git://github.com/ocaml-batteries-team/batteries-included.git"
license: "LGPL-2.1+ with OCaml linking exception"
license: "LGPL-2.1-or-later with OCaml-LGPL-linking-exception"
doc: "http://ocaml-batteries-team.github.io/batteries-included/hdoc2/"
build: [
["ocaml" "setup.ml" "-configure" "--prefix" prefix]
Expand All @@ -18,7 +18,7 @@ build: [
install: [make "install"]
remove: ["ocamlfind" "remove" "batteries"]
depends: [
"ocaml" {>= "3.12.1"}
"ocaml" {>= "4.00.0" & < "4.10.0"}
"ocamlfind" {build & >= "1.5.3"}
"ocamlbuild" {build}
"qtest" {with-test & >= "2.5"}
Expand Down
6 changes: 3 additions & 3 deletions setup.ml
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.2.0 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: 8eacb5fc3c01b3f2ec2fa94f8db2c52a) *)
(* DO NOT EDIT (digest: c538dc9cea7562212bf9319fabb10941) *)
(*
Regenerated by OASIS v0.4.11
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -6742,7 +6742,7 @@ let setup_t =
{
oasis_version = "0.4";
ocaml_version = Some (OASISVersion.VGreaterEqual "3.12.1");
version = "2.10.0";
version = "2.11.0";
license =
OASISLicense.DEP5License
(OASISLicense.DEP5Unit
Expand Down Expand Up @@ -7019,7 +7019,7 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.11";
oasis_digest = Some "\031B\"\198\141\157`Yd\200\159F\169\162\127\022";
oasis_digest = Some "\197\026\147\198c\239\0223\026_)\201>2\152\150";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
Expand Down
2 changes: 2 additions & 0 deletions src/batBytes.mliv
Expand Up @@ -666,3 +666,5 @@ let s = Bytes.of_string "hello"

##V<4.4##external unsafe_fill : t -> int -> int -> char -> unit = "caml_fill_string" "noalloc"
##V>=4.4##external unsafe_fill: t -> int -> int -> char -> unit = "caml_fill_bytes" "noalloc"

##V>=4.09##external unsafe_blit_string : string -> int -> bytes -> int -> int -> unit = "caml_blit_string" "noalloc"
49 changes: 33 additions & 16 deletions src/batFilename.mliv
Expand Up @@ -30,7 +30,7 @@ val parent_dir_name : string

val dir_sep : string
(** The directory separator (e.g. [/] in Unix).
@since NEXT_RELEASE and OCaml 3.11.2 *)
@since 2.11.0 and OCaml 3.11.2 *)

val concat : string -> string -> string
(** [concat dir file] returns a file name that designates file
Expand Down Expand Up @@ -73,7 +73,7 @@ val chop_suffix : string -> string -> string
##V>=4.8## this does not match exactly the interpretation of case-insensitive
##V>=4.8## filename equivalence from Windows.
##V>=4.8##
##V>=4.8## @since NEXT_RELEASE and OCaml 4.08
##V>=4.8## @since 2.11.0 and OCaml 4.08
##V>=4.8##*)


Expand All @@ -89,7 +89,7 @@ val chop_suffix : string -> string -> string
##V>=4.4## If such a suffix does not exist, [extension name] is the empty
##V>=4.4## string.
##V>=4.4##
##V>=4.4## @since NEXT_RELEASE and OCaml 4.04
##V>=4.4## @since 2.11.0 and OCaml 4.04
##V>=4.4##*)

##V>=4.4##val remove_extension : string -> string
Expand All @@ -101,7 +101,7 @@ val chop_suffix : string -> string -> string
##V>=4.4##
##V>=4.4## [remove_extension s ^ extension s = s]
##V>=4.4##
##V>=4.4## @since NEXT_RELEASE and OCaml 4.04
##V>=4.4## @since 2.11.0 and OCaml 4.04
##V>=4.4##*)

val chop_extension : string -> string
Expand Down Expand Up @@ -141,22 +141,22 @@ val temp_file : ?temp_dir: string -> string -> string -> string
*)

val open_temp_file :
?mode: open_flag list -> ?perms: int -> ?temp_dir: string -> string ->
string -> string * out_channel
?mode: open_flag list ->
##V>4.2## ?perms: int ->
?temp_dir: string -> string ->
string -> string * out_channel
(** Same as {!Filename.temp_file}, but returns both the name of a fresh
temporary file, and an output channel opened (atomically) on
this file. This function is more secure than [temp_file]: there
is no risk that the temporary file will be modified (e.g. replaced
by a symbolic link) before the program opens it. The optional argument
[mode] is a list of additional flags to control the opening of the file.
It can contain one or several of [Open_append], [Open_binary],
and [Open_text]. The default is [[Open_text]] (open in text mode). The
file is created with permissions [perms] (defaults to readable and
writable only by the file owner, [0o600]).
and [Open_text]. The default is [[Open_text]] (open in text mode).
##V>4.2## The file is created with permissions [perms] (defaults to readable and
##V>4.2## writable only by the file owner, [0o600]).

@raise Sys_error if the file could not be opened.
@before 4.03.0 no ?perms optional argument
@before 3.11.2 no ?temp_dir optional argument
*)

##V>=4.0##val get_temp_dir_name : unit -> string
Expand All @@ -166,24 +166,24 @@ val open_temp_file :
##V>=4.0## Under Windows, the value of the [TEMP] environment variable, or "."
##V>=4.0## if the variable is not set.
##V>=4.0## The temporary directory can be changed with {!Filename.set_temp_dir_name}.
##V>=4.0## @since NEXT_RELEASE and OCaml 4.00.0
##V>=4.0## @since 2.11.0 and OCaml 4.00.0
##V>=4.0##*)

##V>=4.0##val set_temp_dir_name : string -> unit
##V>=4.0##(** Change the temporary directory returned by {!Filename.get_temp_dir_name}
##V>=4.0## and used by {!Filename.temp_file} and {!Filename.open_temp_file}.
##V>=4.0## @since NEXT_RELEASE and OCaml 4.00.0
##V>=4.0## @since 2.11.0 and OCaml 4.00.0
##V>=4.0##*)

val temp_dir_name : string
[@@ocaml.deprecated "Use Filename.get_temp_dir_name instead"]
##V>=4.2## [@@ocaml.deprecated "Use Filename.get_temp_dir_name instead"]
(** The name of the initial temporary directory:
Under Unix, the value of the [TMPDIR] environment variable, or "/tmp"
if the variable is not set.
Under Windows, the value of the [TEMP] environment variable, or "."
if the variable is not set.
@deprecated You should use {!Filename.get_temp_dir_name} instead.
@since NEXT_RELEASE and OCaml 3.09.1
@since 2.11.0 and OCaml 3.09.1
*)

val quote : string -> string
Expand Down Expand Up @@ -226,9 +226,26 @@ val quote : string -> string
##V>4.9## Raise [Failure] if the command cannot be escaped on the current platform.
##V>4.9##*)

##V<4.4## val extension : string -> string
##V<4.4##(* extension name is the shortest suffix ext of name0 where:
##V<4.4##
##V<4.4## - name0 is the longest suffix of name that does not contain a directory separator;
##V<4.4## - ext starts with a period;
##V<4.4## - ext is preceded by at least one non-period character in name0.
##V<4.4## If such a suffix does not exist, extension name is the empty string.
##V<4.4##
##V<4.4## @since 2.11.0 *)

##V<4.4## val remove_extension : string -> string
##V<4.4##(* Return the given file name without its extension, as defined in
##V<4.4## Filename.extension. If the extension is empty, the function returns
##V<4.4## the given file name.
##V<4.4##
##V<4.4## @since 2.11.0 *)

val split_extension : string -> string * string
(** [split_extension s] returns both the filename [s] without its extension
and its extension in two distinct strings.
For instance, [split_extension "foo.bar"] returns the pair ["foo",".bar"].

@since NEXT_RELEASE *)
@since 2.11.0 *)
31 changes: 31 additions & 0 deletions src/batFilename.ml → src/batFilename.mlv
Expand Up @@ -21,6 +21,37 @@

include Filename

##V<4.4## let is_dir_sep name i =
##V<4.4## try
##V<4.4## for j = 0 to String.length dir_sep - 1 do
##V<4.4## if i + j >= String.length name ||
##V<4.4## name.[i + j] != dir_sep.[j] then raise Exit
##V<4.4## done;
##V<4.4## true
##V<4.4## with Exit ->
##V<4.4## false
##V<4.4##
##V<4.4## let extension_len name =
##V<4.4## let rec check i0 i =
##V<4.4## if i < 0 || is_dir_sep name i then 0
##V<4.4## else if name.[i] = '.' then check i0 (i - 1)
##V<4.4## else String.length name - i0
##V<4.4## in
##V<4.4## let rec search_dot i =
##V<4.4## if i < 0 || is_dir_sep name i then 0
##V<4.4## else if name.[i] = '.' then check i (i - 1)
##V<4.4## else search_dot (i - 1)
##V<4.4## in
##V<4.4## search_dot (String.length name - 1)
##V<4.4##
##V<4.4## let remove_extension name =
##V<4.4## let l = extension_len name in
##V<4.4## if l = 0 then name else String.sub name 0 (String.length name - l)
##V<4.4##
##V<4.4## let extension name =
##V<4.4## let l = extension_len name in
##V<4.4## if l = 0 then "" else String.sub name (String.length name - l) l

let split_extension s =
remove_extension s, extension s

Expand Down
2 changes: 1 addition & 1 deletion src/batGc.mliv
Expand Up @@ -356,7 +356,7 @@ val finalise : ('a -> unit) -> 'a -> unit
##V>=4.4## finalisation function attached with `GC.finalise` are always
##V>=4.4## called before the finalisation function attached with `GC.finalise_last`.
##V>=4.4##
##V>=4.4## @since NEXT_RELEASE and OCaml 4.04
##V>=4.4## @since 2.11.0 and OCaml 4.04
##V>=4.4##*)

val finalise_release : unit -> unit;;
Expand Down
6 changes: 3 additions & 3 deletions src/batIO.mli
Expand Up @@ -951,7 +951,7 @@ module Incubator : sig
?last:string ->
?sep:string ->
?indent:int ->
(Format.formatter -> 'a -> 'b) -> Format.formatter -> 'a array -> unit
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a array -> unit
(** Print the contents of an array, with [first] preceding the first item
(default: ["\[|"]), [last] following the last item (default: ["|\]"])
and [sep] separating items (default: ["; "]). A printing function must
Expand All @@ -972,7 +972,7 @@ module Incubator : sig
?last:string ->
?sep:string ->
?indent:int ->
(Format.formatter -> 'a -> 'b) -> Format.formatter -> 'a BatEnum.t -> unit
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a BatEnum.t -> unit
(** Print the contents of an enum, with [first] preceding the first item
(default: [""]), [last] following the last item (default: [""])
and [sep] separating items (default: [" "]). A printing function must
Expand All @@ -992,7 +992,7 @@ module Incubator : sig
?last:string ->
?sep:string ->
?indent:int ->
(Format.formatter -> 'a -> 'b) -> Format.formatter -> 'a list -> unit
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a list -> unit
(** Print the contents of a list, with [first] preceding the first item
(default: ["\["]), [last] following the last item (default: ["\]"])
and [sep] separating items (default: ["; "]). A printing function must
Expand Down
2 changes: 1 addition & 1 deletion src/batInnerPervasives.mlv
Expand Up @@ -58,7 +58,7 @@ let ok = function

let wrap f x = try Ok (f x) with ex -> Error ex

let forever f x = ignore (while true do f x done)
let forever f x = ignore (while true do ignore (f x) done)

let ignore_exceptions f x = try ignore (f x) with _ -> ()

Expand Down
2 changes: 1 addition & 1 deletion src/batLazyList.ml
Expand Up @@ -106,7 +106,7 @@ let make n x =

let iter f l =
let rec aux l = match next l with
| Cons (x, t) -> (f x; aux t)
| Cons (x, t) -> (ignore (f x); aux t)
| Nil -> ()
in aux l

Expand Down
4 changes: 2 additions & 2 deletions src/batList.mliv
Expand Up @@ -299,13 +299,13 @@ val min : 'a list -> 'a
val sum : int list -> int
(** [sum l] returns the sum of the integers of [l].
Returns [0] on the empty list.
Note: prior to NEXT_RELEASE, used to raise Invalid_argument on the empty list.
Note: prior to 2.11.0, used to raise Invalid_argument on the empty list.
*)

val fsum : float list -> float
(** [fsum l] returns the sum of the floats of [l].
Returns [0.] on the empty list.
Note: prior to NEXT_RELEASE, used to raise Invalid_argument on the empty list.
Note: prior to 2.11.0, used to raise Invalid_argument on the empty list.
*)

val favg : float list -> float
Expand Down
16 changes: 15 additions & 1 deletion src/batPrintexc.mliv
Expand Up @@ -325,7 +325,7 @@ val print : _ BatInnerIO.output -> exn -> unit
##V>=4.4## raw_backtrace_slot -> raw_backtrace_slot option
##V>=4.4##(** [get_raw_backtrace_next_slot slot] returns the next slot inlined, if any.
##V>=4.4##
##V>=4.4## @since NEXT_RELEASE and OCaml 4.04
##V>=4.4## @since 2.11.0 and OCaml 4.04
##V>=4.4##*)


Expand All @@ -348,3 +348,17 @@ val print : _ BatInnerIO.output -> exn -> unit

##V>=4.08##type t = exn = ..
##V>=4.08##(** The type of exception values. *)

##V>=4.09##val use_printers: exn -> string option
##V>=4.09##(** [Printexc.use_printers e] returns [None] if there are no registered
##V>=4.09## printers and [Some s] with else as the resulting string otherwise.
##V>=4.09##
##V>=4.09## @since 2.11.0 and OCaml 4.09
##V>=4.09##*)

##V>=4.09##val to_string_default: exn -> string
##V>=4.09##(** [Printexc.to_string_default e] returns a string representation of the
##V>=4.09## exception [e], ignoring all registered exception printers.
##V>=4.09##
##V>=4.09## @since 2.11.0 and OCaml 4.09
##V>=4.09##*)
4 changes: 2 additions & 2 deletions src/batRefList.ml
Expand Up @@ -121,12 +121,12 @@ module Index = struct

let index pred rl =
let index = ref (-1) in
List.find (fun it -> incr index; pred it; ) !rl;
ignore (List.find (fun it -> incr index; pred it; ) !rl);
!index

let index_of rl item =
let index = ref (-1) in
List.find (fun it -> incr index; it = item; ) !rl;
ignore (List.find (fun it -> incr index; it = item; ) !rl);
!index

let at_index rl pos = List.nth !rl pos
Expand Down

0 comments on commit 2ddbb72

Please sign in to comment.