Skip to content
Commits on Source (12)
......@@ -8,6 +8,8 @@
*.cma
*.cmxa
*.cmxs
*.cmt
*.cmti
/src/extBytes.mli
/src/doc/*.html
/test/extlib_test
......
S src
S test
B src
B test
......@@ -2,12 +2,31 @@ language: c
sudo: required
install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
script: bash -ex .travis-opam.sh
env:
- OCAML_VERSION=4.00
- OCAML_VERSION=4.01
- OCAML_VERSION=4.02
- OCAML_VERSION=4.03
- OCAML_VERSION=4.04
os:
- linux
- osx
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
os: osx
- env: OCAML_VERSION=4.02
os: linux
- env: OCAML_VERSION=4.03
os: linux
- env: OCAML_VERSION=4.04
os: linux
- env: OCAML_VERSION=4.05
os: linux
- env: OCAML_VERSION=4.06
os: linux
- env: OCAML_VERSION=4.06 OPAM_SWITCH=4.06.1+32bit
os: linux
addons:
apt:
packages:
- gcc-multilib
1.7.6 (2019-03-03)
* fix Dllist.skip with negative argument (Virgile Robles)
* fix IO.read_bits 31 (Dan Korostelev)
1.7.5 (2018-07-08)
* IO: restore compilation on 32-bit (broken in 1.7.3)
* sync with OCaml 4.07
* install.ml is now deprecated, install with Makefile
+ IO: read_i32_as_int
1.7.4 (2018-03-12)
* fix tests with OCaml 4.06
1.7.3 (2018-03-11)
* String: faster slice
* sync with OCaml 4.06 (thx test/std.ml)
* IO: fix sign bug in read_i31
* IO: add write_i31 and bounds-checking on write_i32
* base64: add encode_string decode_string
* install cmt and cmti
1.7.2 (2017-03-29)
* sync with OCaml 4.05
......
The Library is distributed under the terms of the GNU Library General
The Library is distributed under the terms of the GNU Lesser General
Public License version 2 (included below).
As a special exception to the GNU Library General Public License, you
As a special exception to the GNU Lesser General Public License, you
may link, statically or dynamically, a "work that uses the Library"
with a publicly distributed version of the Library to produce an
executable file containing portions of the Library, and distribute
that executable file under terms of your choice, without any of the
additional requirements listed in clause 6 of the GNU Library General
additional requirements listed in clause 6 of the GNU Lesser General
Public License. By "a publicly distributed version of the Library",
we mean either the unmodified Library as distributed, or a
modified version of the Library that is distributed under the
conditions defined in clause 3 of the GNU Library General Public
conditions defined in clause 2 of the GNU Lesser General Public
License. This exception does not however invalidate any other reasons
why the executable file might be covered by the GNU Library General
why the executable file might be covered by the GNU Lesser General
Public License.
------------
......
VERSION:=$(shell git --git-dir=.git describe --always --long)
RELEASE:=1.7.2
RELEASE:=1.7.6
ifndef VERSION
VERSION:=$(RELEASE)
......
......@@ -2,12 +2,12 @@ platform:
- x86
environment:
CYG_ROOT: "C:\\cygwin"
CYG_BASH: "%CYG_ROOT%\\bin\\bash -lc"
FORK_USER: ocaml
FORK_BRANCH: master
CYG_ROOT: C:\cygwin64
install:
- appveyor DownloadFile https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/appveyor-opam.sh
- "%CYG_ROOT%\\setup-x86.exe -qnNdO -R %CYG_ROOT% -s http://cygwin.mirror.constant.com -l C:/cygwin/var/cache/setup -P rsync -P patch -P diffutils -P make -P unzip -P git -P m4 -P perl -P mingw64-x86_64-gcc-core"
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/$env:FORK_USER/ocaml-ci-scripts/$env:FORK_BRANCH/appveyor-install.ps1"))
build_script:
- "%CYG_BASH% '${APPVEYOR_BUILD_FOLDER}/appveyor-opam.sh'"
- call %CYG_ROOT%\bin\bash.exe -l %APPVEYOR_BUILD_FOLDER%\appveyor-opam.sh
extlib (1.7.2-2) UNRELEASED; urgency=medium
extlib (1.7.6-1) unstable; urgency=medium
[ Stéphane Glondu ]
* New upstream release
* Remove Lifeng from Uploaders (Closes: #925072)
* Update Vcs-*
* Bump Standards-Version to 4.4.0
* Bump debhelper compat level to 12
-- Stéphane Glondu <glondu@debian.org> Thu, 08 Aug 2019 09:33:14 +0200
extlib (1.7.2-1) unstable; urgency=low
* Team upload.
* New upstream release.
- Update ocamldoc generation.
* standards-version 4.1.1 (no change)
[ Andy Li ]
* Add dh_missing --fail-missing.
* Add autopkgtest support.
-- Andy Li <andy@onthewings.net> Tue, 28 Nov 2017 14:30:15 +0800
-- Stéphane Glondu <glondu@debian.org> Fri, 09 Aug 2019 14:10:38 +0200
extlib (1.7.0-3) unstable; urgency=medium
......@@ -371,4 +367,3 @@ extlib (1.0b-1) unstable; urgency=low
* Initial Release (Closes: Bug#213127).
-- Stefano Zacchiroli <zack@debian.org> Fri, 3 Oct 2003 23:55:57 +0200
......@@ -5,7 +5,7 @@ Maintainer: Debian OCaml Maintainers <debian-ocaml-maint@lists.debian.org>
Uploaders:
Stéphane Glondu <glondu@debian.org>
Build-Depends:
debhelper (>= 9),
debhelper (>= 12),
ocaml-nox (>= 4.00.1),
cppo,
ocaml-findlib (>= 1.5.1),
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ocaml-extlib
Upstream-Contact: ygrek <ygrek@autistici.org>
Source: https://github.com/ygrek/ocaml-extlib
......
@OCamlStdlibDir@/extlib/*.cmi
@OCamlStdlibDir@/extlib/*.cmt
@OCamlStdlibDir@/extlib/*.cmti
@OCamlStdlibDir@/extlib/*.ml*
OPT: @OCamlStdlibDir@/extlib/*.a
OPT: @OCamlStdlibDir@/extlib/*.cmx
......
# see the doc target in Makefile
-pp "cppo $(ocaml src/configure.ml | tr '\n' ' ')"
\ No newline at end of file
-pp "cppo $(ocaml src/configure.ml -cppo-args | tr '\n' ' ' | tr -d '\\' )"
abort-on-upstream-changes
unapply-patches
opam-version: "1.2"
opam-version: "2.0"
maintainer: "ygrek@autistici.org"
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"
......@@ -21,15 +22,17 @@ authors: [
]
build: [
[make "minimal=1" "build"]
[make "test"] {with-test}
[make "doc"] {with-doc}
]
install: [ [make "minimal=1" "install"] ]
build-doc: [ [make "doc"] ]
build-test: [ [make "test"] ]
remove: [
["ocamlfind" "remove" "extlib"]
]
depends: [
"ocaml"
"ocamlfind" {build}
"cppo" {build}
"base-bytes" {build}
]
flags: light-uninstall
......@@ -494,19 +494,26 @@ let read_i16 i =
else
n
let read_i32 ch =
let sign_bit_i32 = lnot 0x7FFF_FFFF
let read_32 ~i31 ch =
let ch1 = read_byte ch in
let ch2 = read_byte ch in
let ch3 = read_byte ch in
let ch4 = read_byte ch in
if ch4 land 128 <> 0 then begin
if ch4 land 64 = 0 then raise (Overflow "read_i32");
ch1 lor (ch2 lsl 8) lor (ch3 lsl 16) lor ((ch4 land 127) lsl 24)
if i31 && ch4 land 64 = 0 then raise (Overflow "read_i31");
ch1 lor (ch2 lsl 8) lor (ch3 lsl 16) lor ((ch4 land 127) lsl 24) lor sign_bit_i32
end else begin
if ch4 land 64 <> 0 then raise (Overflow "read_i32");
if i31 && ch4 land 64 <> 0 then raise (Overflow "read_i31");
ch1 lor (ch2 lsl 8) lor (ch3 lsl 16) lor (ch4 lsl 24)
end
let read_i31 ch = read_32 ~i31:true ch
let read_i32_as_int ch = read_32 ~i31:false ch
let read_i32 = read_i31
let read_real_i32 ch =
let ch1 = read_byte ch in
let ch2 = read_byte ch in
......@@ -559,12 +566,24 @@ let write_i16 ch n =
else
write_ui16 ch n
let write_i32 ch n =
let write_32 ch n =
write_byte ch n;
write_byte ch (n lsr 8);
write_byte ch (n lsr 16);
write_byte ch (n asr 24)
let write_i31 ch n =
#ifndef WORD_SIZE_32
if n < -0x4000_0000 || n > 0x3FFF_FFFF then raise (Overflow "write_i31");
#endif
write_32 ch n
let write_i32 ch n =
#ifndef WORD_SIZE_32
if n < -0x8000_0000 || n > 0x7FFF_FFFF then raise (Overflow "write_i32");
#endif
write_32 ch n
let write_real_i32 ch n =
let base = Int32.to_int n in
let big = Int32.to_int (Int32.shift_right_logical n 24) in
......@@ -602,19 +621,26 @@ let read_i16 i =
else
n
let read_i32 ch =
let sign_bit_i32 = lnot 0x7FFF_FFFF
let read_32 ~i31 ch =
let ch4 = read_byte ch in
let ch3 = read_byte ch in
let ch2 = read_byte ch in
let ch1 = read_byte ch in
if ch4 land 128 <> 0 then begin
if ch4 land 64 = 0 then raise (Overflow "read_i32");
ch1 lor (ch2 lsl 8) lor (ch3 lsl 16) lor ((ch4 land 127) lsl 24)
if i31 && ch4 land 64 = 0 then raise (Overflow "read_i31");
ch1 lor (ch2 lsl 8) lor (ch3 lsl 16) lor ((ch4 land 127) lsl 24) lor sign_bit_i32
end else begin
if ch4 land 64 <> 0 then raise (Overflow "read_i32");
if i31 && ch4 land 64 <> 0 then raise (Overflow "read_i31");
ch1 lor (ch2 lsl 8) lor (ch3 lsl 16) lor (ch4 lsl 24)
end
let read_i31 ch = read_32 ~i31:true ch
let read_i32_as_int ch = read_32 ~i31:false ch
let read_i32 = read_i31
let read_real_i32 ch =
let big = Int32.shift_left (Int32.of_int (read_byte ch)) 24 in
let ch3 = read_byte ch in
......@@ -651,12 +677,24 @@ let write_i16 ch n =
else
write_ui16 ch n
let write_i32 ch n =
let write_32 ch n =
write_byte ch (n asr 24);
write_byte ch (n lsr 16);
write_byte ch (n lsr 8);
write_byte ch n
let write_i31 ch n =
#ifndef WORD_SIZE_32
if n < -0x4000_0000 || n > 0x3FFF_FFFF then raise (Overflow "write_i31");
#endif
write_32 ch n
let write_i32 ch n =
#ifndef WORD_SIZE_32
if n < -0x8000_0000 || n > 0x7FFF_FFFF then raise (Overflow "write_i32");
#endif
write_32 ch n
let write_real_i32 ch n =
let base = Int32.to_int n in
let big = Int32.to_int (Int32.shift_right_logical n 24) in
......@@ -714,7 +752,7 @@ let rec read_bits b n =
end else begin
let k = read_byte b.ch in
if b.nbits >= 24 then begin
if n >= 31 then raise Bits_error;
if n > 31 then raise Bits_error;
let c = 8 + b.nbits - n in
let d = b.bits land ((1 lsl b.nbits) - 1) in
let d = (d lsl (8 - c)) lor (k lsr c) in
......
......@@ -207,9 +207,15 @@ val read_ui16 : input -> int
val read_i16 : input -> int
(** Read a signed 16-bit word. *)
val read_i32 : input -> int
val read_i31 : input -> int
(** Read a signed 32-bit integer. Raise [Overflow] if the
read integer cannot be represented as a Caml 31-bit integer. *)
read integer cannot be represented as an OCaml 31-bit integer. *)
val read_i32 : input -> int
(** Deprecated, same as read_i31 *)
val read_i32_as_int : input -> int
(** Read a signed 32-bit integer, represented as OCaml integer, wrapping around 31-bit int on 32-bit architecture *)
val read_real_i32 : input -> int32
(** Read a signed 32-bit integer as an OCaml int32. *)
......@@ -241,6 +247,9 @@ val write_ui16 : 'a output -> int -> unit
val write_i16 : 'a output -> int -> unit
(** Write a signed 16-bit word. *)
val write_i31 : 'a output -> int -> unit
(** Write a signed 31-bit integer as 4 bytes. *)
val write_i32 : 'a output -> int -> unit
(** Write a signed 32-bit integer. *)
......@@ -272,7 +281,9 @@ sig
val read_ui16 : input -> int
val read_i16 : input -> int
val read_i31 : input -> int
val read_i32 : input -> int
val read_i32_as_int : input -> int
val read_real_i32 : input -> int32
val read_i64 : input -> int64
val read_float32 : input -> float
......@@ -280,6 +291,7 @@ sig
val write_ui16 : 'a output -> int -> unit
val write_i16 : 'a output -> int -> unit
val write_i31 : 'a output -> int -> unit
val write_i32 : 'a output -> int -> unit
val write_real_i32 : 'a output -> int32 -> unit
val write_i64 : 'a output -> int64 -> unit
......
......@@ -9,17 +9,22 @@ ifdef minimal
MODULES := $(filter-out unzip uChar uTF8, $(MODULES))
endif
CPPO_ARGS := $(shell ocaml configure.ml)
CPPO = cppo $(CPPO_ARGS)
CPPO_ARGS := $(shell ocaml configure.ml -cppo-args)
CPPO := cppo $(CPPO_ARGS)
OCAMLC = ocamlfind ocamlc -pp "$(CPPO)" -g -package bytes
OCAMLOPT = ocamlfind ocamlopt -pp "$(CPPO)" -g -package bytes
OCAML_ARGS := -pp "$(CPPO)" -g
OCAML_ARGS += $(shell ocaml configure.ml -compile-args)
OCAMLC = ocamlfind ocamlc $(OCAML_ARGS)
OCAMLOPT = ocamlfind ocamlopt $(OCAML_ARGS)
OCAMLDOC = ocamldoc -pp "$(CPPO)"
MLI = $(filter-out extLib.mli, $(MODULES:=.mli))
CMI = $(MODULES:=.cmi)
CMO = $(MODULES:=.cmo)
CMX = $(MODULES:=.cmx)
CMT = $(MODULES:=.cmt)
CMTI = $(MODULES:=.cmti)
.NOTPARALLEL:
.SUFFIXES:
......@@ -53,7 +58,7 @@ extBytes.mli: extBytes.ml
$(OCAMLC) -i $< > $@
install:
ocamlfind install -patch-version $(VERSION) extlib META extLib.cma $(MLI) $(CMI) -optional extLib.cmxa $(CMX) extLib.cmxs extLib.a extLib.lib
ocamlfind install -patch-version $(VERSION) extlib META extLib.cma $(MLI) $(CMI) -optional extLib.cmxa $(CMX) extLib.cmxs extLib.a extLib.lib $(CMT) $(CMTI)
uninstall:
ocamlfind remove extlib
......
......@@ -119,3 +119,12 @@ let str_encode ?(tbl=chars) s =
let str_decode ?(tbl=inv_chars) s =
let ch = decode ~tbl (IO.input_bytes s) in
IO.nread_string ch ((Bytes.length s * 6) / 8)
let encode_string ?(tbl=chars) s =
let ch = encode ~tbl (IO.output_string ()) in
IO.nwrite_string ch s;
IO.close_out ch
let decode_string ?(tbl=inv_chars) s =
let ch = decode ~tbl (IO.input_string s) in
IO.nread_string ch ((String.length s * 6) / 8)
......@@ -42,12 +42,18 @@ type encoding_table = char array
or -1 if the char is not accepted. *)
type decoding_table = int array
(** Encode a string into Base64. *)
(** erroneous interface, kept for compatibility use [encode_string] instead *)
val str_encode : ?tbl:encoding_table -> string -> Bytes.t
(** erroneous interface, kept for compatibility use [decode_string] instead *)
val str_decode : ?tbl:decoding_table -> Bytes.t -> string
(** Encode a string into Base64. *)
val encode_string : ?tbl:encoding_table -> string -> string
(** Decode a string encoded into Base64, raise [Invalid_char] if a
character in the input string is not a valid one. *)
val str_decode : ?tbl:decoding_table -> Bytes.t -> string
val decode_string : ?tbl:decoding_table -> string -> string
(** Generic base64 encoding over an output. *)
val encode : ?tbl:encoding_table -> 'a IO.output -> 'a IO.output
......