diff -Nru uutf-1.0.1/CHANGES.md uutf-1.0.2/CHANGES.md --- uutf-1.0.1/CHANGES.md 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/CHANGES.md 2019-02-05 20:29:14.000000000 +0000 @@ -1,4 +1,10 @@ -v1.0.1 2016-03-07 La Forclaz (VS) +v1.0.2 2019-02-05 La Forclaz (VS) +--------------------------------- + +- Fix the substring folding functionality introduced in v1.0.0. + It never worked correctly. + +v1.0.1 2017-03-07 La Forclaz (VS) --------------------------------- - OCaml 4.05.0 compatibility (removal of `Uchar.dump`). diff -Nru uutf-1.0.1/debian/changelog uutf-1.0.2/debian/changelog --- uutf-1.0.1/debian/changelog 2018-05-21 10:12:35.000000000 +0000 +++ uutf-1.0.2/debian/changelog 2020-01-29 08:49:01.000000000 +0000 @@ -1,3 +1,12 @@ +uutf (1.0.2-1) unstable; urgency=medium + + * New upstream release + * Bump debhelper compat level to 12 + * Bump Standards-Version to 4.5.0 + * Add Rules-Requires-Root: no + + -- Stéphane Glondu Wed, 29 Jan 2020 09:49:01 +0100 + uutf (1.0.1-2) unstable; urgency=medium * Bump minimal required version of OCaml to 4.03 diff -Nru uutf-1.0.1/debian/compat uutf-1.0.2/debian/compat --- uutf-1.0.1/debian/compat 2018-05-10 11:55:29.000000000 +0000 +++ uutf-1.0.2/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -11 diff -Nru uutf-1.0.1/debian/control uutf-1.0.2/debian/control --- uutf-1.0.1/debian/control 2018-05-21 10:11:46.000000000 +0000 +++ uutf-1.0.2/debian/control 2020-01-29 08:49:01.000000000 +0000 @@ -6,12 +6,17 @@ Mehdi Dogguy , Stéphane Glondu Build-Depends: - debhelper (>= 11), - ocaml-nox (>= 4.03~), - ocaml-findlib (>= 1.2.4), + debhelper-compat (= 12), + ocaml-nox, + ocaml-findlib, ocamlbuild, - dh-ocaml (>= 0.9) -Standards-Version: 4.1.4 + libtopkg-ocaml-dev, + libuchar-ocaml-dev, + libcmdliner-ocaml-dev, + opam-installer, + dh-ocaml +Standards-Version: 4.5.0 +Rules-Requires-Root: no Homepage: http://erratique.ch/software/uutf Vcs-Git: https://salsa.debian.org/ocaml-team/uutf.git Vcs-Browser: https://salsa.debian.org/ocaml-team/uutf diff -Nru uutf-1.0.1/debian/copyright uutf-1.0.2/debian/copyright --- uutf-1.0.1/debian/copyright 2018-05-10 10:54:23.000000000 +0000 +++ uutf-1.0.2/debian/copyright 2020-01-29 08:49:01.000000000 +0000 @@ -1,36 +1,19 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Source: http://erratique.ch/software/uutf +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Files: * -Copyright: © 2012 Daniel C. Bünzli -License: BSD-3-clause - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: +Copyright: © 2012-2016 Daniel C. Bünzli +License: ISC + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. . - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - . - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the - distribution. - . - 3. Neither the name of the Daniel C. Bünzli nor the names of - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Files: debian/* Copyright: © 2015 Mehdi Dogguy diff -Nru uutf-1.0.1/debian/libuutf-ocaml-dev.docs uutf-1.0.2/debian/libuutf-ocaml-dev.docs --- uutf-1.0.1/debian/libuutf-ocaml-dev.docs 1970-01-01 00:00:00.000000000 +0000 +++ uutf-1.0.2/debian/libuutf-ocaml-dev.docs 2020-01-29 08:49:01.000000000 +0000 @@ -0,0 +1 @@ +doc/uutf/* diff -Nru uutf-1.0.1/debian/libuutf-ocaml-dev.install.in uutf-1.0.2/debian/libuutf-ocaml-dev.install.in --- uutf-1.0.1/debian/libuutf-ocaml-dev.install.in 2018-05-10 10:54:23.000000000 +0000 +++ uutf-1.0.2/debian/libuutf-ocaml-dev.install.in 2020-01-29 08:49:01.000000000 +0000 @@ -1,5 +1,8 @@ +bin/* usr/bin +@OCamlStdlibDir@/uutf/*opam* @OCamlStdlibDir@/uutf/*.mli @OCamlStdlibDir@/uutf/*.cmi +@OCamlStdlibDir@/uutf/*.cmt* OPT: @OCamlStdlibDir@/uutf/*.a OPT: @OCamlStdlibDir@/uutf/*.cmx OPT: @OCamlStdlibDir@/uutf/*.cmxa diff -Nru uutf-1.0.1/debian/patches/0001-Uchar-is-a-standard-module-in-OCaml-4.03.patch uutf-1.0.2/debian/patches/0001-Uchar-is-a-standard-module-in-OCaml-4.03.patch --- uutf-1.0.1/debian/patches/0001-Uchar-is-a-standard-module-in-OCaml-4.03.patch 2018-05-21 10:04:39.000000000 +0000 +++ uutf-1.0.2/debian/patches/0001-Uchar-is-a-standard-module-in-OCaml-4.03.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -From: Mehdi Dogguy -Date: Mon, 21 May 2018 11:42:58 +0200 -Subject: Uchar is a standard module in OCaml >= 4.03 - ---- - _tags | 4 ++-- - pkg/META | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/_tags b/_tags -index 1bfe0bf..0f025cc 100644 ---- a/_tags -+++ b/_tags -@@ -1,7 +1,7 @@ --true : bin_annot, safe_string, package(bytes), package(uchar) -+true : bin_annot, safe_string, package(bytes) - - : include - - : include - : package(unix), package(cmdliner) -- : package(unix) -\ No newline at end of file -+ : package(unix) -diff --git a/pkg/META b/pkg/META -index 4c4d20d..60bbf2c 100644 ---- a/pkg/META -+++ b/pkg/META -@@ -1,6 +1,6 @@ - version = "1.0.1" - description = "Non-blocking streaming Unicode codec for OCaml" --requires = "bytes uchar" -+requires = "bytes" - archive(byte) = "uutf.cma" - archive(native) = "uutf.cmxa" - plugin(byte) = "uutf.cma" diff -Nru uutf-1.0.1/debian/patches/series uutf-1.0.2/debian/patches/series --- uutf-1.0.1/debian/patches/series 2018-05-21 10:04:09.000000000 +0000 +++ uutf-1.0.2/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -0001-Uchar-is-a-standard-module-in-OCaml-4.03.patch diff -Nru uutf-1.0.1/debian/rules uutf-1.0.2/debian/rules --- uutf-1.0.1/debian/rules 2018-05-10 10:54:23.000000000 +0000 +++ uutf-1.0.2/debian/rules 2020-01-29 08:49:01.000000000 +0000 @@ -2,43 +2,25 @@ # -*- makefile -*- DESTDIR=$(CURDIR)/debian/tmp -MODULE_NAME=uutf include /usr/share/ocaml/ocamlvars.mk -OCAMLFIND_DESTDIR=$(DESTDIR)/$(OCAML_STDLIB_DIR)/$(MODULE_NAME) -export OCAMLFIND_DESTDIR - -TARGETS=$(MODULE_NAME).cmi $(MODULE_NAME).cma -ifeq ($(OCAML_BEST),opt) -TARGETS+=$(MODULE_NAME).a $(MODULE_NAME).cmx $(MODULE_NAME).cmxa -ifeq ($(OCAML_NATDYNLINK),yes) -TARGETS+=$(MODULE_NAME).cmxs -endif -endif - -TO_INSTALL=$(addprefix _build/src/,$(TARGETS)) pkg/META src/$(MODULE_NAME).mli %: dh $@ --with ocaml -.PHONY: override_dh_auto_configure -override_dh_auto_configure: +override_dh_auto_clean: + ocaml pkg/pkg.ml clean -.PHONY: override_dh_auto_build override_dh_auto_build: - ocamlbuild -classic-display $(TARGETS) + ocaml pkg/pkg.ml build --with-cmdliner true --tests true -.PHONY: override_dh_auto_test override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + ocaml pkg/pkg.ml test +endif -.PHONY: override_dh_auto_install override_dh_auto_install: - mkdir -p '$(OCAMLFIND_DESTDIR)' - cp $(TO_INSTALL) '$(OCAMLFIND_DESTDIR)' + opam-installer --prefix=$(DESTDIR) --libdir=.$(OCAML_STDLIB_DIR) uutf.install + rm -f $(DESTDIR)/doc/uutf/LICENSE.md -.PHONY: override_dh_install -override_dh_install: - dh_install --fail-missing - -.PHONY: override_dh_auto_clean -override_dh_auto_clean: - ocamlbuild -classic-display -clean +override_dh_missing: + dh_missing --fail-missing diff -Nru uutf-1.0.1/debian/watch uutf-1.0.2/debian/watch --- uutf-1.0.1/debian/watch 2018-05-10 10:54:23.000000000 +0000 +++ uutf-1.0.2/debian/watch 2020-01-29 08:49:01.000000000 +0000 @@ -1,2 +1,2 @@ version=3 -http://erratique.ch/software/uutf/releases/ .*uutf-(.+)\.tbz +https://erratique.ch/software/uutf/releases/ .*uutf-(.+)\.tbz diff -Nru uutf-1.0.1/opam uutf-1.0.2/opam --- uutf-1.0.1/opam 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/opam 2019-02-05 20:29:14.000000000 +0000 @@ -1,15 +1,15 @@ -version: "1.0.1" -opam-version: "1.2" +version: "1.0.2" +opam-version: "2.0" maintainer: "Daniel Bünzli " authors: ["Daniel Bünzli "] homepage: "http://erratique.ch/software/uutf" doc: "http://erratique.ch/software/uutf/doc/Uutf" -dev-repo: "http://erratique.ch/repos/uutf.git" +dev-repo: "git+http://erratique.ch/repos/uutf.git" bug-reports: "https://github.com/dbuenzli/uutf/issues" tags: [ "unicode" "text" "utf-8" "utf-16" "codec" "org:erratique" ] license: "ISC" -available: [ ocaml-version >= "4.01.0"] depends: [ + "ocaml" {>= "4.01.0"} "ocamlfind" {build} "ocamlbuild" {build} "topkg" {build} diff -Nru uutf-1.0.1/pkg/META uutf-1.0.2/pkg/META --- uutf-1.0.1/pkg/META 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/pkg/META 2019-02-05 20:29:14.000000000 +0000 @@ -1,4 +1,4 @@ -version = "1.0.1" +version = "1.0.2" description = "Non-blocking streaming Unicode codec for OCaml" requires = "bytes uchar" archive(byte) = "uutf.cma" diff -Nru uutf-1.0.1/README.md uutf-1.0.2/README.md --- uutf-1.0.1/README.md 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/README.md 2019-02-05 20:29:14.000000000 +0000 @@ -1,6 +1,6 @@ Uutf — Non-blocking streaming Unicode codec for OCaml ------------------------------------------------------------------------------- -v1.0.1 +v1.0.2 Uutf is a non-blocking streaming codec to decode and encode the UTF-8, UTF-16, UTF-16LE and UTF-16BE encoding schemes. It can efficiently diff -Nru uutf-1.0.1/src/uutf.ml uutf-1.0.2/src/uutf.ml --- uutf-1.0.1/src/uutf.ml 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/src/uutf.ml 2019-02-05 20:29:14.000000000 +0000 @@ -1,7 +1,7 @@ (*--------------------------------------------------------------------------- Copyright (c) 2012 Daniel C. Bünzli. All rights reserved. Distributed under the ISC license, see terms at the end of the file. - uutf v1.0.1 + uutf v1.0.2 ---------------------------------------------------------------------------*) let io_buffer_size = 65536 (* IO_BUFFER_SIZE 4.0.0 *) @@ -722,53 +722,48 @@ 'a -> int -> [ `Uchar of Uchar.t | `Malformed of string ] -> 'a let fold_utf_8 ?(pos = 0) ?len f acc s = - let rec loop acc f s i l = - if i = l then acc else + let rec loop acc f s i last = + if i > last then acc else let need = unsafe_array_get utf_8_len (unsafe_byte s i) in - if need = 0 then loop (f acc i (malformed s i 1)) f s (i + 1) l else - let rem = l - i in + if need = 0 then loop (f acc i (malformed s i 1)) f s (i + 1) last else + let rem = last - i + 1 in if rem < need then f acc i (malformed s i rem) else - loop (f acc i (r_utf_8 s i need)) f s (i + need) l + loop (f acc i (r_utf_8 s i need)) f s (i + need) last in - let len = match len with - | None -> String.length s - pos - | Some l -> l - in - loop acc f (Bytes.unsafe_of_string s) pos len + let len = match len with None -> String.length s - pos | Some l -> l in + let last = pos + len - 1 in + loop acc f (Bytes.unsafe_of_string s) pos last let fold_utf_16be ?(pos = 0) ?len f acc s = - let rec loop acc f s i l = - if i = l then acc else - let rem = l - i in + let rec loop acc f s i last = + if i > last then acc else + let rem = last - i + 1 in if rem < 2 then f acc i (malformed s i 1) else match r_utf_16 s i (i + 1) with - | `Uchar _ | `Malformed _ as v -> loop (f acc i v) f s (i + 2) l + | `Uchar _ | `Malformed _ as v -> loop (f acc i v) f s (i + 2) last | `Hi hi -> if rem < 4 then f acc i (malformed s i rem) else - loop (f acc i (r_utf_16_lo hi s (i + 2) (i + 3))) f s (i + 4) l - in - let len = match len with - | None -> String.length s - pos - | Some l -> l + loop (f acc i (r_utf_16_lo hi s (i + 2) (i + 3))) f s (i + 4) last in - loop acc f (Bytes.unsafe_of_string s) pos len - - let fold_utf_16le ?(pos = 0) ?len f acc s = (* [fold_utf_16be], bytes swapped. *) - let rec loop acc f s i l = - if i = l then acc else - let rem = l - i in + let len = match len with None -> String.length s - pos | Some l -> l in + let last = pos + len - 1 in + loop acc f (Bytes.unsafe_of_string s) pos last + + let fold_utf_16le ?(pos = 0) ?len f acc s = + (* [fold_utf_16be], bytes swapped. *) + let rec loop acc f s i last = + if i > last then acc else + let rem = last - i + 1 in if rem < 2 then f acc i (malformed s i 1) else match r_utf_16 s (i + 1) i with - | `Uchar _ | `Malformed _ as v -> loop (f acc i v) f s (i + 2) l + | `Uchar _ | `Malformed _ as v -> loop (f acc i v) f s (i + 2) last | `Hi hi -> if rem < 4 then f acc i (malformed s i rem) else - loop (f acc i (r_utf_16_lo hi s (i + 3) (i + 2))) f s (i + 4) l - in - let len = match len with - | None -> String.length s - pos - | Some l -> l + loop (f acc i (r_utf_16_lo hi s (i + 3) (i + 2))) f s (i + 4) last in - loop acc f (Bytes.unsafe_of_string s) pos len + let len = match len with None -> String.length s - pos | Some l -> l in + let last = pos + len - 1 in + loop acc f (Bytes.unsafe_of_string s) pos last end module Buffer = struct diff -Nru uutf-1.0.1/src/uutf.mli uutf-1.0.2/src/uutf.mli --- uutf-1.0.1/src/uutf.mli 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/src/uutf.mli 2019-02-05 20:29:14.000000000 +0000 @@ -1,7 +1,7 @@ (*--------------------------------------------------------------------------- Copyright (c) 2012 Daniel C. Bünzli. All rights reserved. Distributed under the ISC license, see terms at the end of the file. - uutf v1.0.1 + uutf v1.0.2 ---------------------------------------------------------------------------*) (** Non-blocking streaming Unicode codec. @@ -20,7 +20,7 @@ See {{:#examples}examples} of use. - {e v1.0.1 — {{:http://erratique.ch/software/uutf }homepage}} + {e v1.0.2 — {{:http://erratique.ch/software/uutf }homepage}} {3 References} {ul diff -Nru uutf-1.0.1/test/test.ml uutf-1.0.2/test/test.ml --- uutf-1.0.1/test/test.ml 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/test/test.ml 2019-02-05 20:29:14.000000000 +0000 @@ -1,7 +1,7 @@ (*--------------------------------------------------------------------------- Copyright (c) 2012 Daniel C. Bünzli. All rights reserved. Distributed under the ISC license, see terms at the end of the file. - uutf v1.0.1 + uutf v1.0.2 ---------------------------------------------------------------------------*) let u_nl = Uchar.of_int 0x000A @@ -208,6 +208,22 @@ [`Uchar u_nl; `Uchar u_nl]); () +let test_sub () = + log "Test Uutf.String.fold_utf_8 substring"; + let trip fold ~pos ~len s = + let b = Buffer.create 100 in + let add _ _ = function + | `Uchar u -> Uutf.Buffer.add_utf_8 b u + | `Malformed _ -> assert false + in + fold ?pos:(Some pos) ?len:(Some len) add () s; + assert (String.sub s pos len = Buffer.contents b); + in + trip Uutf.String.fold_utf_8 ~pos:4 ~len:4 "hop hap mop"; + trip Uutf.String.fold_utf_8 ~pos:0 ~len:1 "hop hap mop"; + trip Uutf.String.fold_utf_8 ~pos:2 ~len:1 "hop"; + () + module Int = struct type t = int let compare : int -> int -> int = compare end module Umap = Map.Make (Uchar) module Bmap = Map.Make (Bytes) @@ -353,6 +369,7 @@ buffer_string_codec_test (); pos_test (); guess_test (); + test_sub (); utf8_test (); is_uchar_test (); log "All tests succeeded.\n" diff -Nru uutf-1.0.1/test/utftrip.ml uutf-1.0.2/test/utftrip.ml --- uutf-1.0.1/test/utftrip.ml 2017-03-07 13:21:41.000000000 +0000 +++ uutf-1.0.2/test/utftrip.ml 2019-02-05 20:29:14.000000000 +0000 @@ -1,7 +1,7 @@ (*--------------------------------------------------------------------------- Copyright (c) 2012 Daniel C. Bünzli. All rights reserved. Distributed under the ISC license, see terms at the end of the file. - uutf v1.0.1 + uutf v1.0.2 ---------------------------------------------------------------------------*) let str = Printf.sprintf @@ -385,7 +385,7 @@ in Term.(pure do_cmd $ cmd $ file $ sin $ sout $ use_unix $ usize $ ienc $ oenc $ nln $ rseed $ rcount), - Term.info "utftrip" ~version:"v1.0.1" ~doc ~man + Term.info "utftrip" ~version:"v1.0.2" ~doc ~man let () = match Term.eval cmd with | `Error _ -> exit 1