diff -Nru ocaml-re-1.7.3/benchmarks/dune ocaml-re-1.9.0/benchmarks/dune --- ocaml-re-1.7.3/benchmarks/dune 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/benchmarks/dune 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,3 @@ +(executable + (libraries re threads core_bench) + (name benchmark)) diff -Nru ocaml-re-1.7.3/benchmarks/jbuild ocaml-re-1.9.0/benchmarks/jbuild --- ocaml-re-1.7.3/benchmarks/jbuild 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/benchmarks/jbuild 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -(jbuild_version 1) - -(executable - ((libraries (re threads core_bench)) - (name benchmark))) diff -Nru ocaml-re-1.7.3/CHANGES.md ocaml-re-1.9.0/CHANGES.md --- ocaml-re-1.7.3/CHANGES.md 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/CHANGES.md 2019-04-06 07:05:39.000000000 +0000 @@ -1,3 +1,16 @@ +1.9.0 (05-Apr-2019) +------------------- + +* Fix regression in `Re.exec_partial` (#164) +* Mov gen related functions to `Re.Gen` and deprecate the old names (#167) +* Introduce `Re.View` that exposes the internal representation (#163) + +1.8.0 (04-Aug-2018) +------------------- + +* Fix index-out-of-bounds exception in Re.Perl.re (#160) +* Add seq based iterators (#170) + 1.7.3 (05-Mar-2018) ------------------- diff -Nru ocaml-re-1.7.3/debian/changelog ocaml-re-1.9.0/debian/changelog --- ocaml-re-1.7.3/debian/changelog 2018-06-03 20:24:09.000000000 +0000 +++ ocaml-re-1.9.0/debian/changelog 2020-01-09 14:23:13.000000000 +0000 @@ -1,3 +1,13 @@ +ocaml-re (1.9.0-1) unstable; urgency=medium + + * Team upload + * New upstream release + * Bump Standards-Version to 4.4.1 + * Bump debhelper compat level to 12 + * Add Rules-Requires-Root: no + + -- Stéphane Glondu Thu, 09 Jan 2020 15:23:13 +0100 + ocaml-re (1.7.3-2) unstable; urgency=medium * Install library without using opam-installer to avoid a build-deps diff -Nru ocaml-re-1.7.3/debian/compat ocaml-re-1.9.0/debian/compat --- ocaml-re-1.7.3/debian/compat 2018-05-10 10:58:40.000000000 +0000 +++ ocaml-re-1.9.0/debian/compat 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -9 diff -Nru ocaml-re-1.7.3/debian/control ocaml-re-1.9.0/debian/control --- ocaml-re-1.7.3/debian/control 2018-06-03 19:53:48.000000000 +0000 +++ ocaml-re-1.9.0/debian/control 2020-01-09 14:23:13.000000000 +0000 @@ -5,14 +5,15 @@ Uploaders: Mehdi Dogguy Build-Depends: - debhelper (>= 9), - ocaml-nox (>= 3.12.0~), - ocaml-best-compilers, + debhelper-compat (= 12), + ocaml-nox, ocaml-findlib, + ocaml-dune, + libseq-ocaml-dev, libounit-ocaml-dev, - jbuilder, - dh-ocaml (>= 0.9~) -Standards-Version: 3.9.8 + dh-ocaml +Standards-Version: 4.4.1 +Rules-Requires-Root: no Homepage: https://github.com/ocaml/ocaml-re Vcs-Browser: https://salsa.debian.org/ocaml-team/ocaml-re Vcs-Git: https://salsa.debian.org/ocaml-team/ocaml-re.git diff -Nru ocaml-re-1.7.3/debian/copyright ocaml-re-1.9.0/debian/copyright --- ocaml-re-1.7.3/debian/copyright 2018-06-03 09:10:28.000000000 +0000 +++ ocaml-re-1.9.0/debian/copyright 2020-01-09 14:23:13.000000000 +0000 @@ -1,4 +1,4 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Source: https://github.com/ocaml/ocaml-re Files: * diff -Nru ocaml-re-1.7.3/debian/libre-ocaml-dev.doc-base ocaml-re-1.9.0/debian/libre-ocaml-dev.doc-base --- ocaml-re-1.7.3/debian/libre-ocaml-dev.doc-base 2018-06-03 08:35:52.000000000 +0000 +++ ocaml-re-1.9.0/debian/libre-ocaml-dev.doc-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -Document: libre-ocaml-dev -Title: regular expression library for OCaml -Author: Daniel C. Bünzli -Abstract: Documentation of the OCaml RE library -Section: Programming/OCaml - -Format: HTML -Index: /usr/share/doc/libre-ocaml-dev/api/index.html -Files: /usr/share/doc/libre-ocaml-dev/api/* diff -Nru ocaml-re-1.7.3/debian/libre-ocaml-dev.docs ocaml-re-1.9.0/debian/libre-ocaml-dev.docs --- ocaml-re-1.7.3/debian/libre-ocaml-dev.docs 2018-05-30 17:38:15.000000000 +0000 +++ ocaml-re-1.9.0/debian/libre-ocaml-dev.docs 2020-01-09 14:23:13.000000000 +0000 @@ -1,2 +1 @@ -README.md -CHANGES.md +usr/doc/re/* diff -Nru ocaml-re-1.7.3/debian/libre-ocaml-dev.install.in ocaml-re-1.9.0/debian/libre-ocaml-dev.install.in --- ocaml-re-1.7.3/debian/libre-ocaml-dev.install.in 2018-05-30 17:37:06.000000000 +0000 +++ ocaml-re-1.9.0/debian/libre-ocaml-dev.install.in 2020-01-09 14:23:13.000000000 +0000 @@ -1 +1 @@ -usr +usr/lib diff -Nru ocaml-re-1.7.3/debian/rules ocaml-re-1.9.0/debian/rules --- ocaml-re-1.7.3/debian/rules 2018-06-03 20:22:15.000000000 +0000 +++ ocaml-re-1.9.0/debian/rules 2020-01-09 14:23:13.000000000 +0000 @@ -1,24 +1,24 @@ #!/usr/bin/make -f # -*- makefile -*- -DESTDIR=$(CURDIR)/debian/tmp include /usr/share/ocaml/ocamlvars.mk DESTDIR := $(CURDIR)/debian/tmp -export OCAMLFIND_DESTDIR=$(DESTDIR)/$(OCAML_STDLIB_DIR) - -BUILD_PATH=_build/install/default/lib/re %: dh $@ --with ocaml -.PHONY: override_dh_auto_install +override_dh_auto_build: + dune build -p re + +override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) + dune runtest -p re +endif + override_dh_auto_install: - for file in `find $(BUILD_PATH) -type l -printf "%P "`; do \ - mkdir -p $(OCAMLFIND_DESTDIR)/re/`dirname $$file`; \ - cp -L $(BUILD_PATH)/$$file $(OCAMLFIND_DESTDIR)/re/`dirname $$file`/; \ - done - -.PHONY: override_dh_install -override_dh_install: - dh_install --list-missing + dune install --destdir=$(DESTDIR) --prefix=/usr --libdir=..$(OCAML_STDLIB_DIR) + rm -f $(DESTDIR)/usr/doc/re/LICENSE.md + +override_dh_missing: + dh_missing --list-missing diff -Nru ocaml-re-1.7.3/deprecated/dune ocaml-re-1.9.0/deprecated/dune --- ocaml-re-1.7.3/deprecated/dune 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/deprecated/dune 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,47 @@ +(library + (name re_str) + (public_name re.str) + (wrapped false) + (modules re_str) + (synopsis "Deprecated. Use Re.Str") + (libraries re)) + +(library + (name re_pcre) + (public_name re.pcre) + (wrapped false) + (modules re_pcre) + (synopsis "Deprecated. Use Re.Pcre") + (libraries re)) + +(library + (name re_perl) + (public_name re.perl) + (wrapped false) + (modules re_perl) + (synopsis "Deprecated. Use Re.Perl") + (libraries re)) + +(library + (name re_posix) + (public_name re.posix) + (wrapped false) + (modules re_posix) + (synopsis "Deprecated. Use Re.Posix") + (libraries re)) + +(library + (name re_emacs) + (public_name re.emacs) + (wrapped false) + (modules re_emacs) + (synopsis "Deprecated. Use Re.Emacs") + (libraries re)) + +(library + (name re_glob) + (public_name re.glob) + (wrapped false) + (modules re_glob) + (synopsis "Deprecated. Use Re.Glob") + (libraries re)) diff -Nru ocaml-re-1.7.3/deprecated/jbuild ocaml-re-1.9.0/deprecated/jbuild --- ocaml-re-1.7.3/deprecated/jbuild 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/deprecated/jbuild 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -(jbuild_version 1) - -(library - ((name re_str) - (public_name re.str) - (wrapped false) - (modules (re_str)) - (synopsis "Deprecated. Use Re.Str") - (libraries (re)))) - -(library - ((name re_pcre) - (public_name re.pcre) - (wrapped false) - (modules (re_pcre)) - (synopsis "Deprecated. Use Re.Pcre") - (libraries (re)))) - -(library - ((name re_perl) - (public_name re.perl) - (wrapped false) - (modules (re_perl)) - (synopsis "Deprecated. Use Re.Perl") - (libraries (re)))) - -(library - ((name re_posix) - (public_name re.posix) - (wrapped false) - (modules (re_posix)) - (synopsis "Deprecated. Use Re.Posix") - (libraries (re)))) - -(library - ((name re_emacs) - (public_name re.emacs) - (wrapped false) - (modules (re_emacs)) - (synopsis "Deprecated. Use Re.Emacs") - (libraries (re)))) - -(library - ((name re_glob) - (public_name re.glob) - (wrapped false) - (modules (re_glob)) - (synopsis "Deprecated. Use Re.Glob") - (libraries (re)))) diff -Nru ocaml-re-1.7.3/dune ocaml-re-1.9.0/dune --- ocaml-re-1.7.3/dune 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/dune 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,2 @@ +(env + (_ (flags (:standard -w -50)))) \ No newline at end of file diff -Nru ocaml-re-1.7.3/dune-project ocaml-re-1.9.0/dune-project --- ocaml-re-1.7.3/dune-project 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/dune-project 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,3 @@ +(lang dune 1.0) + +(name re) diff -Nru ocaml-re-1.7.3/dune-workspace.dev ocaml-re-1.9.0/dune-workspace.dev --- ocaml-re-1.7.3/dune-workspace.dev 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/dune-workspace.dev 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,8 @@ +(lang dune 1.0) +;; This file is used by `make all-supported-ocaml-versions` +(context (opam (switch 4.02.3))) +(context (opam (switch 4.03.0))) +(context (opam (switch 4.04.2))) +(context (opam (switch 4.05.0))) +(context (opam (switch 4.06.1))) +(context (opam (switch 4.07.0))) \ No newline at end of file diff -Nru ocaml-re-1.7.3/INSTALL ocaml-re-1.9.0/INSTALL --- ocaml-re-1.7.3/INSTALL 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/INSTALL 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ - -Requirements - - The installation procedure defined in the Makefile requires findlib - (http://www.ocaml-programming.de/packages/documentation/findlib/). - -Installation - -- Compile with "make all". - -- If you have ocamlopt, do also "make opt". - -- Become super-user if necessary and do "make install" - (A "make uninstall" removes the library.) diff -Nru ocaml-re-1.7.3/jbuild-workspace.dev ocaml-re-1.9.0/jbuild-workspace.dev --- ocaml-re-1.7.3/jbuild-workspace.dev 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/jbuild-workspace.dev 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -;; This file is used by `make all-supported-ocaml-versions` -(context ((switch 4.02.3))) -(context ((switch 4.03.0))) -(context ((switch 4.04.2))) -(context ((switch 4.05.0))) -(context ((switch 4.06.0))) \ No newline at end of file diff -Nru ocaml-re-1.7.3/lib/color_map.ml ocaml-re-1.9.0/lib/color_map.ml --- ocaml-re-1.7.3/lib/color_map.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib/color_map.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,34 @@ +(* In reality, this can really be represented as a bool array. + + The representation is best thought of as a list of all chars along with a + flag: + + (a, 0), (b, 1), (c, 0), (d, 0), ... + + characters belonging to the same color are represented by sequnces of + characters with the flag set to 0. +*) + +type t = Bytes.t + +let make () = Bytes.make 257 '\000' + +let flatten cm = + let c = Bytes.create 256 in + let color_repr = Bytes.create 256 in + let v = ref 0 in + Bytes.set c 0 '\000'; + Bytes.set color_repr 0 '\000'; + for i = 1 to 255 do + if Bytes.get cm i <> '\000' then incr v; + Bytes.set c i (Char.chr !v); + Bytes.set color_repr !v (Char.chr i) + done; + (c, Bytes.sub color_repr 0 (!v + 1), !v + 1) + +(* mark all the endpoints of the intervals of the char set with the 1 byte *) +let split s cm = + Cset.iter s ~f:(fun i j -> + Bytes.set cm i '\001'; + Bytes.set cm (j + 1) '\001'; + ) diff -Nru ocaml-re-1.7.3/lib/color_map.mli ocaml-re-1.9.0/lib/color_map.mli --- ocaml-re-1.7.3/lib/color_map.mli 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib/color_map.mli 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,14 @@ +(* Color maps exists to provide an optimization for the regex engine. The fact + that some characters are entirely equivalent for some regexes means that we + can use them interchangeably. + + A color map assigns a color to every character in our character set. Any two + characters with the same color will be treated equivalently by the automaton. +*) +type t + +val make : unit -> t + +val flatten : t -> bytes * bytes * int + +val split : Cset.t -> t -> unit diff -Nru ocaml-re-1.7.3/lib/core.ml ocaml-re-1.9.0/lib/core.ml --- ocaml-re-1.7.3/lib/core.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib/core.ml 2019-04-06 07:05:39.000000000 +0000 @@ -27,31 +27,8 @@ let unknown = -2 let break = -3 -(* Result of a successful match. *) -type groups = - { s : string - (* Input string. Matched strings are substrings of s *) - - ; marks : Automata.mark_infos - (* Mapping from group indices to positions in gpos. group i has positions 2*i - - 1, 2*i + 1 in gpos. If the group wasn't matched, then its corresponding - values in marks will be -1,-1 *) - - ; pmarks : Pmark.Set.t - (* Marks positions. i.e. those marks created with Re.marks *) - - ; gpos : int array - (* Group positions. Adjacent elements are (start, stop) of group match. - indexed by the values in marks. So group i in an re would be the substring: - - start = t.gpos.(marks.(2*i)) - 1 - stop = t.gpos.(marks.(2*i + 1)) - 1 *) - - ; gcount : int - (* Number of groups the regular expression contains. Matched or not *) } - type match_info = - | Match of groups + | Match of Group.t | Failed | Running @@ -82,14 +59,14 @@ (* The whole regular expression *) mutable initial_states : (Category.t * state) list; (* Initial states, indexed by initial category *) - cols : Bytes.t; + colors : Bytes.t; (* Color table *) - col_repr : Bytes.t; + color_repr : Bytes.t; (* Table from colors to one character of this color *) - ncol : int; + ncolor : int; (* Number of colors. *) lnl : int; - (* Color of the last newline *) + (* Color of the last newline. -1 if unnecessary *) tbl : Automata.working_area; (* Temporary table used to compute the first available index when computing a new state *) @@ -106,8 +83,8 @@ type info = { re : re; (* The automata *) - i_cols : Bytes.t; - (* Color table ([x.i_cols = x.re.cols]) + colors : Bytes.t; + (* Color table ([x.colors = x.re.colors]) Shortcut used for performance reasons *) mutable positions : int array; (* Array of mark positions @@ -120,14 +97,14 @@ (****) -let category re c = - if c = -1 then +let category re ~color = + if color = -1 then Category.inexistant (* Special category for the last newline *) - else if c = re.lnl then + else if color = re.lnl then Category.(lastnewline ++ newline ++ not_letter) else - Category.from_char (Bytes.get re.col_repr c) + Category.from_char (Bytes.get re.color_repr color) (****) @@ -149,20 +126,20 @@ real_idx = desc.Automata.State.idx; next = if break_state then dummy_next else Array.make ncol unknown_state; final = []; - desc = desc } + desc } let find_state re desc = try Automata.State.Table.find re.states desc with Not_found -> - let st = mk_state re.ncol desc in + let st = mk_state re.ncolor desc in Automata.State.Table.add re.states desc st; st (**** Match with marks ****) -let delta info cat c st = - let desc = Automata.delta info.re.tbl cat c st.desc in +let delta info cat ~color st = + let desc = Automata.delta info.re.tbl cat color st.desc in let len = Array.length info.positions in if desc.Automata.State.idx = len && len > 0 then begin let pos = info.positions in @@ -171,17 +148,17 @@ end; desc -let validate info (s:string) pos st = - let c = Char.code (Bytes.get info.i_cols (Char.code s.[pos])) in - let cat = category info.re c in - let desc' = delta info cat c st in +let validate info (s:string) ~pos st = + let color = Char.code (Bytes.get info.colors (Char.code s.[pos])) in + let cat = category info.re ~color in + let desc' = delta info cat ~color st in let st' = find_state info.re desc' in - st.next.(c) <- st' + st.next.(color) <- st' (* let rec loop info s pos st = if pos < info.last then - let st' = st.next.(Char.code info.i_cols.[Char.code s.[pos]]) in + let st' = st.next.(Char.code info.cols.[Char.code s.[pos]]) in let idx = st'.idx in if idx >= 0 then begin info.positions.(idx) <- pos; @@ -197,23 +174,24 @@ st *) -let rec loop info (s:string) pos st = +let rec loop info (s:string) ~pos st = if pos < info.last then - let st' = st.next.(Char.code (Bytes.get info.i_cols (Char.code s.[pos]))) in - loop2 info s pos st st' + let st' = st.next.(Char.code (Bytes.get info.colors (Char.code s.[pos]))) in + loop2 info s ~pos st st' else st -and loop2 info s pos st st' = +and loop2 info s ~pos st st' = if st'.idx >= 0 then begin let pos = pos + 1 in if pos < info.last then begin (* It is important to place these reads before the write *) (* But then, we don't have enough registers left to store the right position. So, we store the position plus one. *) - let st'' = st'.next.(Char.code (Bytes.get info.i_cols (Char.code s.[pos]))) in + let st'' = + st'.next.(Char.code (Bytes.get info.colors (Char.code s.[pos]))) in info.positions.(st'.idx) <- pos; - loop2 info s pos st' st'' + loop2 info s ~pos st' st'' end else begin info.positions.(st'.idx) <- pos; st' @@ -222,20 +200,20 @@ info.positions.(st'.real_idx) <- pos + 1; st' end else begin (* Unknown *) - validate info s pos st; - loop info s pos st + validate info s ~pos st; + loop info s ~pos st end -let rec loop_no_mark info s pos last st = +let rec loop_no_mark info s ~pos ~last st = if pos < last then - let st' = st.next.(Char.code (Bytes.get info.i_cols (Char.code s.[pos]))) in + let st' = st.next.(Char.code (Bytes.get info.colors (Char.code s.[pos]))) in if st'.idx >= 0 then - loop_no_mark info s (pos + 1) last st' + loop_no_mark info s ~pos:(pos + 1) ~last st' else if st'.idx = break then st' else begin (* Unknown *) - validate info s pos st; - loop_no_mark info s pos last st + validate info s ~pos st; + loop_no_mark info s ~pos ~last st end else st @@ -244,7 +222,7 @@ try List.assq cat st.final with Not_found -> - let st' = delta info cat (-1) st in + let st' = delta info cat ~color:(-1) st in let res = (st'.Automata.State.idx, Automata.status st') in st.final <- (cat, res) :: st.final; res @@ -268,9 +246,9 @@ (* Special case for the last newline *) re.lnl else - Char.code (Bytes.get re.cols (Char.code s.[pos])) + Char.code (Bytes.get re.colors (Char.code s.[pos])) -let rec handle_last_newline info pos st groups = +let rec handle_last_newline info ~pos st ~groups = let st' = st.next.(info.re.lnl) in if st'.idx >= 0 then begin if groups then info.positions.(st'.idx) <- pos + 1; @@ -279,16 +257,16 @@ if groups then info.positions.(st'.real_idx) <- pos + 1; st' end else begin (* Unknown *) - let c = info.re.lnl in - let real_c = Char.code (Bytes.get info.i_cols (Char.code '\n')) in - let cat = category info.re c in - let desc' = delta info cat real_c st in + let color = info.re.lnl in + let real_c = Char.code (Bytes.get info.colors (Char.code '\n')) in + let cat = category info.re ~color in + let desc' = delta info cat ~color:real_c st in let st' = find_state info.re desc' in - st.next.(c) <- st'; - handle_last_newline info pos st groups + st.next.(color) <- st'; + handle_last_newline info ~pos st ~groups end -let rec scan_str info (s:string) initial_state groups = +let rec scan_str info (s:string) initial_state ~groups = let pos = info.pos in let last = info.last in if (last = String.length s @@ -297,22 +275,22 @@ && String.get s (last - 1) = '\n') then begin let info = { info with last = last - 1 } in - let st = scan_str info s initial_state groups in + let st = scan_str info s initial_state ~groups in if st.idx = break then st else - handle_last_newline info (last - 1) st groups + handle_last_newline info ~pos:(last - 1) st ~groups end else if groups then - loop info s pos initial_state + loop info s ~pos initial_state else - loop_no_mark info s pos last initial_state + loop_no_mark info s ~pos ~last initial_state let match_str ~groups ~partial re s ~pos ~len = let slen = String.length s in let last = if len = -1 then slen else pos + len in let info = - { re = re; i_cols = re.cols; pos = pos; last = last; - positions = + { re ; colors = re.colors; pos ; last + ; positions = if groups then begin let n = Automata.index_count re.tbl + 1 in if n <= 10 then @@ -326,9 +304,11 @@ if pos = 0 then Category.(search_boundary ++ inexistant) else - Category.(search_boundary ++ category re (get_color re s (pos - 1))) in + Category.(search_boundary + ++ category re ~color:(get_color re s (pos - 1))) + in let initial_state = find_initial_state re initial_cat in - let st = scan_str info s initial_state groups in + let st = scan_str info s initial_state ~groups in let res = if st.idx = break || partial then Automata.status st.desc @@ -337,7 +317,8 @@ if last = slen then Category.(search_boundary ++ inexistant) else - Category.(search_boundary ++ category re (get_color re s last)) in + Category.(search_boundary ++ category re ~color:(get_color re s last)) + in let (idx, res) = final info st final_cat in if groups then info.positions.(idx) <- last + 1; res @@ -348,16 +329,16 @@ | Automata.Failed -> Failed | Automata.Running -> Running -let mk_re init cols col_repr ncol lnl group_count = - { initial = init; +let mk_re ~initial ~colors ~color_repr ~ncolor ~lnl ~group_count = + { initial ; initial_states = []; - cols = cols; - col_repr = col_repr; - ncol = ncol; - lnl = lnl; + colors; + color_repr; + ncolor; + lnl; tbl = Automata.create_working_area (); states = Automata.State.Table.create 97; - group_count = group_count } + group_count } (**** Character sets ****) @@ -402,6 +383,28 @@ | Difference of regexp * regexp | Pmark of Pmark.t * regexp +module View = struct + type t = regexp = + Set of Cset.t + | Sequence of regexp list + | Alternative of regexp list + | Repeat of regexp * int * int option + | Beg_of_line | End_of_line + | Beg_of_word | End_of_word | Not_bound + | Beg_of_str | End_of_str + | Last_end_of_line | Start | Stop + | Sem of Automata.sem * regexp + | Sem_greedy of Automata.rep_kind * regexp + | Group of regexp | No_group of regexp | Nest of regexp + | Case of regexp | No_case of regexp + | Intersection of regexp list + | Complement of regexp list + | Difference of regexp * regexp + | Pmark of Pmark.t * regexp + + let view t = t +end + let rec pp fmt t = let open Fmt in let var s re = sexp fmt s pp re in @@ -453,14 +456,7 @@ | Group _ | Nest _ | Pmark (_,_)-> false -(**** Colormap ****) - (*XXX Use a better algorithm allowing non-contiguous regions? *) -let split s cm = - Cset.iter s ~f:(fun i j -> - Bytes.set cm i '\001'; - Bytes.set cm (j + 1) '\001'; - ) let cupper = Cset.union (cseq 'A' 'Z') @@ -477,13 +473,13 @@ let lnl = ref false in let rec colorize regexp = match regexp with - Set s -> split s c + Set s -> Color_map.split s c | Sequence l -> List.iter colorize l | Alternative l -> List.iter colorize l | Repeat (r, _, _) -> colorize r - | Beg_of_line | End_of_line -> split (Cset.csingle '\n') c + | Beg_of_line | End_of_line -> Color_map.split (Cset.csingle '\n') c | Beg_of_word | End_of_word - | Not_bound -> split cword c + | Not_bound -> Color_map.split cword c | Beg_of_str | End_of_str | Start | Stop -> () | Last_end_of_line -> lnl := true @@ -499,21 +495,6 @@ colorize regexp; !lnl -let make_cmap () = Bytes.make 257 '\000' - -let flatten_cmap cm = - let c = Bytes.create 256 in - let col_repr = Bytes.create 256 in - let v = ref 0 in - Bytes.set c 0 '\000'; - Bytes.set col_repr 0 '\000'; - for i = 1 to 255 do - if Bytes.get cm i <> '\000' then incr v; - Bytes.set c i (Char.chr !v); - Bytes.set col_repr !v (Char.chr i) - done; - (c, Bytes.sub col_repr 0 (!v + 1), !v + 1) - (**** Compilation ****) let rec equal x1 x2 = @@ -795,19 +776,19 @@ let compile_1 regexp = let regexp = handle_case false regexp in - let c = make_cmap () in + let c = Color_map.make () in let need_lnl = colorize c regexp in - let (col, col_repr, ncol) = flatten_cmap c in - let lnl = if need_lnl then ncol else -1 in - let ncol = if need_lnl then ncol + 1 else ncol in + let (colors, color_repr, ncolor) = Color_map.flatten c in + let lnl = if need_lnl then ncolor else -1 in + let ncolor = if need_lnl then ncolor + 1 else ncolor in let ids = A.create_ids () in let pos = ref 0 in let (r, kind) = translate ids - `First false false `Greedy pos (ref Cset.CSetMap.empty) col regexp in + `First false false `Greedy pos (ref Cset.CSetMap.empty) colors regexp in let r = enforce_kind ids `First kind r in (*Format.eprintf "<%d %d>@." !ids ncol;*) - mk_re r col col_repr ncol lnl (!pos / 2) + mk_re ~initial:r ~colors ~color_repr ~ncolor ~lnl ~group_count:(!pos / 2) (****) @@ -945,249 +926,177 @@ seq [shortest (rep any); group r] ) -let exec_internal name ?(pos=0) ?(len = -1) ~groups re s = +let exec_internal name ?(pos=0) ?(len = -1) ~partial ~groups re s = if pos < 0 || len < -1 || pos + len > String.length s then invalid_arg name; - match_str ~groups ~partial:false re s ~pos ~len + match_str ~groups ~partial re s ~pos ~len let exec ?pos ?len re s = - match exec_internal "Re.exec" ?pos ?len ~groups:true re s with + match exec_internal "Re.exec" ?pos ?len ~groups:true ~partial:false re s with Match substr -> substr | _ -> raise Not_found let exec_opt ?pos ?len re s = - match exec_internal "Re.exec_opt" ?pos ?len ~groups:true re s with + match exec_internal "Re.exec_opt" ?pos ?len ~groups:true ~partial:false + re s with Match substr -> Some substr | _ -> None let execp ?pos ?len re s = - match exec_internal ~groups:false "Re.execp" ?pos ?len re s with + match exec_internal ~groups:false ~partial:false "Re.execp" ?pos ?len re s with Match _substr -> true | _ -> false let exec_partial ?pos ?len re s = - match exec_internal ~groups:false "Re.exec_partial" ?pos ?len re s with + match exec_internal ~groups:false ~partial:true "Re.exec_partial" + ?pos ?len re s with Match _ -> `Full | Running -> `Partial | Failed -> `Mismatch -module Group = struct - - type t = groups +module Mark = struct - let offset t i = - if 2 * i + 1 >= Array.length t.marks then raise Not_found; - let m1 = t.marks.(2 * i) in - if m1 = -1 then raise Not_found; - let p1 = t.gpos.(m1) - 1 in - let p2 = t.gpos.(t.marks.(2 * i + 1)) - 1 in - (p1, p2) + type t = Pmark.t - let get t i = - let (p1, p2) = offset t i in - String.sub t.s p1 (p2 - p1) + let test (g : Group.t) p = + Pmark.Set.mem p g.pmarks - let start subs i = fst (offset subs i) + let all (g : Group.t) = g.pmarks - let stop subs i = snd (offset subs i) + module Set = Pmark.Set - let test t i = - if 2 * i >= Array.length t.marks then - false - else - let idx = t.marks.(2 * i) in - idx <> -1 + let equal = Pmark.equal - let dummy_offset = (-1, -1) + let compare = Pmark.compare - let all_offset t = - let res = Array.make t.gcount dummy_offset in - for i = 0 to Array.length t.marks / 2 - 1 do - let m1 = t.marks.(2 * i) in - if m1 <> -1 then begin - let p1 = t.gpos.(m1) in - let p2 = t.gpos.(t.marks.(2 * i + 1)) in - res.(i) <- (p1 - 1, p2 - 1) - end - done; - res +end - let dummy_string = "" +type split_token = + [ `Text of string + | `Delim of Group.t + ] - let all t = - let res = Array.make t.gcount dummy_string in - for i = 0 to Array.length t.marks / 2 - 1 do - let m1 = t.marks.(2 * i) in - if m1 <> -1 then begin - let p1 = t.gpos.(m1) in - let p2 = t.gpos.(t.marks.(2 * i + 1)) in - res.(i) <- String.sub t.s (p1 - 1) (p2 - p1) - end - done; - res +module Rseq = struct + let all ?(pos=0) ?len re s : _ Seq.t = + if pos < 0 then invalid_arg "Re.all"; + (* index of the first position we do not consider. + !pos < limit is an invariant *) + let limit = match len with + | None -> String.length s + | Some l -> + if l<0 || pos+l > String.length s then invalid_arg "Re.all"; + pos+l + in + (* iterate on matches. When a match is found, search for the next + one just after its end *) + let rec aux pos () = + if pos >= limit + then Seq.Nil (* no more matches *) + else + match match_str ~groups:true ~partial:false re s + ~pos ~len:(limit - pos) with + | Match substr -> + let p1, p2 = Group.offset substr 0 in + let pos = if p1=p2 then p2+1 else p2 in + Seq.Cons (substr, aux pos) + | Running + | Failed -> Seq.Nil + in + aux pos - let pp fmt t = - let matches = - let offsets = all_offset t in - let strs = all t in - Array.to_list ( - Array.init (Array.length strs) (fun i -> strs.(i), offsets.(i)) - ) in - let open Fmt in - let pp_match fmt (str, (start, stop)) = - fprintf fmt "@[(%s (%d %d))@]" str start stop in - sexp fmt "Group" (list pp_match) matches + let matches ?pos ?len re s : _ Seq.t = + all ?pos ?len re s + |> Seq.map (fun sub -> Group.get sub 0) + + let split_full ?(pos=0) ?len re s : _ Seq.t = + if pos < 0 then invalid_arg "Re.split"; + let limit = match len with + | None -> String.length s + | Some l -> + if l<0 || pos+l > String.length s then invalid_arg "Re.split"; + pos+l + in + (* i: start of delimited string + pos: first position after last match of [re] + limit: first index we ignore (!pos < limit is an invariant) *) + let pos0 = pos in + let rec aux state i pos () = match state with + | `Idle when pos >= limit -> + if i < limit then ( + let sub = String.sub s i (limit - i) in + Seq.Cons (`Text sub, aux state (i+1) pos) + ) else Seq.Nil + | `Idle -> + begin match match_str ~groups:true ~partial:false re s ~pos + ~len:(limit - pos) with + | Match substr -> + let p1, p2 = Group.offset substr 0 in + let pos = if p1=p2 then p2+1 else p2 in + let old_i = i in + let i = p2 in + if p1 > pos0 then ( + (* string does not start by a delimiter *) + let text = String.sub s old_i (p1 - old_i) in + let state = `Yield (`Delim substr) in + Seq.Cons (`Text text, aux state i pos) + ) else Seq.Cons (`Delim substr, aux state i pos) + | Running -> Seq.Nil + | Failed -> + if i < limit + then ( + let text = String.sub s i (limit - i) in + (* yield last string *) + Seq.Cons (`Text text, aux state limit pos) + ) else + Seq.Nil + end + | `Yield x -> + Seq.Cons (x, aux `Idle i pos) + in + aux `Idle pos pos - let nb_groups t = t.gcount + let split ?pos ?len re s : _ Seq.t = + let seq = split_full ?pos ?len re s in + let rec filter seq () = match seq () with + | Seq.Nil -> Seq.Nil + | Seq.Cons (`Delim _, tl) -> filter tl () + | Seq.Cons (`Text s,tl) -> Seq.Cons (s, filter tl) + in filter seq end -module Mark = struct - - type t = Pmark.t - - let test {pmarks ; _} p = - Pmark.Set.mem p pmarks - - let all s = s.pmarks +module Rlist = struct + let list_of_seq (s:'a Seq.t) : 'a list = + Seq.fold_left (fun l x -> x :: l) [] s |> List.rev - module Set = Pmark.Set + let all ?pos ?len re s = Rseq.all ?pos ?len re s |> list_of_seq - let equal = Pmark.equal + let matches ?pos ?len re s = Rseq.matches ?pos ?len re s |> list_of_seq - let compare = Pmark.compare + let split_full ?pos ?len re s = Rseq.split_full ?pos ?len re s |> list_of_seq + let split ?pos ?len re s = Rseq.split ?pos ?len re s |> list_of_seq end -type 'a gen = unit -> 'a option - -let all_gen ?(pos=0) ?len re s = - if pos < 0 then invalid_arg "Re.all"; - (* index of the first position we do not consider. - !pos < limit is an invariant *) - let limit = match len with - | None -> String.length s - | Some l -> - if l<0 || pos+l > String.length s then invalid_arg "Re.all"; - pos+l - in - (* iterate on matches. When a match is found, search for the next - one just after its end *) - let pos = ref pos in - fun () -> - if !pos >= limit - then None (* no more matches *) - else - match match_str ~groups:true ~partial:false re s - ~pos:!pos ~len:(limit - !pos) with - | Match substr -> - let p1, p2 = Group.offset substr 0 in - pos := if p1=p2 then p2+1 else p2; - Some substr - | Running - | Failed -> None - -let all ?pos ?len re s = - let l = ref [] in - let g = all_gen ?pos ?len re s in - let rec iter () = match g() with - | None -> List.rev !l - | Some sub -> l := sub :: !l; iter () - in iter () - -let matches_gen ?pos ?len re s = - let g = all_gen ?pos ?len re s in - fun () -> - match g() with - | None -> None - | Some sub -> Some (Group.get sub 0) - -let matches ?pos ?len re s = - let l = ref [] in - let g = all_gen ?pos ?len re s in - let rec iter () = match g() with - | None -> List.rev !l - | Some sub -> l := Group.get sub 0 :: !l; iter () - in iter () - -type split_token = - [ `Text of string - | `Delim of groups - ] +module Gen = struct + type 'a gen = unit -> 'a option + let gen_of_seq (s:'a Seq.t) : 'a gen = + let r = ref s in + fun () -> match !r () with + | Seq.Nil -> None + | Seq.Cons (x, tl) -> + r := tl; + Some x + + let split ?pos ?len re s : _ gen = + Rseq.split ?pos ?len re s |> gen_of_seq -let split_full_gen ?(pos=0) ?len re s = - if pos < 0 then invalid_arg "Re.split"; - let limit = match len with - | None -> String.length s - | Some l -> - if l<0 || pos+l > String.length s then invalid_arg "Re.split"; - pos+l - in - (* i: start of delimited string - pos: first position after last match of [re] - limit: first index we ignore (!pos < limit is an invariant) *) - let pos0 = pos in - let state = ref `Idle in - let i = ref pos and pos = ref pos in - let next () = match !state with - | `Idle when !pos >= limit -> - if !i < limit then ( - let sub = String.sub s !i (limit - !i) in - incr i; - Some (`Text sub) - ) else None - | `Idle -> - begin match match_str ~groups:true ~partial:false re s ~pos:!pos - ~len:(limit - !pos) with - | Match substr -> - let p1, p2 = Group.offset substr 0 in - pos := if p1=p2 then p2+1 else p2; - let old_i = !i in - i := p2; - if p1 > pos0 then ( - (* string does not start by a delimiter *) - let text = String.sub s old_i (p1 - old_i) in - state := `Yield (`Delim substr); - Some (`Text text) - ) else Some (`Delim substr) - | Running -> None - | Failed -> - if !i < limit - then ( - let text = String.sub s !i (limit - !i) in - i := limit; - Some (`Text text) (* yield last string *) - ) else - None - end - | `Yield x -> - state := `Idle; - Some x - in next + let split_full ?pos ?len re s : _ gen = + Rseq.split_full ?pos ?len re s |> gen_of_seq -let split_full ?pos ?len re s = - let l = ref [] in - let g = split_full_gen ?pos ?len re s in - let rec iter () = match g() with - | None -> List.rev !l - | Some s -> l := s :: !l; iter () - in iter () - -let split_gen ?pos ?len re s = - let g = split_full_gen ?pos ?len re s in - let rec next() = match g() with - | None -> None - | Some (`Delim _) -> next() - | Some (`Text s) -> Some s - in next + let all ?pos ?len re s = Rseq.all ?pos ?len re s |> gen_of_seq -let split ?pos ?len re s = - let l = ref [] in - let g = split_full_gen ?pos ?len re s in - let rec iter () = match g() with - | None -> List.rev !l - | Some (`Delim _) -> iter() - | Some (`Text s) -> l := s :: !l; iter () - in iter () + let matches ?pos ?len re s = Rseq.matches ?pos ?len re s |> gen_of_seq +end let replace ?(pos=0) ?len ?(all=true) re ~f s = if pos < 0 then invalid_arg "Re.replace"; @@ -1268,9 +1177,26 @@ | End_of_str -> "" in witness (handle_case false t) +type 'a seq = 'a Seq.t +module Seq = Rseq +module List = Rlist +module Group = Group + (** {2 Deprecated functions} *) -type substrings = groups +type 'a gen = 'a Gen.gen +let all_gen = Gen.all +let matches_gen = Gen.matches +let split_gen = Gen.split +let split_full_gen = Gen.split_full + +let all_seq = Seq.all +let matches_seq = Seq.matches +let split_seq = Seq.split +let split_full_seq = Seq.split_full + + +type substrings = Group.t let get = Group.get let get_ofs = Group.offset @@ -1322,3 +1248,7 @@ Bounded repetition a{0,3} = (a,(a,a?)?)? *) + +type groups = Group.t + +include Rlist diff -Nru ocaml-re-1.7.3/lib/core.mli ocaml-re-1.9.0/lib/core.mli --- ocaml-re-1.7.3/lib/core.mli 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib/core.mli 2019-04-06 07:05:39.000000000 +0000 @@ -28,8 +28,39 @@ type re (** Compiled regular expression *) -type groups -(** Information about groups in a match. *) +(** Manipulate matching groups. *) +module Group : sig + type t + (** Information about groups in a match. *) + + val get : t -> int -> string + (** Raise [Not_found] if the group did not match *) + + val offset : t -> int -> int * int + (** Raise [Not_found] if the group did not match *) + + val start : t -> int -> int + (** Return the start of the match. Raise [Not_found] if the group did not match. *) + + val stop : t -> int -> int + (** Return the end of the match. Raise [Not_found] if the group did not match. *) + + val all : t -> string array + (** Return the empty string for each group which did not match *) + + val all_offset : t -> (int * int) array + (** Return [(-1,-1)] for each group which did not match *) + + val test : t -> int -> bool + (** Test whether a group matched *) + + val nb_groups : t -> int + (** Returns the total number of groups defined - matched or not. + This function is experimental. *) + + val pp : Format.formatter -> t -> unit +end +type groups = Group.t [@@ocaml.deprecated "Use Group.t"] (** {2 Compilation and execution of a regular expression} *) @@ -40,7 +71,7 @@ val exec : ?pos:int -> (* Default: 0 *) ?len:int -> (* Default: -1 (until end of string) *) - re -> string -> groups + re -> string -> Group.t (** [exec re str] matches [str] against the compiled expression [re], and returns the matched groups if any. @param pos optional beginning of the string (default 0) @@ -52,7 +83,7 @@ val exec_opt : ?pos:int -> (* Default: 0 *) ?len:int -> (* Default: -1 (until end of string) *) - re -> string -> groups option + re -> string -> Group.t option (** Similar to {!exec}, but returns an option instead of using an exception. *) val execp : @@ -68,41 +99,6 @@ re -> string -> [ `Full | `Partial | `Mismatch ] (** More detailed version of {!exec_p} *) -(** Manipulate matching groups. *) -module Group : sig - - type t = groups - (** Information about groups in a match. *) - - val get : t -> int -> string - (** Raise [Not_found] if the group did not match *) - - val offset : t -> int -> int * int - (** Raise [Not_found] if the group did not match *) - - val start : t -> int -> int - (** Return the start of the match. Raise [Not_found] if the group did not match. *) - - val stop : t -> int -> int - (** Return the end of the match. Raise [Not_found] if the group did not match. *) - - val all : t -> string array - (** Return the empty string for each group which did not match *) - - val all_offset : t -> (int * int) array - (** Return [(-1,-1)] for each group which did not match *) - - val test : t -> int -> bool - (** Test whether a group matched *) - - val nb_groups : t -> int - (** Returns the total number of groups defined - matched or not. - This function is experimental. *) - - val pp : Format.formatter -> t -> unit - -end - (** Marks *) module Mark : sig @@ -124,62 +120,84 @@ (** {2 High Level Operations} *) +type split_token = + [ `Text of string (** Text between delimiters *) + | `Delim of Group.t (** Delimiter *) + ] + +type 'a seq = 'a Seq.t + +module Seq : sig + val all : + ?pos:int -> (** Default: 0 *) + ?len:int -> + re -> string -> Group.t Seq.t + (** Same as {!all} but returns an iterator + @since NEXT_RELEASE *) + + val matches : + ?pos:int -> (** Default: 0 *) + ?len:int -> + re -> string -> string Seq.t + (** Same as {!matches}, but returns an iterator + @since NEXT_RELEASE *) + + val split : + ?pos:int -> (** Default: 0 *) + ?len:int -> + re -> string -> string Seq.t + (** @since NEXT_RELEASE *) + + val split_full : + ?pos:int -> (** Default: 0 *) + ?len:int -> + re -> string -> split_token Seq.t + (** @since NEXT_RELEASE *) +end + +val all : ?pos:int -> ?len:int -> re -> string -> Group.t list +(** Repeatedly calls {!exec} on the given string, starting at given position and + length.*) + type 'a gen = unit -> 'a option -val all : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> Group.t list -(** Repeatedly calls {!exec} on the given string, starting at given - position and length.*) +val all_gen : ?pos:int -> ?len:int -> re -> string -> Group.t gen +[@@ocaml.deprecated "Use Seq.all"] -val all_gen : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> Group.t gen -(** Same as {!all} but returns a generator *) +val all_seq : ?pos:int -> ?len:int -> re -> string -> Group.t seq +[@@ocaml.deprecated "Use Seq.all"] -val matches : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> string list -(** Same as {!all}, but extracts the matched substring rather than - returning the whole group. This basically iterates over matched - strings *) +val matches : ?pos:int -> ?len:int -> re -> string -> string list +(** Same as {!all}, but extracts the matched substring rather than returning + the whole group. This basically iterates over matched strings *) -val matches_gen : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> string gen -(** Same as {!matches}, but returns a generator. *) +val matches_gen : ?pos:int -> ?len:int -> re -> string -> string gen +[@@ocaml.deprecated "Use Seq.matches"] -val split : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> string list -(** [split re s] splits [s] into chunks separated by [re]. It yields - the chunks themselves, not the separator. For instance - this can be used with a whitespace-matching re such as ["[\t ]+"]. *) +val matches_seq : ?pos:int -> ?len:int -> re -> string -> string seq +[@@ocaml.deprecated "Use Seq.matches"] -val split_gen : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> string gen +val split : ?pos:int -> ?len:int -> re -> string -> string list +(** [split re s] splits [s] into chunks separated by [re]. It yields the chunks + themselves, not the separator. For instance this can be used with a + whitespace-matching re such as ["[\t ]+"]. *) -type split_token = - [ `Text of string (** Text between delimiters *) - | `Delim of Group.t (** Delimiter *) - ] +val split_gen : ?pos:int -> ?len:int -> re -> string -> string gen +[@@ocaml.deprecated "Use Seq.split"] -val split_full : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> split_token list +val split_seq : ?pos:int -> ?len:int -> re -> string -> string seq +[@@ocaml.deprecated "Use Seq.split"] -val split_full_gen : - ?pos:int -> (** Default: 0 *) - ?len:int -> - re -> string -> split_token gen +val split_full : ?pos:int -> ?len:int -> re -> string -> split_token list +(** [split re s] splits [s] into chunks separated by [re]. It yields the chunks + along with the separators. For instance this can be used with a + whitespace-matching re such as ["[\t ]+"]. *) + +val split_full_gen : ?pos:int -> ?len:int -> re -> string -> split_token gen +[@@ocaml.deprecated "Use Seq.split_full"] + +val split_full_seq : ?pos:int -> ?len:int -> re -> string -> split_token seq +[@@ocaml.deprecated "Use Seq.split_full"] val replace : ?pos:int -> (** Default: 0 *) @@ -372,6 +390,31 @@ (** Alias for {!pp_re}. Deprecated *) val print_re : Format.formatter -> re -> unit +module View : sig + type outer + + (** A view of the top-level of a regex. This type is unstable and may change *) + type t = + Set of Cset.t + | Sequence of outer list + | Alternative of outer list + | Repeat of outer * int * int option + | Beg_of_line | End_of_line + | Beg_of_word | End_of_word | Not_bound + | Beg_of_str | End_of_str + | Last_end_of_line | Start | Stop + | Sem of Automata.sem * outer + | Sem_greedy of Automata.rep_kind * outer + | Group of outer | No_group of outer | Nest of outer + | Case of outer | No_case of outer + | Intersection of outer list + | Complement of outer list + | Difference of outer * outer + | Pmark of Pmark.t * outer + + val view : outer -> t +end with type outer := t + (** {2 Experimental functions}. *) val witness : t -> string @@ -381,28 +424,37 @@ (** {2 Deprecated functions} *) type substrings = Group.t +[@@ocaml.deprecated "Use Group.t"] (** Alias for {!Group.t}. Deprecated *) val get : Group.t -> int -> string +[@@ocaml.deprecated "Use Group.get"] (** Same as {!Group.get}. Deprecated *) val get_ofs : Group.t -> int -> int * int +[@@ocaml.deprecated "Use Group.offset"] (** Same as {!Group.offset}. Deprecated *) val get_all : Group.t -> string array +[@@ocaml.deprecated "Use Group.all"] (** Same as {!Group.all}. Deprecated *) val get_all_ofs : Group.t -> (int * int) array +[@@ocaml.deprecated "Use Group.all_offset"] (** Same as {!Group.all_offset}. Deprecated *) val test : Group.t -> int -> bool +[@@ocaml.deprecated "Use Group.test"] (** Same as {!Group.test}. Deprecated *) type markid = Mark.t +[@@ocaml.deprecated "Use Mark."] (** Alias for {!Mark.t}. Deprecated *) val marked : Group.t -> Mark.t -> bool +[@@ocaml.deprecated "Use Mark.test"] (** Same as {!Mark.test}. Deprecated *) val mark_set : Group.t -> Mark.Set.t +[@@ocaml.deprecated "Use Mark.all"] (** Same as {!Mark.all}. Deprecated *) diff -Nru ocaml-re-1.7.3/lib/dune ocaml-re-1.9.0/lib/dune --- ocaml-re-1.7.3/lib/dune 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib/dune 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,5 @@ +(library + (name re) + (synopsis "Pure OCaml regular expression library") + (libraries seq) + (public_name re)) diff -Nru ocaml-re-1.7.3/lib/glob.ml ocaml-re-1.9.0/lib/glob.ml --- ocaml-re-1.7.3/lib/glob.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib/glob.ml 2019-04-06 07:05:39.000000000 +0000 @@ -164,12 +164,12 @@ end let one ~explicit_slash ~explicit_period = - Re.(compl ( + Re.compl ( List.concat [ - if explicit_slash then [char '/'] else []; - if explicit_period then [char '.'] else []; + if explicit_slash then [Re.char '/'] else []; + if explicit_period then [Re.char '.'] else []; ] - )) + ) let enclosed enclosed = match enclosed with diff -Nru ocaml-re-1.7.3/lib/group.ml ocaml-re-1.9.0/lib/group.ml --- ocaml-re-1.7.3/lib/group.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib/group.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,73 @@ +(* Result of a successful match. *) +type t = + { s : string + ; marks : Automata.mark_infos + ; pmarks : Pmark.Set.t + ; gpos : int array + ; gcount : int + } + +let offset t i = + if 2 * i + 1 >= Array.length t.marks then raise Not_found; + let m1 = t.marks.(2 * i) in + if m1 = -1 then raise Not_found; + let p1 = t.gpos.(m1) - 1 in + let p2 = t.gpos.(t.marks.(2 * i + 1)) - 1 in + (p1, p2) + +let get t i = + let (p1, p2) = offset t i in + String.sub t.s p1 (p2 - p1) + +let start subs i = fst (offset subs i) + +let stop subs i = snd (offset subs i) + +let test t i = + if 2 * i >= Array.length t.marks then + false + else + let idx = t.marks.(2 * i) in + idx <> -1 + +let dummy_offset = (-1, -1) + +let all_offset t = + let res = Array.make t.gcount dummy_offset in + for i = 0 to Array.length t.marks / 2 - 1 do + let m1 = t.marks.(2 * i) in + if m1 <> -1 then begin + let p1 = t.gpos.(m1) in + let p2 = t.gpos.(t.marks.(2 * i + 1)) in + res.(i) <- (p1 - 1, p2 - 1) + end + done; + res + +let dummy_string = "" + +let all t = + let res = Array.make t.gcount dummy_string in + for i = 0 to Array.length t.marks / 2 - 1 do + let m1 = t.marks.(2 * i) in + if m1 <> -1 then begin + let p1 = t.gpos.(m1) in + let p2 = t.gpos.(t.marks.(2 * i + 1)) in + res.(i) <- String.sub t.s (p1 - 1) (p2 - p1) + end + done; + res + +let pp fmt t = + let matches = + let offsets = all_offset t in + let strs = all t in + Array.to_list ( + Array.init (Array.length strs) (fun i -> strs.(i), offsets.(i)) + ) in + let open Fmt in + let pp_match fmt (str, (start, stop)) = + fprintf fmt "@[(%s (%d %d))@]" str start stop in + sexp fmt "Group" (list pp_match) matches + +let nb_groups t = t.gcount diff -Nru ocaml-re-1.7.3/lib/group.mli ocaml-re-1.9.0/lib/group.mli --- ocaml-re-1.7.3/lib/group.mli 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib/group.mli 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,52 @@ +(* Result of a successful match. *) +type t = + { s : string + (* Input string. Matched strings are substrings of s *) + + ; marks : Automata.mark_infos + (* Mapping from group indices to positions in gpos. group i has positions 2*i + - 1, 2*i + 1 in gpos. If the group wasn't matched, then its corresponding + values in marks will be -1,-1 *) + + ; pmarks : Pmark.Set.t + (* Marks positions. i.e. those marks created with Re.marks *) + + ; gpos : int array + (* Group positions. Adjacent elements are (start, stop) of group match. + indexed by the values in marks. So group i in an re would be the substring: + + start = t.gpos.(marks.(2*i)) - 1 + stop = t.gpos.(marks.(2*i + 1)) - 1 *) + + ; gcount : int + (* Number of groups the regular expression contains. Matched or not *) + } + +(** Information about groups in a match. *) + +val get : t -> int -> string +(** Raise [Not_found] if the group did not match *) + +val offset : t -> int -> int * int +(** Raise [Not_found] if the group did not match *) + +val start : t -> int -> int +(** Return the start of the match. Raise [Not_found] if the group did not match. *) + +val stop : t -> int -> int +(** Return the end of the match. Raise [Not_found] if the group did not match. *) + +val all : t -> string array +(** Return the empty string for each group which did not match *) + +val all_offset : t -> (int * int) array +(** Return [(-1,-1)] for each group which did not match *) + +val test : t -> int -> bool +(** Test whether a group matched *) + +val nb_groups : t -> int +(** Returns the total number of groups defined - matched or not. + This function is experimental. *) + +val pp : Format.formatter -> t -> unit diff -Nru ocaml-re-1.7.3/lib/jbuild ocaml-re-1.9.0/lib/jbuild --- ocaml-re-1.7.3/lib/jbuild 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib/jbuild 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -(jbuild_version 1) - -(library - ((name re) - (synopsis "Pure OCaml regular expression library") - (public_name re))) diff -Nru ocaml-re-1.7.3/lib/pcre.ml ocaml-re-1.9.0/lib/pcre.ml --- ocaml-re-1.7.3/lib/pcre.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib/pcre.ml 2019-04-06 07:05:39.000000000 +0000 @@ -10,7 +10,7 @@ | Group of int * string | NoGroup -type groups = Re.groups +type groups = Core.Group.t let re ?(flags = []) pat = let opts = List.map (function @@ -116,4 +116,4 @@ List.concat matches -type substrings = Re.groups +type substrings = Group.t diff -Nru ocaml-re-1.7.3/lib/pcre.mli ocaml-re-1.9.0/lib/pcre.mli --- ocaml-re-1.7.3/lib/pcre.mli 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib/pcre.mli 2019-04-06 07:05:39.000000000 +0000 @@ -2,7 +2,7 @@ type flag = [ `CASELESS | `MULTILINE | `ANCHORED ] -type groups = Core.groups +type groups = Core.Group.t (** Result of a {!Pcre.full_split} *) type split_result = @@ -42,4 +42,4 @@ (** {2 Deprecated} *) -type substrings = Core.groups +type substrings = Group.t diff -Nru ocaml-re-1.7.3/lib/perl.ml ocaml-re-1.9.0/lib/perl.ml --- ocaml-re-1.7.3/lib/perl.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib/perl.ml 2019-04-06 07:05:39.000000000 +0000 @@ -191,7 +191,7 @@ `Char c' -> bracket (Re.rg c c' :: s) | `Set st' -> - Re.char c :: Re.char '-' :: st' :: s + bracket (Re.char c :: Re.char '-' :: st' :: s) end end else bracket (Re.char c :: s) @@ -221,6 +221,7 @@ end else `Char c end else if c = '\\' then begin + if eos () then raise Parse_error; let c = get () in (* XXX \127, ... @@ -245,6 +246,7 @@ end else `Char c and comment () = + if eos () then raise Parse_error; if accept ')' then Re.epsilon else begin incr i; comment () end in let res = regexp () in diff -Nru ocaml-re-1.7.3/lib_test/dune ocaml-re-1.9.0/lib_test/dune --- ocaml-re-1.7.3/lib_test/dune 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/dune 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,9 @@ +(tests + (libraries re fort_unit) + (modules :standard \ test_str) + (names test_easy test_re test_perl test_emacs test_glob test_pcre)) + +(test + (libraries re fort_unit str) + (modules test_str) + (name test_str)) diff -Nru ocaml-re-1.7.3/lib_test/fort_unit/dune ocaml-re-1.9.0/lib_test/fort_unit/dune --- ocaml-re-1.7.3/lib_test/fort_unit/dune 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/fort_unit/dune 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,6 @@ +(rule (copy %{project_root}/lib/fmt.ml fmt.ml)) + +(library + (name fort_unit) + (wrapped false) + (libraries re oUnit)) \ No newline at end of file diff -Nru ocaml-re-1.7.3/lib_test/fort_unit/fort_unit.ml ocaml-re-1.9.0/lib_test/fort_unit/fort_unit.ml --- ocaml-re-1.7.3/lib_test/fort_unit/fort_unit.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/fort_unit/fort_unit.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,66 @@ +(* ounit compatibility layer for fort tests *) +open OUnit2 + +type ('a, 'b) either = + | Left of 'a + | Right of 'b + +let str_of_either f g = function + | Left a -> f a + | Right b -> g b + +let try_with f = try Right (f ()) with exn -> Left exn + +let expect_equal_app ?printer ?msg f x g y = + let fx = try_with (fun () -> f x) in + let gy = try_with (fun () -> g y) in + let printer = + let right x = + match printer with + | None -> "" + | Some p -> p x in + str_of_either Printexc.to_string right in + assert_equal ~printer ?msg fx gy + +let collected_tests = ref [] + +let id x = x +let not_found () = raise Not_found + +let bool_printer i = Printf.sprintf "%b" i +let int_printer i = Printf.sprintf "%d" i +let str_printer s = "\"" ^ String.escaped s ^ "\"" +let ofs_printer (i0,i1) = Printf.sprintf "(%d,%d)" i0 i1 +let list_printer f l = + "[" ^ (String.concat "; " (List.map f l)) ^ "]" +let arr_printer f a = + "[|" ^ (String.concat "; " (List.map f (Array.to_list a))) ^ "|]" +let opt_printer f = function + | None -> "" + | Some s -> "Some (" ^ (f s) ^ ")" + +let arr_str_printer = arr_printer str_printer +let arr_ofs_printer = arr_printer ofs_printer +let list_ofs_printer = list_printer ofs_printer + +let fail = assert_failure + +let expect_eq_bool ?msg f x g y = + expect_equal_app ?msg ~printer:string_of_bool f x g y +let expect_eq_str ?msg f x g y = + expect_equal_app ?msg ~printer:str_printer f x g y +let expect_eq_ofs ?msg f x g y = + expect_equal_app ?msg ~printer:ofs_printer f x g y +let expect_eq_arr_str ?msg f x g y = + expect_equal_app ?msg ~printer:arr_str_printer f x g y +let expect_eq_arr_ofs ?msg f x g y = + expect_equal_app ?msg ~printer:arr_ofs_printer f x g y + +let expect_eq_list_str ?msg f x g y = + expect_equal_app ?msg ~printer:(list_printer str_printer) f x g y + +let expect_pass name run = + collected_tests := (name >:: (fun _ -> run ())) :: !collected_tests + +let run_test_suite suite_name = + run_test_tt_main (suite_name >::: !collected_tests) diff -Nru ocaml-re-1.7.3/lib_test/fort_unit.ml ocaml-re-1.9.0/lib_test/fort_unit.ml --- ocaml-re-1.7.3/lib_test/fort_unit.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/fort_unit.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -(* ounit compatibility layer for fort tests *) -open OUnit2 - -type ('a, 'b) either = - | Left of 'a - | Right of 'b - -let str_of_either f g = function - | Left a -> f a - | Right b -> g b - -let try_with f = try Right (f ()) with exn -> Left exn - -let expect_equal_app ?printer ?msg f x g y = - let fx = try_with (fun () -> f x) in - let gy = try_with (fun () -> g y) in - let printer = - let right x = - match printer with - | None -> "" - | Some p -> p x in - str_of_either Printexc.to_string right in - assert_equal ~printer ?msg fx gy - -let collected_tests = ref [] - -let id x = x -let not_found () = raise Not_found - -let bool_printer i = Printf.sprintf "%b" i -let int_printer i = Printf.sprintf "%d" i -let str_printer s = "\"" ^ String.escaped s ^ "\"" -let ofs_printer (i0,i1) = Printf.sprintf "(%d,%d)" i0 i1 -let list_printer f l = - "[" ^ (String.concat "; " (List.map f l)) ^ "]" -let arr_printer f a = - "[|" ^ (String.concat "; " (List.map f (Array.to_list a))) ^ "|]" -let opt_printer f = function - | None -> "" - | Some s -> "Some (" ^ (f s) ^ ")" - -let arr_str_printer = arr_printer str_printer -let arr_ofs_printer = arr_printer ofs_printer -let list_ofs_printer = list_printer ofs_printer - -let fail = assert_failure - -let expect_eq_bool ?msg f x g y = - expect_equal_app ?msg ~printer:string_of_bool f x g y -let expect_eq_str ?msg f x g y = - expect_equal_app ?msg ~printer:str_printer f x g y -let expect_eq_ofs ?msg f x g y = - expect_equal_app ?msg ~printer:ofs_printer f x g y -let expect_eq_arr_str ?msg f x g y = - expect_equal_app ?msg ~printer:arr_str_printer f x g y -let expect_eq_arr_ofs ?msg f x g y = - expect_equal_app ?msg ~printer:arr_ofs_printer f x g y - -let expect_eq_list_str ?msg f x g y = - expect_equal_app ?msg ~printer:(list_printer str_printer) f x g y - -let expect_pass name run = - collected_tests := (name >:: (fun _ -> run ())) :: !collected_tests - -let run_test_suite suite_name = - run_test_tt_main (suite_name >::: !collected_tests) diff -Nru ocaml-re-1.7.3/lib_test/glob.ml ocaml-re-1.9.0/lib_test/glob.ml --- ocaml-re-1.7.3/lib_test/glob.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/glob.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -(** This is a little command line tool to test the library. -@author Christian Lindig -*) - -module R = Re -module G = Re.Glob - -exception Error of string -let error fmt = Printf.kprintf (fun msg -> raise (Error msg)) fmt -let eprintf = Printf.eprintf -let printf = Printf.printf - -let (@@) f x = f x - -let glob pattern str = - let rx = R.compile @@ R.whole_string @@ G.glob ~expand_braces:true pattern in - (* let () = R.print_re Format.std_formatter rx in *) - if R.execp rx str - then printf "%s matches: %s\n" pattern str - else printf "%s doesn't match: %s\n" pattern str - -let main () = - let argv = Array.to_list Sys.argv in - let this = List.hd argv in - let args = List.tl argv in - match args with - | [] | [_] -> error "usage: %s pattern string .." this - | p :: strs -> List.iter (glob p) strs - -let () = - try - main (); exit 0 - with - | Error(msg) -> eprintf "Error: %s\n" msg; exit 1 - | _ -> eprintf "unknown exception raised\n"; exit 1 - diff -Nru ocaml-re-1.7.3/lib_test/Input ocaml-re-1.9.0/lib_test/Input --- ocaml-re-1.7.3/lib_test/Input 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/Input 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -datafile for regex matching of phone numbers test - -the following numbers should match: - -(111) 111 1111 -111 222-2222 -(111) 333-3333 -111 444 4444 - -foo (111) 555 5555 -foo 111 666-6666 -foo (111) 777-7777 -foo 111 888 8888 - -foo (111) 999 9999 bar -foo 111 000-0000 bar -foo (111) 232-1111 bar -foo 111 242 1111 bar - -The following should fail to match: - -2(212) 222 2222 -2232 222-2222 -(242) 222-22222 -2252 222 2222 - -foo (262) 2222222 -foo 272 2222222 -foo (282) 222-22227 -foo 292 222 22222 - -foo (202).222 2222 bar -foo 211@22222222 bar -foo (213 222-2222 bar -foo 214) 222 2222 bar - diff -Nru ocaml-re-1.7.3/lib_test/jbuild ocaml-re-1.9.0/lib_test/jbuild --- ocaml-re-1.7.3/lib_test/jbuild 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/jbuild 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -(jbuild_version 1) - -(rule - ((targets (fmt.ml)) - (deps (../lib/fmt.ml)) - (action (copy ${<} ${@})))) - -(library - ((name fort_unit) - (wrapped false) - (modules (fort_unit fmt)) - (libraries (re oUnit)))) - -(executables - ((libraries (re fort_unit)) - (modules (test_re)) - (names (test_re)))) - -(executables - ((libraries (re fort_unit)) - (modules (test_perl)) - (names (test_perl)))) - -(executables - ((libraries (re fort_unit)) - (modules (test_emacs)) - (names (test_emacs)))) - -(executables - ((libraries (re fort_unit)) - (modules (test_glob)) - (names (test_glob)))) - -(executables - ((libraries (re str fort_unit)) - (modules (test_str)) - (names (test_str)))) - -(executables - ((libraries (re fort_unit)) - (modules (test_pcre)) - (names (test_pcre)))) - -(alias - ((name runtest) - (deps (test_re.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (deps (test_perl.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (deps (test_emacs.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (deps (test_glob.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (deps (test_str.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (deps (test_pcre.exe)) - (action (run ${<})))) \ No newline at end of file diff -Nru ocaml-re-1.7.3/lib_test/longest.c ocaml-re-1.9.0/lib_test/longest.c --- ocaml-re-1.7.3/lib_test/longest.c 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/longest.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ - -#include -#include - -main () { - regex_t preg; - regmatch_t pmatch[3]; - - regcomp (&preg, "(aa?)*", REG_EXTENDED); - regexec (&preg, "aaa", 2, pmatch, 0); - - printf ("%d %d %d %d (expected: 0 3 1 3)\n", - pmatch[0].rm_so, pmatch[0].rm_eo, pmatch[1].rm_so, pmatch[1].rm_eo); - - regcomp (&preg, "(a*)(ab)?b*", REG_EXTENDED); - regexec (&preg, "aaabb", 3, pmatch, 0); - - printf ("%d %d %d %d %d %d (expected: 0 5 0 2 2 4)\n", - pmatch[0].rm_so, pmatch[0].rm_eo, - pmatch[1].rm_so, pmatch[1].rm_eo, - pmatch[2].rm_so, pmatch[2].rm_eo); - - regcomp (&preg, "((a?)|b)*", REG_EXTENDED); - regexec (&preg, "ab", 3, pmatch, 0); - - printf ("%d %d %d %d %d %d (expected: 0 2 1 2 -1 -1)\n", - pmatch[0].rm_so, pmatch[0].rm_eo, - pmatch[1].rm_so, pmatch[1].rm_eo, - pmatch[2].rm_so, pmatch[2].rm_eo); - - regcomp (&preg, "((a)|b)*", REG_EXTENDED); - regexec (&preg, "ab", 3, pmatch, 0); - - printf ("%d %d %d %d %d %d (expected: 0 2 1 2 -1 -1)\n", - pmatch[0].rm_so, pmatch[0].rm_eo, - pmatch[1].rm_so, pmatch[1].rm_eo, - pmatch[2].rm_so, pmatch[2].rm_eo); -} diff -Nru ocaml-re-1.7.3/lib_test/Makefile ocaml-re-1.9.0/lib_test/Makefile --- ocaml-re-1.7.3/lib_test/Makefile 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -re_scan: re_scan.ml ../re.cmxa - ocamlopt -o re_scan -I .. re.cmxa re_scan.ml - -pcre_scan: pcre_scan.ml - ocamlopt -o pcre_scan -I +contrib pcre.cmxa pcre_scan.ml - -re_match: re_match.ml ../re.cmxa - ocamlopt -o re_match -I .. re.cmxa re_match.ml - -pcre_match: pcre_match.ml - ocamlopt -o pcre_match -I +contrib pcre.cmxa pcre_match.ml - -unison3: unison3.ml - ocamlopt -o unison3 unix.cmxa -I +contrib pcre.cmxa unison3.ml - -unison: unison.ml ../re.cmxa - ocamlopt -o unison unix.cmxa -I .. re.cmxa unison.ml - -unison2: unison2.ml - ocamlopt -o unison2 unix.cmxa -I ../../unison/src re.cmx unison2.ml - -clean: - rm -f re_scan pcre_scan re_match pcre_match unison unison2 unison3 - rm -f *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o diff -Nru ocaml-re-1.7.3/lib_test/old/glob.ml ocaml-re-1.9.0/lib_test/old/glob.ml --- ocaml-re-1.7.3/lib_test/old/glob.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/glob.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,36 @@ +(** This is a little command line tool to test the library. +@author Christian Lindig +*) + +module R = Re +module G = Re.Glob + +exception Error of string +let error fmt = Printf.kprintf (fun msg -> raise (Error msg)) fmt +let eprintf = Printf.eprintf +let printf = Printf.printf + +let (@@) f x = f x + +let glob pattern str = + let rx = R.compile @@ R.whole_string @@ G.glob ~expand_braces:true pattern in + (* let () = R.print_re Format.std_formatter rx in *) + if R.execp rx str + then printf "%s matches: %s\n" pattern str + else printf "%s doesn't match: %s\n" pattern str + +let main () = + let argv = Array.to_list Sys.argv in + let this = List.hd argv in + let args = List.tl argv in + match args with + | [] | [_] -> error "usage: %s pattern string .." this + | p :: strs -> List.iter (glob p) strs + +let () = + try + main (); exit 0 + with + | Error(msg) -> eprintf "Error: %s\n" msg; exit 1 + | _ -> eprintf "unknown exception raised\n"; exit 1 + diff -Nru ocaml-re-1.7.3/lib_test/old/Input ocaml-re-1.9.0/lib_test/old/Input --- ocaml-re-1.7.3/lib_test/old/Input 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/Input 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,36 @@ +datafile for regex matching of phone numbers test + +the following numbers should match: + +(111) 111 1111 +111 222-2222 +(111) 333-3333 +111 444 4444 + +foo (111) 555 5555 +foo 111 666-6666 +foo (111) 777-7777 +foo 111 888 8888 + +foo (111) 999 9999 bar +foo 111 000-0000 bar +foo (111) 232-1111 bar +foo 111 242 1111 bar + +The following should fail to match: + +2(212) 222 2222 +2232 222-2222 +(242) 222-22222 +2252 222 2222 + +foo (262) 2222222 +foo 272 2222222 +foo (282) 222-22227 +foo 292 222 22222 + +foo (202).222 2222 bar +foo 211@22222222 bar +foo (213 222-2222 bar +foo 214) 222 2222 bar + diff -Nru ocaml-re-1.7.3/lib_test/old/longest.c ocaml-re-1.9.0/lib_test/old/longest.c --- ocaml-re-1.7.3/lib_test/old/longest.c 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/longest.c 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,38 @@ + +#include +#include + +main () { + regex_t preg; + regmatch_t pmatch[3]; + + regcomp (&preg, "(aa?)*", REG_EXTENDED); + regexec (&preg, "aaa", 2, pmatch, 0); + + printf ("%d %d %d %d (expected: 0 3 1 3)\n", + pmatch[0].rm_so, pmatch[0].rm_eo, pmatch[1].rm_so, pmatch[1].rm_eo); + + regcomp (&preg, "(a*)(ab)?b*", REG_EXTENDED); + regexec (&preg, "aaabb", 3, pmatch, 0); + + printf ("%d %d %d %d %d %d (expected: 0 5 0 2 2 4)\n", + pmatch[0].rm_so, pmatch[0].rm_eo, + pmatch[1].rm_so, pmatch[1].rm_eo, + pmatch[2].rm_so, pmatch[2].rm_eo); + + regcomp (&preg, "((a?)|b)*", REG_EXTENDED); + regexec (&preg, "ab", 3, pmatch, 0); + + printf ("%d %d %d %d %d %d (expected: 0 2 1 2 -1 -1)\n", + pmatch[0].rm_so, pmatch[0].rm_eo, + pmatch[1].rm_so, pmatch[1].rm_eo, + pmatch[2].rm_so, pmatch[2].rm_eo); + + regcomp (&preg, "((a)|b)*", REG_EXTENDED); + regexec (&preg, "ab", 3, pmatch, 0); + + printf ("%d %d %d %d %d %d (expected: 0 2 1 2 -1 -1)\n", + pmatch[0].rm_so, pmatch[0].rm_eo, + pmatch[1].rm_so, pmatch[1].rm_eo, + pmatch[2].rm_so, pmatch[2].rm_eo); +} diff -Nru ocaml-re-1.7.3/lib_test/old/pcre_match.ml ocaml-re-1.9.0/lib_test/old/pcre_match.ml --- ocaml-re-1.7.3/lib_test/old/pcre_match.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/pcre_match.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,42 @@ +(* + * $Id: pcre_match.ml,v 1.1.1.1 2001/09/21 15:54:12 vouillon Exp $ + * http://www.bagley.org/~doug/shootout/ + * from: Markus Mottl + *) + +open Re_pcre + +let rex = + regexp ~flags:[`EXTENDED] + "(?: ^ | [^\d\(]) # must be preceeded by non-digit + (\(\d\d\d\)|\d\d\d) # match 1: area code + [ ] # area code followed by one space + \d\d\d # prefix of 3 digits + [ -] # separator is either space or dash + \d\d\d\d # last 4 digits + (?: \D|$) # must be followed by a non-digit (or EOL)" + +let phones = + let lines = ref [] in + foreach_line (fun line -> lines := line :: !lines); + List.rev !lines + +let check_phone irflags ar cnt must_print line = + try + unsafe_pcre_exec irflags rex 0 line 4 ar; + let num = String.copy "(...) ...-...." and pos = Array.unsafe_get ar 2 in + let ofs = if String.unsafe_get line pos = '(' then 1 else 0 in + let pos = pos + ofs in + String.unsafe_blit line pos num 1 3; + let pos = pos + ofs + 4 in + String.unsafe_blit line pos num 6 3; + String.unsafe_blit line (pos + 4) num 10 4; + if must_print then Printf.printf "%d: %s\n" !cnt num; + incr cnt + with Not_found -> () + +let n = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 1;; +for i = 2 to n do + List.iter (check_phone (rflags []) (Array.create 6 0) (ref 1) false) phones +done; +List.iter (check_phone (rflags []) (Array.create 6 0) (ref 1) true) phones diff -Nru ocaml-re-1.7.3/lib_test/old/pcre_scan.ml ocaml-re-1.9.0/lib_test/old/pcre_scan.ml --- ocaml-re-1.7.3/lib_test/old/pcre_scan.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/pcre_scan.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,8 @@ + +let x = Re_pcre.regexp "aa?b" +let _ = + let s = String.make (1024*1024) 'a' in + s.[1024*1024-1] <- 'b'; + for _i = 0 to 99 do + ignore (Re_pcre.exec ~rex:x s) + done diff -Nru ocaml-re-1.7.3/lib_test/old/perl_scan.pl ocaml-re-1.9.0/lib_test/old/perl_scan.pl --- ocaml-re-1.7.3/lib_test/old/perl_scan.pl 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/perl_scan.pl 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,4 @@ +$s = 'a' x (1024 * 1024 - 1) . 'b'; +for ($i = 1; $i < 100; $i++) { +print "$&\n" if $s =~ /aa?b/ ; +} diff -Nru ocaml-re-1.7.3/lib_test/old/re_match.ml ocaml-re-1.9.0/lib_test/old/re_match.ml --- ocaml-re-1.7.3/lib_test/old/re_match.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/re_match.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,56 @@ +(* + * $Id: re_match.ml,v 1.2 2001/10/03 15:04:59 vouillon Exp $ + * http://www.bagley.org/~doug/shootout/ + * from: Markus Mottl + *) + +let rex = + let three_digits = Re.seq [Re.digit; Re.digit; Re.digit] in + Re.compile + (Re.seq + [(* Must be preceeded by a non-digit *) + Re.alt [Re.bol; Re.compl [Re.digit; Re.char '(']]; + (* Area code *) + Re.group (Re.alt [Re.seq [Re.char '('; three_digits; Re.char ')']; + three_digits]); + (* One space *) + Re.char ' '; + (* Prefix of 3 digits *) + three_digits; + (* Separator: either a space or a dash *) + Re.set " -"; + (* Last for digits *) + three_digits; Re.digit; + (* Must be followed by a non-digit (or EOL) *) + Re.alt [Re.eol; Re.compl [Re.digit]]]) + +let foreach_line ?(ic = stdin) f = + try while true do f (input_line ic) done with End_of_file -> () + +let phones = + let lines = ref [] in +let ic = open_in "Input" in + foreach_line ~ic (fun line -> lines := line :: !lines); +close_in ic; + List.rev !lines + +let check_phone cnt must_print line = + try + let matches = Re.exec rex line in + let num = "(...) ...-...." in + let (pos, _) = Re.Group.offset matches 1 in + let ofs = if line.[pos] = '(' then 1 else 0 in + let pos = pos + ofs in + String.blit line pos num 1 3; + let pos = pos + ofs + 4 in + String.blit line pos num 6 3; + String.blit line (pos + 4) num 10 4; + if must_print then Printf.printf "%d: %s\n" !cnt num; + incr cnt + with Not_found -> () + +let n = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 1;; +for _i = 2 to n do + List.iter (check_phone (ref 1) false) phones +done; +List.iter (check_phone (ref 1) true) phones diff -Nru ocaml-re-1.7.3/lib_test/old/re_scan.ml ocaml-re-1.9.0/lib_test/old/re_scan.ml --- ocaml-re-1.7.3/lib_test/old/re_scan.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/re_scan.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,10 @@ + +open Re + +let x = compile (seq [char 'a'; opt (char 'a'); char 'b']) +let _ = + let s = String.make (1024*1024) 'a' in + s.[1024*1024-1] <- 'b'; + for _i = 0 to 99 do + ignore (exec x s) + done diff -Nru ocaml-re-1.7.3/lib_test/old/scan.ml ocaml-re-1.9.0/lib_test/old/scan.ml --- ocaml-re-1.7.3/lib_test/old/scan.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/scan.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,150 @@ +type state = + { idx : int; + next : state array } + +type info = { i_cols : string; last : int } + +let unknown = {idx = -1; next = [||]} +let st1 = { idx = 0; next = Array.make 256 unknown } +let st2 = { idx = 0; next = Array.make 256 st1 } +let cols = String.create 256 + +let _ = + for i = 0 to 255 do st1.next.(i) <- st2; cols.[i] <- Char.chr i done + +(* 1.33 +let rec loop s pos last st = + if pos < last then begin + ignore s.[pos]; + loop s (pos + 1) last st.next.(127) + end + +let exec s = loop s 0 (String.length s) st1 +*) + +(* 1.67 +let rec loop s pos last st = + if pos < last then begin + ignore s.[pos]; + loop s (pos + 1) last st.next.(127) + end + +let exec s = loop s 0 (String.length s) st1 +*) + +(* 1.76 +let rec loop s pos last st = + if pos < last then begin + let c = s.[pos] in + let st' = st.next.(Char.code c) in + loop s (pos + 1) last st' + end + +let exec s = loop s 0 (String.length s) st1 +*) + +(* 1.81 +let rec loop cols s pos last st = + if pos < last then begin + let c' = cols.[Char.code s.[pos]] in + let st' = st.next.(Char.code c') in + loop cols s (pos + 1) last st' + end + +let exec s = loop cols s 0 (String.length s) st1 +*) + +(* 1.84 +let rec loop info s pos last st = + if pos < last then begin + let c' = info.i_cols.[Char.code s.[pos]] in + let st' = st.next.(Char.code c') in + loop info s (pos + 1) last st' + end + +let exec s = + loop {i_cols = cols; last = String.length s} s 0 (String.length s) st1 +*) + +(* 1.95 +let rec loop info s pos last st = + if pos < info.last then begin + let c' = info.i_cols.[Char.code s.[pos]] in + let st' = st.next.(Char.code c') in + loop info s (pos + 1) last st' + end + +let exec s = + loop {i_cols = cols; last = String.length s} s 0 (String.length s) st1 +*) + +(* 1.85 +let rec loop info s pos cols st = + if pos < info.last then begin + let c' = cols.[Char.code s.[pos]] in + let st' = st.next.(Char.code c') in + loop info s (pos + 1) cols st' + end + +let exec s = loop {i_cols = cols; last = String.length s} s 0 cols st1 +*) + +let rec loop info s pos cols st = + if pos < info.last then begin + let c1 = cols.[Char.code s.[pos]] in + let st1 = st.next.(Char.code c1) in + let pos = pos + 1 in + let c2 = cols.[Char.code s.[pos]] in + let st2 = st1.next.(Char.code c2) in + let pos = pos + 1 in + let c3 = cols.[Char.code s.[pos]] in + let st3 = st2.next.(Char.code c3) in + let pos = pos + 1 in + let c4 = cols.[Char.code s.[pos]] in + let st4 = st3.next.(Char.code c4) in + loop info s (pos + 1) cols st4 + end + +let exec s = loop {i_cols = cols; last = String.length s} s 0 cols st1 + +(* 2.20 +let rec loop info s pos last st idx = + if idx >= 0 then begin + if pos < last then begin + let c' = info.i_cols.[Char.code s.[pos]] in + let st' = st.next.(Char.code c') in + let idx = st'.idx in + loop info s (pos + 1) last st' idx + end + end else + () + +let exec s = + loop {i_cols = cols; last = String.length s} s 0 (String.length s) st1 0 +*) + +(* +let rec loop info s pos cols st st' = + if pos < info.last then begin + let c' = cols.[Char.code s.[pos]] in + let idx = st.idx in + if idx >= 0 then begin + let st' = st.next.(Char.code c') in + loop info s (pos + 1) cols st' st + end else if idx = -1 then + () + else (* Unknown *) + validate info s pos st' + end + +and validate info s pos st' = validate info s pos st' + +let exec s = loop {i_cols = cols; last = String.length s} s 0 cols st1 st1 +*) + +let _ = + let s = String.make (1024*1024) 'a' in + s.[1024*1024-1] <- 'b'; + for _i = 0 to 99 do + ignore (exec s) + done diff -Nru ocaml-re-1.7.3/lib_test/old/test_exec_iter.ml ocaml-re-1.9.0/lib_test/old/test_exec_iter.ml --- ocaml-re-1.7.3/lib_test/old/test_exec_iter.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/test_exec_iter.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,20 @@ +#!/usr/bin/env ocaml +#use "topfind";; +#directory "_build/lib";; +#load "re.cma";; +#load "re_posix.cma";; +let re = Re.compile (Re_posix.re "a*(ab)");; +let s = "aaaaabaaa aaabaaabaaaabaa axbaaba";; + +let rec iter_gen f g = match g() with + | None -> () + | Some x -> f x; iter_gen f g +;; + +Re.Easy.iter_gen re s + |> iter_gen + (fun s -> + let i,j = Re.get_ofs s 0 in + Printf.printf "%s at %d,%d\n" (Re.get s 0) i j + );; + diff -Nru ocaml-re-1.7.3/lib_test/old/unison2.ml ocaml-re-1.9.0/lib_test/old/unison2.ml --- ocaml-re-1.7.3/lib_test/old/unison2.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/unison2.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,163 @@ +let desc = + [ `Path "lablgtk-1.00/config.make"; + `Path "lablgtk-1.00/lablgtktop_t"; + `Path "lablgtk-1.00/lablgtktop"; + `Path "lablgtk-1.00/lablgtkrun"; + `Path "lablgtk-1.00/lablgtk"; + `Path "unison3/src/unison"; + `Name "core"; + `Path "lipe/caisse/val_parse.h"; + `Path "lipe/caisse/val_parse.c"; + `Path "lipe/caisse/val_lex.c"; + `Path "lipe/caisse/caisse"; + `Path "lipe/runtime"; + `Path "lipe/demo"; + `Path "unison2/doc/unison-manual.ps"; + `Path "unison/doc/unison-mal.ps"; + `Name "*.ppi"; + `Path "unison2/src/unison"; + `Path "Xduce/xduce/pref.ml"; + `Path "Xduce/xduce/xduce{,.opt}"; + `Path "unison/src/TAGS"; + `Path "unison/src/unison"; + `Name "*.old"; + `Name "#*#"; + `Name "*.cm{i,o,x,a,xa}"; + `Name "*.vo"; + `Name "*{~,.aux,.bbl,.blg,.log,.toc,.o,.a}"; + `Name "gmon.out"; + `Name "ocamlprof.dump"; + `Name "CVS"; + `Name ".*.prcs_aux"; + `Path "icfp2000/tools/src2tex"; + `Path "icfp2000/temp.dvi"; + `Path "icfp2000/main.dvi"; + `Path "icfp2000/whole.dvi"; + `Path "icfp2000/regsub.ps"; + `Path "Views/main.dvi"; + `Path "lipe/perso/caisse"; + `Name "obsolete"; + `Path "misc/fingerprint/cksum/cksum"; + `Path "misc/relay/relay"; + `Path "Xduce/xduce.current/xduce.opt"; + `Path "Xduce/xduce.current/pref.ml"; + `Path "Xduce/xduce.new/pref.ml"; + `Path "Xduce/xduce.new/xduce.opt"; + `Path "profiler/profiler"; + `Path "ocaml/boot/Saved"; + `Path "ocaml/byterun/ocamlrun"; + `Path "ocaml/config/Makefile"; + `Path "ocaml/config/m.h"; + `Path "ocaml/config/s.h"; + `Path "ocaml/expunge"; + `Path "ocaml/asmcomp/arch.ml"; + `Path "ocaml/asmcomp/emit.ml"; + `Path "ocaml/asmcomp/proc.ml"; + `Path "ocaml/asmcomp/reload.ml"; + `Path "ocaml/asmcomp/scheduling.ml"; + `Path "ocaml/asmcomp/selection.ml"; + `Path "ocaml/debugger/ocamldebug"; + `Path "ocaml/lex/ocamllex"; + `Path "ocaml/ocaml"; + `Path "ocaml/ocamlc"; + `Path "ocaml/ocamlopt"; + `Path "ocaml/otherlibs/dynlink/extract_crc"; + `Path "ocaml/otherlibs/labltk/browser/ocamlbrowser"; + `Path "ocaml/otherlibs/labltk/compiler/tkcompiler"; + `Path "ocaml/otherlibs/str/regex-0.12/config.status"; + `Path "ocaml/stdlib/camlheader"; + `Path "ocaml/tools/cvt_emit"; + `Path "ocaml/boot/camlheader"; + `Path "ocaml/boot/ocamlrun"; + `Path "ocaml/boot/ocamlyacc"; + `Path "ocaml/otherlibs/labltk/lib/.depend"; + `Path "ocaml/otherlibs/labltk/lib/labltk"; + `Path "ocaml/otherlibs/labltk/lib/labltktop"; + `Path "ocaml/otherlibs/labltk/lib/tk.ml"; + `Path "ocaml/tools/ocamlcp"; + `Path "ocaml/tools/ocamldep"; + `Path "ocaml/tools/ocamlmktop"; + `Path "ocaml/tools/ocamlprof"; + `Path "ocaml/utils/config.ml"; + `Path "ocaml/yacc/ocamlyacc"; + `Path "Xduce/interleave/tools/src2tex"; + `Path "xml/parser"; + `Path "ocaml/ocamlopt.opt"; + `Path "ocaml/boot/ocamlc"; + `Path "ocaml/boot/ocamllex"; + `Path "ocaml/ocamlc.opt"; + `Path "specs/tools/src2f"; + `Path "specs/tools/src2tex" ] + +let paths = + [ "These"; + "Xduce"; + "unison"; + "unison2"; + "unison3"; + "tinkertype"; + "lipe"; + "icfp2000"; + "Views"; + "sync"; + "misc"; + "lablgtk-1.00"; + "mydb"; + "yacc"; + "db-papers"; + "submissions"; + "xml"; + "profiler"; + "specs"; + "ocaml"; + "rx" ] + +let rec children p = + let rec loop ch dir = + try + let file = Unix.readdir dir in + let ch' = + if file = "." || file = ".." then + ch + else + file :: ch in + loop ch' dir + with End_of_file -> + ch + in + let dir = Unix.opendir p in + let result = loop [] dir in + Unix.closedir dir; + result + +let is_dir p = + try + (Unix.lstat p).Unix.st_kind = Unix.S_DIR + with Unix.Unix_error _ -> + false + +let prefix ="/home/jerome/" + +let rec visit rx p = + if Rx.match_string rx p then +((*Format.eprintf "-%s@." p*)) +else begin +(*Format.eprintf "+%s@." p;*) + let fp = prefix ^ p in + if is_dir fp then + List.iter (fun n -> visit rx (p ^ "/" ^ n)) (children fp) +end + +let _ = + let rx = + Rx.alt + (List.map + (fun p -> + match p with + `Path s -> + Rx.globx s + | `Name s -> + Rx.seq [Rx.rx "(.*/)?"; Rx.globx s]) + desc); + in + List.iter (fun p -> visit rx p) paths diff -Nru ocaml-re-1.7.3/lib_test/old/unison3.ml ocaml-re-1.9.0/lib_test/old/unison3.ml --- ocaml-re-1.7.3/lib_test/old/unison3.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/unison3.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,204 @@ +let desc = + [ `Path "lablgtk-1.00/config.make"; + `Path "lablgtk-1.00/lablgtktop_t"; + `Path "lablgtk-1.00/lablgtktop"; + `Path "lablgtk-1.00/lablgtkrun"; + `Path "lablgtk-1.00/lablgtk"; + `Path "unison3/src/unison"; + `Name "core"; + `Path "lipe/caisse/val_parse.h"; + `Path "lipe/caisse/val_parse.c"; + `Path "lipe/caisse/val_lex.c"; + `Path "lipe/caisse/caisse"; + `Path "lipe/runtime"; + `Path "lipe/demo"; + `Path "unison2/doc/unison-manual.ps"; + `Path "unison/doc/unison-mal.ps"; + `Name "*.ppi"; + `Path "unison2/src/unison"; + `Path "Xduce/xduce/pref.ml"; + `Path "Xduce/xduce/xduce"; + `Path "Xduce/xduce/xduce.opt"; + `Path "unison/src/TAGS"; + `Path "unison/src/unison"; + `Name "*.old"; + `Name "#*#"; + `Name "*.cmi"; + `Name "*.cmo"; + `Name "*.cmx"; + `Name "*.cma"; + `Name "*.cmxa"; + `Name "*.vo"; + `Name "*~"; + `Name "*.aux"; + `Name "*.bbl"; + `Name "*.blg"; + `Name "*.log"; + `Name "*.toc"; + `Name "*.o"; + `Name "*.a"; + `Name "gmon.out"; + `Name "ocamlprof.dump"; + `Name "CVS"; + `Name ".*.prcs_aux"; + `Path "icfp2000/tools/src2tex"; + `Path "icfp2000/temp.dvi"; + `Path "icfp2000/main.dvi"; + `Path "icfp2000/whole.dvi"; + `Path "icfp2000/regsub.ps"; + `Path "Views/main.dvi"; + `Path "lipe/perso/caisse"; + `Name "obsolete"; + `Path "misc/fingerprint/cksum/cksum"; + `Path "misc/relay/relay"; + `Path "Xduce/xduce.current/xduce.opt"; + `Path "Xduce/xduce.current/pref.ml"; + `Path "Xduce/xduce.new/pref.ml"; + `Path "Xduce/xduce.new/xduce.opt"; + `Path "profiler/profiler"; + `Path "ocaml/boot/Saved"; + `Path "ocaml/byterun/ocamlrun"; + `Path "ocaml/config/Makefile"; + `Path "ocaml/config/m.h"; + `Path "ocaml/config/s.h"; + `Path "ocaml/expunge"; + `Path "ocaml/asmcomp/arch.ml"; + `Path "ocaml/asmcomp/emit.ml"; + `Path "ocaml/asmcomp/proc.ml"; + `Path "ocaml/asmcomp/reload.ml"; + `Path "ocaml/asmcomp/scheduling.ml"; + `Path "ocaml/asmcomp/selection.ml"; + `Path "ocaml/debugger/ocamldebug"; + `Path "ocaml/lex/ocamllex"; + `Path "ocaml/ocaml"; + `Path "ocaml/ocamlc"; + `Path "ocaml/ocamlopt"; + `Path "ocaml/otherlibs/dynlink/extract_crc"; + `Path "ocaml/otherlibs/labltk/browser/ocamlbrowser"; + `Path "ocaml/otherlibs/labltk/compiler/tkcompiler"; + `Path "ocaml/otherlibs/str/regex-0.12/config.status"; + `Path "ocaml/stdlib/camlheader"; + `Path "ocaml/tools/cvt_emit"; + `Path "ocaml/boot/camlheader"; + `Path "ocaml/boot/ocamlrun"; + `Path "ocaml/boot/ocamlyacc"; + `Path "ocaml/otherlibs/labltk/lib/.depend"; + `Path "ocaml/otherlibs/labltk/lib/labltk"; + `Path "ocaml/otherlibs/labltk/lib/labltktop"; + `Path "ocaml/otherlibs/labltk/lib/tk.ml"; + `Path "ocaml/tools/ocamlcp"; + `Path "ocaml/tools/ocamldep"; + `Path "ocaml/tools/ocamlmktop"; + `Path "ocaml/tools/ocamlprof"; + `Path "ocaml/utils/config.ml"; + `Path "ocaml/yacc/ocamlyacc"; + `Path "Xduce/interleave/tools/src2tex"; + `Path "xml/parser"; + `Path "ocaml/ocamlopt.opt"; + `Path "ocaml/boot/ocamlc"; + `Path "ocaml/boot/ocamllex"; + `Path "ocaml/ocamlc.opt"; + `Path "specs/tools/src2f"; + `Path "specs/tools/src2tex" ] + +let translate_char c = + match c with + '.' -> "\." + | '*' -> "[^/]*" + | _ -> String.make 1 c + +let translate_str s = + let res = ref "" in + for i = 0 to String.length s - 1 do + res := !res ^ translate_char s.[i] + done; + !res + +let paths = + [ "These"; + "Xduce"; + "unison"; + "unison2"; + "unison3"; + "tinkertype"; + "lipe"; + "icfp2000"; + "Views"; + "sync"; + "misc"; + "lablgtk-1.00"; + "mydb"; + "yacc"; + "db-papers"; + "submissions"; + "xml"; + "profiler"; + "specs"; + "ocaml"; + "rx" ] + +let rec children p = + let rec loop ch dir = + try + let file = Unix.readdir dir in + let ch' = + if file = "." || file = ".." then + ch + else + file :: ch in + loop ch' dir + with End_of_file -> + ch + in + let dir = Unix.opendir p in + let result = loop [] dir in + Unix.closedir dir; + result + +let is_dir p = + try + (Unix.lstat p).Unix.st_kind = Unix.S_DIR + with Unix.Unix_error _ -> + false + +let prefix ="/home/jerome/" + +let count = ref 0 +let rec visit rx p = +(*incr count; if !count > 50 then raise Exit;*) + try + ignore (Re_pcre.exec ~rex:rx p); +(*Format.eprintf "-%s@." p*) + with Not_found -> +(*Format.eprintf "+%s@." p;*) + let fp = prefix ^ p in + if is_dir fp then + List.iter (fun n -> visit rx (p ^ "/" ^ n)) (children fp) + +let _ = + let l = + List.map + (fun p -> + match p with + `Path s -> translate_str s + | `Name s -> "(?:.*/)?" ^ translate_str s) + desc + in + let rx = + "^(?:" ^ + begin match l with + x :: r -> + x ^ List.fold_right (fun x rem -> "|" ^ x ^ rem) r "" + | [] -> + assert false + end + ^ ")$" + in +Format.eprintf "%s@." rx; +for i = 0 to 9 do +count := 0; + let rx = Re_pcre.regexp rx in +try + List.iter (fun p -> visit rx p) paths +with Exit -> () +done diff -Nru ocaml-re-1.7.3/lib_test/old/unison.ml ocaml-re-1.9.0/lib_test/old/unison.ml --- ocaml-re-1.7.3/lib_test/old/unison.ml 1970-01-01 00:00:00.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/old/unison.ml 2019-04-06 07:05:39.000000000 +0000 @@ -0,0 +1,180 @@ +let desc = + [ `Path "lablgtk-1.00/config.make"; + `Path "lablgtk-1.00/lablgtktop_t"; + `Path "lablgtk-1.00/lablgtktop"; + `Path "lablgtk-1.00/lablgtkrun"; + `Path "lablgtk-1.00/lablgtk"; + `Path "unison3/src/unison"; + `Name "core"; + `Path "lipe/caisse/val_parse.h"; + `Path "lipe/caisse/val_parse.c"; + `Path "lipe/caisse/val_lex.c"; + `Path "lipe/caisse/caisse"; + `Path "lipe/runtime"; + `Path "lipe/demo"; + `Path "unison2/doc/unison-manual.ps"; + `Path "unison/doc/unison-mal.ps"; + `Name "*.ppi"; + `Path "unison2/src/unison"; + `Path "Xduce/xduce/pref.ml"; + `Path "Xduce/xduce/xduce{,.opt}"; + `Path "unison/src/TAGS"; + `Path "unison/src/unison"; + `Name "*.old"; + `Name "#*#"; + `Name "*.cm{i,o,x,a,xa}"; + `Name "*.vo"; + `Name "*{~,.aux,.bbl,.blg,.log,.toc,.o,.a}"; + `Name "gmon.out"; + `Name "ocamlprof.dump"; + `Name "CVS"; + `Name ".*.prcs_aux"; + `Path "icfp2000/tools/src2tex"; + `Path "icfp2000/temp.dvi"; + `Path "icfp2000/main.dvi"; + `Path "icfp2000/whole.dvi"; + `Path "icfp2000/regsub.ps"; + `Path "Views/main.dvi"; + `Path "lipe/perso/caisse"; + `Name "obsolete"; + `Path "misc/fingerprint/cksum/cksum"; + `Path "misc/relay/relay"; + `Path "Xduce/xduce.current/xduce.opt"; + `Path "Xduce/xduce.current/pref.ml"; + `Path "Xduce/xduce.new/pref.ml"; + `Path "Xduce/xduce.new/xduce.opt"; + `Path "profiler/profiler"; + `Path "ocaml/boot/Saved"; + `Path "ocaml/byterun/ocamlrun"; + `Path "ocaml/config/Makefile"; + `Path "ocaml/config/m.h"; + `Path "ocaml/config/s.h"; + `Path "ocaml/expunge"; + `Path "ocaml/asmcomp/arch.ml"; + `Path "ocaml/asmcomp/emit.ml"; + `Path "ocaml/asmcomp/proc.ml"; + `Path "ocaml/asmcomp/reload.ml"; + `Path "ocaml/asmcomp/scheduling.ml"; + `Path "ocaml/asmcomp/selection.ml"; + `Path "ocaml/debugger/ocamldebug"; + `Path "ocaml/lex/ocamllex"; + `Path "ocaml/ocaml"; + `Path "ocaml/ocamlc"; + `Path "ocaml/ocamlopt"; + `Path "ocaml/otherlibs/dynlink/extract_crc"; + `Path "ocaml/otherlibs/labltk/browser/ocamlbrowser"; + `Path "ocaml/otherlibs/labltk/compiler/tkcompiler"; + `Path "ocaml/otherlibs/str/regex-0.12/config.status"; + `Path "ocaml/stdlib/camlheader"; + `Path "ocaml/tools/cvt_emit"; + `Path "ocaml/boot/camlheader"; + `Path "ocaml/boot/ocamlrun"; + `Path "ocaml/boot/ocamlyacc"; + `Path "ocaml/otherlibs/labltk/lib/.depend"; + `Path "ocaml/otherlibs/labltk/lib/labltk"; + `Path "ocaml/otherlibs/labltk/lib/labltktop"; + `Path "ocaml/otherlibs/labltk/lib/tk.ml"; + `Path "ocaml/tools/ocamlcp"; + `Path "ocaml/tools/ocamldep"; + `Path "ocaml/tools/ocamlmktop"; + `Path "ocaml/tools/ocamlprof"; + `Path "ocaml/utils/config.ml"; + `Path "ocaml/yacc/ocamlyacc"; + `Path "Xduce/interleave/tools/src2tex"; + `Path "xml/parser"; + `Path "ocaml/ocamlopt.opt"; + `Path "ocaml/boot/ocamlc"; + `Path "ocaml/boot/ocamllex"; + `Path "ocaml/ocamlc.opt"; + `Path "specs/tools/src2f"; + `Path "specs/tools/src2tex" ] + +let paths = + [ "These"; + "Xduce"; + "unison"; + "unison2"; + "unison3"; + "tinkertype"; + "lipe"; + "icfp2000"; + "Views"; + "sync"; + "misc"; + "lablgtk-1.00"; + "mydb"; + "yacc"; + "db-papers"; + "submissions"; + "xml"; + "profiler"; + "specs"; + "ocaml"; + "rx" ] + +let rec children p = + let rec loop ch dir = + try + let file = Unix.readdir dir in + let ch' = + if file = "." || file = ".." then + ch + else + file :: ch in + loop ch' dir + with End_of_file -> + ch + in + let dir = Unix.opendir p in + let result = loop [] dir in + Unix.closedir dir; + result + +let is_dir p = + try + (Unix.lstat p).Unix.st_kind = Unix.S_DIR + with Unix.Unix_error _ -> + false + +let prefix ="/home/jerome/" + +let count = ref 0 +let hit = ref 0 +let rec visit rx p = +(*incr count; if !count > 0 then raise Exit;*) + try +incr count; + ignore (Re.exec ~group:false rx p); +(*Format.eprintf "-%s@." p*) + with Not_found -> +(*Format.eprintf "+%s@." p;*) + let fp = prefix ^ p in +incr hit; + if is_dir fp then + List.iter (fun n -> visit rx (p ^ "/" ^ n)) (children fp) + +let _ = +for i = 0 to 9 do +count := 0; hit := 0; + let rx = + Re.seq + [ Re.bos; + Re.alt + (List.map + (fun p -> + match p with + `Path s -> + Re.Glob.globx s + | `Name s -> + Re.seq [Re.no_group (Re_posix.re "(.*/)?"); + Re.Glob.globx s]) + desc); + Re.eos ] + in + let rx = Re.compile rx in +begin try + List.iter (fun p -> visit rx p) paths +with Exit -> () end; +Format.eprintf "%d/%d@." !hit !count; +done + diff -Nru ocaml-re-1.7.3/lib_test/pcre_match.ml ocaml-re-1.9.0/lib_test/pcre_match.ml --- ocaml-re-1.7.3/lib_test/pcre_match.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/pcre_match.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -(* - * $Id: pcre_match.ml,v 1.1.1.1 2001/09/21 15:54:12 vouillon Exp $ - * http://www.bagley.org/~doug/shootout/ - * from: Markus Mottl - *) - -open Re_pcre - -let rex = - regexp ~flags:[`EXTENDED] - "(?: ^ | [^\d\(]) # must be preceeded by non-digit - (\(\d\d\d\)|\d\d\d) # match 1: area code - [ ] # area code followed by one space - \d\d\d # prefix of 3 digits - [ -] # separator is either space or dash - \d\d\d\d # last 4 digits - (?: \D|$) # must be followed by a non-digit (or EOL)" - -let phones = - let lines = ref [] in - foreach_line (fun line -> lines := line :: !lines); - List.rev !lines - -let check_phone irflags ar cnt must_print line = - try - unsafe_pcre_exec irflags rex 0 line 4 ar; - let num = String.copy "(...) ...-...." and pos = Array.unsafe_get ar 2 in - let ofs = if String.unsafe_get line pos = '(' then 1 else 0 in - let pos = pos + ofs in - String.unsafe_blit line pos num 1 3; - let pos = pos + ofs + 4 in - String.unsafe_blit line pos num 6 3; - String.unsafe_blit line (pos + 4) num 10 4; - if must_print then Printf.printf "%d: %s\n" !cnt num; - incr cnt - with Not_found -> () - -let n = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 1;; -for i = 2 to n do - List.iter (check_phone (rflags []) (Array.create 6 0) (ref 1) false) phones -done; -List.iter (check_phone (rflags []) (Array.create 6 0) (ref 1) true) phones diff -Nru ocaml-re-1.7.3/lib_test/pcre_scan.ml ocaml-re-1.9.0/lib_test/pcre_scan.ml --- ocaml-re-1.7.3/lib_test/pcre_scan.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/pcre_scan.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ - -let x = Re_pcre.regexp "aa?b" -let _ = - let s = String.make (1024*1024) 'a' in - s.[1024*1024-1] <- 'b'; - for _i = 0 to 99 do - ignore (Re_pcre.exec ~rex:x s) - done diff -Nru ocaml-re-1.7.3/lib_test/perl_scan.pl ocaml-re-1.9.0/lib_test/perl_scan.pl --- ocaml-re-1.7.3/lib_test/perl_scan.pl 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/perl_scan.pl 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -$s = 'a' x (1024 * 1024 - 1) . 'b'; -for ($i = 1; $i < 100; $i++) { -print "$&\n" if $s =~ /aa?b/ ; -} diff -Nru ocaml-re-1.7.3/lib_test/re_match.ml ocaml-re-1.9.0/lib_test/re_match.ml --- ocaml-re-1.7.3/lib_test/re_match.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/re_match.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -(* - * $Id: re_match.ml,v 1.2 2001/10/03 15:04:59 vouillon Exp $ - * http://www.bagley.org/~doug/shootout/ - * from: Markus Mottl - *) - -let rex = - let three_digits = Re.seq [Re.digit; Re.digit; Re.digit] in - Re.compile - (Re.seq - [(* Must be preceeded by a non-digit *) - Re.alt [Re.bol; Re.compl [Re.digit; Re.char '(']]; - (* Area code *) - Re.group (Re.alt [Re.seq [Re.char '('; three_digits; Re.char ')']; - three_digits]); - (* One space *) - Re.char ' '; - (* Prefix of 3 digits *) - three_digits; - (* Separator: either a space or a dash *) - Re.set " -"; - (* Last for digits *) - three_digits; Re.digit; - (* Must be followed by a non-digit (or EOL) *) - Re.alt [Re.eol; Re.compl [Re.digit]]]) - -let foreach_line ?(ic = stdin) f = - try while true do f (input_line ic) done with End_of_file -> () - -let phones = - let lines = ref [] in -let ic = open_in "Input" in - foreach_line ~ic (fun line -> lines := line :: !lines); -close_in ic; - List.rev !lines - -let check_phone cnt must_print line = - try - let matches = Re.exec rex line in - let num = "(...) ...-...." in - let (pos, _) = Re.Group.offset matches 1 in - let ofs = if line.[pos] = '(' then 1 else 0 in - let pos = pos + ofs in - String.blit line pos num 1 3; - let pos = pos + ofs + 4 in - String.blit line pos num 6 3; - String.blit line (pos + 4) num 10 4; - if must_print then Printf.printf "%d: %s\n" !cnt num; - incr cnt - with Not_found -> () - -let n = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 1;; -for _i = 2 to n do - List.iter (check_phone (ref 1) false) phones -done; -List.iter (check_phone (ref 1) true) phones diff -Nru ocaml-re-1.7.3/lib_test/re_scan.ml ocaml-re-1.9.0/lib_test/re_scan.ml --- ocaml-re-1.7.3/lib_test/re_scan.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/re_scan.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - -open Re - -let x = compile (seq [char 'a'; opt (char 'a'); char 'b']) -let _ = - let s = String.make (1024*1024) 'a' in - s.[1024*1024-1] <- 'b'; - for _i = 0 to 99 do - ignore (exec x s) - done diff -Nru ocaml-re-1.7.3/lib_test/scan.ml ocaml-re-1.9.0/lib_test/scan.ml --- ocaml-re-1.7.3/lib_test/scan.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/scan.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -type state = - { idx : int; - next : state array } - -type info = { i_cols : string; last : int } - -let unknown = {idx = -1; next = [||]} -let st1 = { idx = 0; next = Array.make 256 unknown } -let st2 = { idx = 0; next = Array.make 256 st1 } -let cols = String.create 256 - -let _ = - for i = 0 to 255 do st1.next.(i) <- st2; cols.[i] <- Char.chr i done - -(* 1.33 -let rec loop s pos last st = - if pos < last then begin - ignore s.[pos]; - loop s (pos + 1) last st.next.(127) - end - -let exec s = loop s 0 (String.length s) st1 -*) - -(* 1.67 -let rec loop s pos last st = - if pos < last then begin - ignore s.[pos]; - loop s (pos + 1) last st.next.(127) - end - -let exec s = loop s 0 (String.length s) st1 -*) - -(* 1.76 -let rec loop s pos last st = - if pos < last then begin - let c = s.[pos] in - let st' = st.next.(Char.code c) in - loop s (pos + 1) last st' - end - -let exec s = loop s 0 (String.length s) st1 -*) - -(* 1.81 -let rec loop cols s pos last st = - if pos < last then begin - let c' = cols.[Char.code s.[pos]] in - let st' = st.next.(Char.code c') in - loop cols s (pos + 1) last st' - end - -let exec s = loop cols s 0 (String.length s) st1 -*) - -(* 1.84 -let rec loop info s pos last st = - if pos < last then begin - let c' = info.i_cols.[Char.code s.[pos]] in - let st' = st.next.(Char.code c') in - loop info s (pos + 1) last st' - end - -let exec s = - loop {i_cols = cols; last = String.length s} s 0 (String.length s) st1 -*) - -(* 1.95 -let rec loop info s pos last st = - if pos < info.last then begin - let c' = info.i_cols.[Char.code s.[pos]] in - let st' = st.next.(Char.code c') in - loop info s (pos + 1) last st' - end - -let exec s = - loop {i_cols = cols; last = String.length s} s 0 (String.length s) st1 -*) - -(* 1.85 -let rec loop info s pos cols st = - if pos < info.last then begin - let c' = cols.[Char.code s.[pos]] in - let st' = st.next.(Char.code c') in - loop info s (pos + 1) cols st' - end - -let exec s = loop {i_cols = cols; last = String.length s} s 0 cols st1 -*) - -let rec loop info s pos cols st = - if pos < info.last then begin - let c1 = cols.[Char.code s.[pos]] in - let st1 = st.next.(Char.code c1) in - let pos = pos + 1 in - let c2 = cols.[Char.code s.[pos]] in - let st2 = st1.next.(Char.code c2) in - let pos = pos + 1 in - let c3 = cols.[Char.code s.[pos]] in - let st3 = st2.next.(Char.code c3) in - let pos = pos + 1 in - let c4 = cols.[Char.code s.[pos]] in - let st4 = st3.next.(Char.code c4) in - loop info s (pos + 1) cols st4 - end - -let exec s = loop {i_cols = cols; last = String.length s} s 0 cols st1 - -(* 2.20 -let rec loop info s pos last st idx = - if idx >= 0 then begin - if pos < last then begin - let c' = info.i_cols.[Char.code s.[pos]] in - let st' = st.next.(Char.code c') in - let idx = st'.idx in - loop info s (pos + 1) last st' idx - end - end else - () - -let exec s = - loop {i_cols = cols; last = String.length s} s 0 (String.length s) st1 0 -*) - -(* -let rec loop info s pos cols st st' = - if pos < info.last then begin - let c' = cols.[Char.code s.[pos]] in - let idx = st.idx in - if idx >= 0 then begin - let st' = st.next.(Char.code c') in - loop info s (pos + 1) cols st' st - end else if idx = -1 then - () - else (* Unknown *) - validate info s pos st' - end - -and validate info s pos st' = validate info s pos st' - -let exec s = loop {i_cols = cols; last = String.length s} s 0 cols st1 st1 -*) - -let _ = - let s = String.make (1024*1024) 'a' in - s.[1024*1024-1] <- 'b'; - for _i = 0 to 99 do - ignore (exec s) - done diff -Nru ocaml-re-1.7.3/lib_test/test_easy.ml ocaml-re-1.9.0/lib_test/test_easy.ml --- ocaml-re-1.7.3/lib_test/test_easy.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/test_easy.ml 2019-04-06 07:05:39.000000000 +0000 @@ -2,7 +2,15 @@ open OUnit -let (|>) x f = f x +module String = struct + [@@@ocaml.warning "-32-3"] + let capitalize_ascii = String.capitalize + let uncapitalize_ascii = String.uncapitalize + let uppercase_ascii = String.uppercase + let lowercase_ascii = String.lowercase + + include String +end let pp_str x = x let quote = Printf.sprintf "'%s'" @@ -12,14 +20,14 @@ |> String.concat ", " |> Printf.sprintf "[ %s ]" -let re_whitespace = Re_posix.compile_pat "[\t ]+" -let re_empty = Re_posix.compile_pat "" +let re_whitespace = Re.Posix.compile_pat "[\t ]+" +let re_empty = Re.Posix.compile_pat "" let re_eol = Re.compile Re.eol let re_bow = Re.compile Re.bow let re_eow = Re.compile Re.eow let test_iter () = - let re = Re_posix.compile_pat "(ab)+" in + let re = Re.Posix.compile_pat "(ab)+" in assert_equal ~printer:pp_list ["abab"; "ab"; "ab"] (Re.matches re "aabab aaabba dab "); assert_equal ~printer:pp_list @@ -76,8 +84,8 @@ () let test_replace () = - let re = Re_posix.compile_pat "[a-zA-Z]+" in - let f sub = String.capitalize (Re.Group.get sub 0) in + let re = Re.Posix.compile_pat "[a-zA-Z]+" in + let f sub = String.capitalize_ascii (Re.Group.get sub 0) in assert_equal ~printer:pp_str " Hello World; I Love Chips!" (Re.replace re ~f " hello world; I love chips!"); assert_equal ~printer:pp_str " Allo maman, bobo" @@ -85,7 +93,7 @@ () let test_replace_string () = - let re = Re_posix.compile_pat "_[a-zA-Z]+_" in + let re = Re.Posix.compile_pat "_[a-zA-Z]+_" in assert_equal ~printer:pp_str "goodbye world" (Re.replace_string re ~by:"goodbye" "_hello_ world"); assert_equal ~printer:pp_str "The quick brown fox" diff -Nru ocaml-re-1.7.3/lib_test/test_exec_iter.ml ocaml-re-1.9.0/lib_test/test_exec_iter.ml --- ocaml-re-1.7.3/lib_test/test_exec_iter.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/test_exec_iter.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#!/usr/bin/env ocaml -#use "topfind";; -#directory "_build/lib";; -#load "re.cma";; -#load "re_posix.cma";; -let re = Re.compile (Re_posix.re "a*(ab)");; -let s = "aaaaabaaa aaabaaabaaaabaa axbaaba";; - -let rec iter_gen f g = match g() with - | None -> () - | Some x -> f x; iter_gen f g -;; - -Re.Easy.iter_gen re s - |> iter_gen - (fun s -> - let i,j = Re.get_ofs s 0 in - Printf.printf "%s at %d,%d\n" (Re.get s 0) i j - );; - diff -Nru ocaml-re-1.7.3/lib_test/test_perl.ml ocaml-re-1.9.0/lib_test/test_perl.ml --- ocaml-re-1.7.3/lib_test/test_perl.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/test_perl.ml 2019-04-06 07:05:39.000000000 +0000 @@ -5,6 +5,10 @@ let eq_re ?opts r s = expect_equal_app ~msg:s id r (re ?opts) s ;; +let parse_error_re ?opts s = + try ignore (re ?opts s); OUnit2.assert_failure s with + | Re.Perl.Parse_error -> () + (* * Tests based on description of Perl regular expressions given at * http://www.perl.com/CPAN-local/doc/manual/html/pod/perlre.html @@ -61,6 +65,10 @@ eq_re (alt [char '^'; char 'a']) "[a^]"; eq_re (compl [rg 'a' 'z']) "[^a-z]"; eq_re (compl [char '$'; rg 'a' 'z']) "[^a-z$]"; + eq_re (alt [char 'z'; char 'a'; char '-'; space]) + "[a-\\sz]"; + parse_error_re "[\\"; + parse_error_re "[a-\\s"; ); expect_pass "greedy quantifiers" (fun () -> @@ -121,6 +129,7 @@ expect_pass "comments" (fun () -> eq_re (seq [char 'a'; epsilon; char 'b']) "a(?#comment)b"; + parse_error_re "(?#"; ); expect_pass "clustering" (fun () -> diff -Nru ocaml-re-1.7.3/lib_test/test_re.ml ocaml-re-1.9.0/lib_test/test_re.ml --- ocaml-re-1.7.3/lib_test/test_re.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/test_re.ml 2019-04-06 07:05:39.000000000 +0000 @@ -1,6 +1,8 @@ +module L = List open Re open OUnit2 open Fort_unit +module List = L let re_match ?pos ?len r s res = expect_equal_app @@ -446,4 +448,21 @@ fail "bug in Re.handle_case" ); + let test msg re input expected = + expect_pass msg (fun () -> + expect_equal_app id expected id (exec_partial (compile re) input) ~printer:(function + | `Partial -> "`Partial" + | `Full -> "`Full" + | `Mismatch -> "`Mismatch")) + in + test "exec_partial 1" (str "hello") "he" `Partial; + test "exec_partial 2" (str "hello") "goodbye" `Partial; + (* exec_partial 3 shoudl be `Full *) + test "exec_partial 3" (str "hello") "hello" `Partial; + test "exec_partial 4" (whole_string (str "hello")) "hello" `Partial; + test "exec_partial 5" (whole_string (str "hello")) "goodbye" `Mismatch; + test "exec_partial 6" (str "hello") "" `Partial; + test "exec_partial 7" (str "") "hello" `Full; + test "exec_partial 8" (whole_string (str "hello")) "" `Partial; + run_test_suite "test_re" diff -Nru ocaml-re-1.7.3/lib_test/unison2.ml ocaml-re-1.9.0/lib_test/unison2.ml --- ocaml-re-1.7.3/lib_test/unison2.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/unison2.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ -let desc = - [ `Path "lablgtk-1.00/config.make"; - `Path "lablgtk-1.00/lablgtktop_t"; - `Path "lablgtk-1.00/lablgtktop"; - `Path "lablgtk-1.00/lablgtkrun"; - `Path "lablgtk-1.00/lablgtk"; - `Path "unison3/src/unison"; - `Name "core"; - `Path "lipe/caisse/val_parse.h"; - `Path "lipe/caisse/val_parse.c"; - `Path "lipe/caisse/val_lex.c"; - `Path "lipe/caisse/caisse"; - `Path "lipe/runtime"; - `Path "lipe/demo"; - `Path "unison2/doc/unison-manual.ps"; - `Path "unison/doc/unison-mal.ps"; - `Name "*.ppi"; - `Path "unison2/src/unison"; - `Path "Xduce/xduce/pref.ml"; - `Path "Xduce/xduce/xduce{,.opt}"; - `Path "unison/src/TAGS"; - `Path "unison/src/unison"; - `Name "*.old"; - `Name "#*#"; - `Name "*.cm{i,o,x,a,xa}"; - `Name "*.vo"; - `Name "*{~,.aux,.bbl,.blg,.log,.toc,.o,.a}"; - `Name "gmon.out"; - `Name "ocamlprof.dump"; - `Name "CVS"; - `Name ".*.prcs_aux"; - `Path "icfp2000/tools/src2tex"; - `Path "icfp2000/temp.dvi"; - `Path "icfp2000/main.dvi"; - `Path "icfp2000/whole.dvi"; - `Path "icfp2000/regsub.ps"; - `Path "Views/main.dvi"; - `Path "lipe/perso/caisse"; - `Name "obsolete"; - `Path "misc/fingerprint/cksum/cksum"; - `Path "misc/relay/relay"; - `Path "Xduce/xduce.current/xduce.opt"; - `Path "Xduce/xduce.current/pref.ml"; - `Path "Xduce/xduce.new/pref.ml"; - `Path "Xduce/xduce.new/xduce.opt"; - `Path "profiler/profiler"; - `Path "ocaml/boot/Saved"; - `Path "ocaml/byterun/ocamlrun"; - `Path "ocaml/config/Makefile"; - `Path "ocaml/config/m.h"; - `Path "ocaml/config/s.h"; - `Path "ocaml/expunge"; - `Path "ocaml/asmcomp/arch.ml"; - `Path "ocaml/asmcomp/emit.ml"; - `Path "ocaml/asmcomp/proc.ml"; - `Path "ocaml/asmcomp/reload.ml"; - `Path "ocaml/asmcomp/scheduling.ml"; - `Path "ocaml/asmcomp/selection.ml"; - `Path "ocaml/debugger/ocamldebug"; - `Path "ocaml/lex/ocamllex"; - `Path "ocaml/ocaml"; - `Path "ocaml/ocamlc"; - `Path "ocaml/ocamlopt"; - `Path "ocaml/otherlibs/dynlink/extract_crc"; - `Path "ocaml/otherlibs/labltk/browser/ocamlbrowser"; - `Path "ocaml/otherlibs/labltk/compiler/tkcompiler"; - `Path "ocaml/otherlibs/str/regex-0.12/config.status"; - `Path "ocaml/stdlib/camlheader"; - `Path "ocaml/tools/cvt_emit"; - `Path "ocaml/boot/camlheader"; - `Path "ocaml/boot/ocamlrun"; - `Path "ocaml/boot/ocamlyacc"; - `Path "ocaml/otherlibs/labltk/lib/.depend"; - `Path "ocaml/otherlibs/labltk/lib/labltk"; - `Path "ocaml/otherlibs/labltk/lib/labltktop"; - `Path "ocaml/otherlibs/labltk/lib/tk.ml"; - `Path "ocaml/tools/ocamlcp"; - `Path "ocaml/tools/ocamldep"; - `Path "ocaml/tools/ocamlmktop"; - `Path "ocaml/tools/ocamlprof"; - `Path "ocaml/utils/config.ml"; - `Path "ocaml/yacc/ocamlyacc"; - `Path "Xduce/interleave/tools/src2tex"; - `Path "xml/parser"; - `Path "ocaml/ocamlopt.opt"; - `Path "ocaml/boot/ocamlc"; - `Path "ocaml/boot/ocamllex"; - `Path "ocaml/ocamlc.opt"; - `Path "specs/tools/src2f"; - `Path "specs/tools/src2tex" ] - -let paths = - [ "These"; - "Xduce"; - "unison"; - "unison2"; - "unison3"; - "tinkertype"; - "lipe"; - "icfp2000"; - "Views"; - "sync"; - "misc"; - "lablgtk-1.00"; - "mydb"; - "yacc"; - "db-papers"; - "submissions"; - "xml"; - "profiler"; - "specs"; - "ocaml"; - "rx" ] - -let rec children p = - let rec loop ch dir = - try - let file = Unix.readdir dir in - let ch' = - if file = "." || file = ".." then - ch - else - file :: ch in - loop ch' dir - with End_of_file -> - ch - in - let dir = Unix.opendir p in - let result = loop [] dir in - Unix.closedir dir; - result - -let is_dir p = - try - (Unix.lstat p).Unix.st_kind = Unix.S_DIR - with Unix.Unix_error _ -> - false - -let prefix ="/home/jerome/" - -let rec visit rx p = - if Rx.match_string rx p then -((*Format.eprintf "-%s@." p*)) -else begin -(*Format.eprintf "+%s@." p;*) - let fp = prefix ^ p in - if is_dir fp then - List.iter (fun n -> visit rx (p ^ "/" ^ n)) (children fp) -end - -let _ = - let rx = - Rx.alt - (List.map - (fun p -> - match p with - `Path s -> - Rx.globx s - | `Name s -> - Rx.seq [Rx.rx "(.*/)?"; Rx.globx s]) - desc); - in - List.iter (fun p -> visit rx p) paths diff -Nru ocaml-re-1.7.3/lib_test/unison3.ml ocaml-re-1.9.0/lib_test/unison3.ml --- ocaml-re-1.7.3/lib_test/unison3.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/unison3.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,204 +0,0 @@ -let desc = - [ `Path "lablgtk-1.00/config.make"; - `Path "lablgtk-1.00/lablgtktop_t"; - `Path "lablgtk-1.00/lablgtktop"; - `Path "lablgtk-1.00/lablgtkrun"; - `Path "lablgtk-1.00/lablgtk"; - `Path "unison3/src/unison"; - `Name "core"; - `Path "lipe/caisse/val_parse.h"; - `Path "lipe/caisse/val_parse.c"; - `Path "lipe/caisse/val_lex.c"; - `Path "lipe/caisse/caisse"; - `Path "lipe/runtime"; - `Path "lipe/demo"; - `Path "unison2/doc/unison-manual.ps"; - `Path "unison/doc/unison-mal.ps"; - `Name "*.ppi"; - `Path "unison2/src/unison"; - `Path "Xduce/xduce/pref.ml"; - `Path "Xduce/xduce/xduce"; - `Path "Xduce/xduce/xduce.opt"; - `Path "unison/src/TAGS"; - `Path "unison/src/unison"; - `Name "*.old"; - `Name "#*#"; - `Name "*.cmi"; - `Name "*.cmo"; - `Name "*.cmx"; - `Name "*.cma"; - `Name "*.cmxa"; - `Name "*.vo"; - `Name "*~"; - `Name "*.aux"; - `Name "*.bbl"; - `Name "*.blg"; - `Name "*.log"; - `Name "*.toc"; - `Name "*.o"; - `Name "*.a"; - `Name "gmon.out"; - `Name "ocamlprof.dump"; - `Name "CVS"; - `Name ".*.prcs_aux"; - `Path "icfp2000/tools/src2tex"; - `Path "icfp2000/temp.dvi"; - `Path "icfp2000/main.dvi"; - `Path "icfp2000/whole.dvi"; - `Path "icfp2000/regsub.ps"; - `Path "Views/main.dvi"; - `Path "lipe/perso/caisse"; - `Name "obsolete"; - `Path "misc/fingerprint/cksum/cksum"; - `Path "misc/relay/relay"; - `Path "Xduce/xduce.current/xduce.opt"; - `Path "Xduce/xduce.current/pref.ml"; - `Path "Xduce/xduce.new/pref.ml"; - `Path "Xduce/xduce.new/xduce.opt"; - `Path "profiler/profiler"; - `Path "ocaml/boot/Saved"; - `Path "ocaml/byterun/ocamlrun"; - `Path "ocaml/config/Makefile"; - `Path "ocaml/config/m.h"; - `Path "ocaml/config/s.h"; - `Path "ocaml/expunge"; - `Path "ocaml/asmcomp/arch.ml"; - `Path "ocaml/asmcomp/emit.ml"; - `Path "ocaml/asmcomp/proc.ml"; - `Path "ocaml/asmcomp/reload.ml"; - `Path "ocaml/asmcomp/scheduling.ml"; - `Path "ocaml/asmcomp/selection.ml"; - `Path "ocaml/debugger/ocamldebug"; - `Path "ocaml/lex/ocamllex"; - `Path "ocaml/ocaml"; - `Path "ocaml/ocamlc"; - `Path "ocaml/ocamlopt"; - `Path "ocaml/otherlibs/dynlink/extract_crc"; - `Path "ocaml/otherlibs/labltk/browser/ocamlbrowser"; - `Path "ocaml/otherlibs/labltk/compiler/tkcompiler"; - `Path "ocaml/otherlibs/str/regex-0.12/config.status"; - `Path "ocaml/stdlib/camlheader"; - `Path "ocaml/tools/cvt_emit"; - `Path "ocaml/boot/camlheader"; - `Path "ocaml/boot/ocamlrun"; - `Path "ocaml/boot/ocamlyacc"; - `Path "ocaml/otherlibs/labltk/lib/.depend"; - `Path "ocaml/otherlibs/labltk/lib/labltk"; - `Path "ocaml/otherlibs/labltk/lib/labltktop"; - `Path "ocaml/otherlibs/labltk/lib/tk.ml"; - `Path "ocaml/tools/ocamlcp"; - `Path "ocaml/tools/ocamldep"; - `Path "ocaml/tools/ocamlmktop"; - `Path "ocaml/tools/ocamlprof"; - `Path "ocaml/utils/config.ml"; - `Path "ocaml/yacc/ocamlyacc"; - `Path "Xduce/interleave/tools/src2tex"; - `Path "xml/parser"; - `Path "ocaml/ocamlopt.opt"; - `Path "ocaml/boot/ocamlc"; - `Path "ocaml/boot/ocamllex"; - `Path "ocaml/ocamlc.opt"; - `Path "specs/tools/src2f"; - `Path "specs/tools/src2tex" ] - -let translate_char c = - match c with - '.' -> "\." - | '*' -> "[^/]*" - | _ -> String.make 1 c - -let translate_str s = - let res = ref "" in - for i = 0 to String.length s - 1 do - res := !res ^ translate_char s.[i] - done; - !res - -let paths = - [ "These"; - "Xduce"; - "unison"; - "unison2"; - "unison3"; - "tinkertype"; - "lipe"; - "icfp2000"; - "Views"; - "sync"; - "misc"; - "lablgtk-1.00"; - "mydb"; - "yacc"; - "db-papers"; - "submissions"; - "xml"; - "profiler"; - "specs"; - "ocaml"; - "rx" ] - -let rec children p = - let rec loop ch dir = - try - let file = Unix.readdir dir in - let ch' = - if file = "." || file = ".." then - ch - else - file :: ch in - loop ch' dir - with End_of_file -> - ch - in - let dir = Unix.opendir p in - let result = loop [] dir in - Unix.closedir dir; - result - -let is_dir p = - try - (Unix.lstat p).Unix.st_kind = Unix.S_DIR - with Unix.Unix_error _ -> - false - -let prefix ="/home/jerome/" - -let count = ref 0 -let rec visit rx p = -(*incr count; if !count > 50 then raise Exit;*) - try - ignore (Re_pcre.exec ~rex:rx p); -(*Format.eprintf "-%s@." p*) - with Not_found -> -(*Format.eprintf "+%s@." p;*) - let fp = prefix ^ p in - if is_dir fp then - List.iter (fun n -> visit rx (p ^ "/" ^ n)) (children fp) - -let _ = - let l = - List.map - (fun p -> - match p with - `Path s -> translate_str s - | `Name s -> "(?:.*/)?" ^ translate_str s) - desc - in - let rx = - "^(?:" ^ - begin match l with - x :: r -> - x ^ List.fold_right (fun x rem -> "|" ^ x ^ rem) r "" - | [] -> - assert false - end - ^ ")$" - in -Format.eprintf "%s@." rx; -for i = 0 to 9 do -count := 0; - let rx = Re_pcre.regexp rx in -try - List.iter (fun p -> visit rx p) paths -with Exit -> () -done diff -Nru ocaml-re-1.7.3/lib_test/unison.ml ocaml-re-1.9.0/lib_test/unison.ml --- ocaml-re-1.7.3/lib_test/unison.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/lib_test/unison.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ -let desc = - [ `Path "lablgtk-1.00/config.make"; - `Path "lablgtk-1.00/lablgtktop_t"; - `Path "lablgtk-1.00/lablgtktop"; - `Path "lablgtk-1.00/lablgtkrun"; - `Path "lablgtk-1.00/lablgtk"; - `Path "unison3/src/unison"; - `Name "core"; - `Path "lipe/caisse/val_parse.h"; - `Path "lipe/caisse/val_parse.c"; - `Path "lipe/caisse/val_lex.c"; - `Path "lipe/caisse/caisse"; - `Path "lipe/runtime"; - `Path "lipe/demo"; - `Path "unison2/doc/unison-manual.ps"; - `Path "unison/doc/unison-mal.ps"; - `Name "*.ppi"; - `Path "unison2/src/unison"; - `Path "Xduce/xduce/pref.ml"; - `Path "Xduce/xduce/xduce{,.opt}"; - `Path "unison/src/TAGS"; - `Path "unison/src/unison"; - `Name "*.old"; - `Name "#*#"; - `Name "*.cm{i,o,x,a,xa}"; - `Name "*.vo"; - `Name "*{~,.aux,.bbl,.blg,.log,.toc,.o,.a}"; - `Name "gmon.out"; - `Name "ocamlprof.dump"; - `Name "CVS"; - `Name ".*.prcs_aux"; - `Path "icfp2000/tools/src2tex"; - `Path "icfp2000/temp.dvi"; - `Path "icfp2000/main.dvi"; - `Path "icfp2000/whole.dvi"; - `Path "icfp2000/regsub.ps"; - `Path "Views/main.dvi"; - `Path "lipe/perso/caisse"; - `Name "obsolete"; - `Path "misc/fingerprint/cksum/cksum"; - `Path "misc/relay/relay"; - `Path "Xduce/xduce.current/xduce.opt"; - `Path "Xduce/xduce.current/pref.ml"; - `Path "Xduce/xduce.new/pref.ml"; - `Path "Xduce/xduce.new/xduce.opt"; - `Path "profiler/profiler"; - `Path "ocaml/boot/Saved"; - `Path "ocaml/byterun/ocamlrun"; - `Path "ocaml/config/Makefile"; - `Path "ocaml/config/m.h"; - `Path "ocaml/config/s.h"; - `Path "ocaml/expunge"; - `Path "ocaml/asmcomp/arch.ml"; - `Path "ocaml/asmcomp/emit.ml"; - `Path "ocaml/asmcomp/proc.ml"; - `Path "ocaml/asmcomp/reload.ml"; - `Path "ocaml/asmcomp/scheduling.ml"; - `Path "ocaml/asmcomp/selection.ml"; - `Path "ocaml/debugger/ocamldebug"; - `Path "ocaml/lex/ocamllex"; - `Path "ocaml/ocaml"; - `Path "ocaml/ocamlc"; - `Path "ocaml/ocamlopt"; - `Path "ocaml/otherlibs/dynlink/extract_crc"; - `Path "ocaml/otherlibs/labltk/browser/ocamlbrowser"; - `Path "ocaml/otherlibs/labltk/compiler/tkcompiler"; - `Path "ocaml/otherlibs/str/regex-0.12/config.status"; - `Path "ocaml/stdlib/camlheader"; - `Path "ocaml/tools/cvt_emit"; - `Path "ocaml/boot/camlheader"; - `Path "ocaml/boot/ocamlrun"; - `Path "ocaml/boot/ocamlyacc"; - `Path "ocaml/otherlibs/labltk/lib/.depend"; - `Path "ocaml/otherlibs/labltk/lib/labltk"; - `Path "ocaml/otherlibs/labltk/lib/labltktop"; - `Path "ocaml/otherlibs/labltk/lib/tk.ml"; - `Path "ocaml/tools/ocamlcp"; - `Path "ocaml/tools/ocamldep"; - `Path "ocaml/tools/ocamlmktop"; - `Path "ocaml/tools/ocamlprof"; - `Path "ocaml/utils/config.ml"; - `Path "ocaml/yacc/ocamlyacc"; - `Path "Xduce/interleave/tools/src2tex"; - `Path "xml/parser"; - `Path "ocaml/ocamlopt.opt"; - `Path "ocaml/boot/ocamlc"; - `Path "ocaml/boot/ocamllex"; - `Path "ocaml/ocamlc.opt"; - `Path "specs/tools/src2f"; - `Path "specs/tools/src2tex" ] - -let paths = - [ "These"; - "Xduce"; - "unison"; - "unison2"; - "unison3"; - "tinkertype"; - "lipe"; - "icfp2000"; - "Views"; - "sync"; - "misc"; - "lablgtk-1.00"; - "mydb"; - "yacc"; - "db-papers"; - "submissions"; - "xml"; - "profiler"; - "specs"; - "ocaml"; - "rx" ] - -let rec children p = - let rec loop ch dir = - try - let file = Unix.readdir dir in - let ch' = - if file = "." || file = ".." then - ch - else - file :: ch in - loop ch' dir - with End_of_file -> - ch - in - let dir = Unix.opendir p in - let result = loop [] dir in - Unix.closedir dir; - result - -let is_dir p = - try - (Unix.lstat p).Unix.st_kind = Unix.S_DIR - with Unix.Unix_error _ -> - false - -let prefix ="/home/jerome/" - -let count = ref 0 -let hit = ref 0 -let rec visit rx p = -(*incr count; if !count > 0 then raise Exit;*) - try -incr count; - ignore (Re.exec ~group:false rx p); -(*Format.eprintf "-%s@." p*) - with Not_found -> -(*Format.eprintf "+%s@." p;*) - let fp = prefix ^ p in -incr hit; - if is_dir fp then - List.iter (fun n -> visit rx (p ^ "/" ^ n)) (children fp) - -let _ = -for i = 0 to 9 do -count := 0; hit := 0; - let rx = - Re.seq - [ Re.bos; - Re.alt - (List.map - (fun p -> - match p with - `Path s -> - Re.Glob.globx s - | `Name s -> - Re.seq [Re.no_group (Re_posix.re "(.*/)?"); - Re.Glob.globx s]) - desc); - Re.eos ] - in - let rx = Re.compile rx in -begin try - List.iter (fun p -> visit rx p) paths -with Exit -> () end; -Format.eprintf "%d/%d@." !hit !count; -done - diff -Nru ocaml-re-1.7.3/Makefile ocaml-re-1.9.0/Makefile --- ocaml-re-1.7.3/Makefile 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/Makefile 2019-04-06 07:05:39.000000000 +0000 @@ -1,18 +1,18 @@ -JBUILDER ?= jbuilder +DUNE ?= dune all: - @$(JBUILDER) build + @$(DUNE) build test: - @$(JBUILDER) runtest + @$(DUNE) runtest check: test clean: - @$(JBUILDER) clean + @$(DUNE) clean .PHONY: check test all clean .PHONY: all-supported-ocaml-versions all-supported-ocaml-versions: - jbuilder build @runtest --workspace jbuild-workspace.dev + dune build @runtest --workspace dune-workspace.dev diff -Nru ocaml-re-1.7.3/pkg/pkg.ml ocaml-re-1.9.0/pkg/pkg.ml --- ocaml-re-1.7.3/pkg/pkg.ml 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/pkg/pkg.ml 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -#use "topfind" -#require "topkg-jbuilder.auto" diff -Nru ocaml-re-1.7.3/README.md ocaml-re-1.9.0/README.md --- ocaml-re-1.7.3/README.md 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/README.md 2019-04-06 07:05:39.000000000 +0000 @@ -18,20 +18,18 @@ The following styles of regular expressions are supported: - Perl-style regular expressions (module `Re.Perl`); -- Posix extended regular expressions (module `Re_posix`); +- Posix extended regular expressions (module `Re.Posix`); - Emacs-style regular expressions (module `Re.Emacs`); -- Shell-style file globbing (module `Re_glob`). +- Shell-style file globbing (module `Re.Glob`). -It is also possible to build regular expressions by combining simpler -regular expressions (module `Re`). +It is also possible to build regular expressions by combining simpler regular +expressions (module `Re`). The most notable missing features are **back-references** and look-ahead/look-behind **assertions**. -There is also a subset of the PCRE interface available in the -`Re.pcre` library. This makes it easier to port code from that -library to Re without any changes beyond replacing the `pcre` -findlib package with `re.pcre`. +There is also a subset of the PCRE interface available in the `Re.Pcre` module. +This makes it easier to port code from that library to Re minimal changes. Performances ============ diff -Nru ocaml-re-1.7.3/re.opam ocaml-re-1.9.0/re.opam --- ocaml-re-1.7.3/re.opam 2018-03-15 14:09:54.000000000 +0000 +++ ocaml-re-1.9.0/re.opam 2019-04-06 07:05:39.000000000 +0000 @@ -1,4 +1,4 @@ -opam-version: "1.2" +opam-version: "2.0" maintainer: "rudi.grinberg@gmail.com" authors: [ @@ -11,17 +11,27 @@ license: "LGPL-2.0 with OCaml linking exception" homepage: "https://github.com/ocaml/ocaml-re" bug-reports: "https://github.com/ocaml/ocaml-re/issues" -dev-repo: "https://github.com/ocaml/ocaml-re.git" +dev-repo: "git+https://github.com/ocaml/ocaml-re.git" build: [ - ["jbuilder" "subst" "-n" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] -build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]] depends: [ - "jbuilder" {build & >= "1.0+beta10"} - "ounit" {test} + "ocaml" {>= "4.02"} + "dune" {build} + "ounit" {with-test} + "seq" ] -available: [ocaml-version >= "4.02.3"] +synopsis: "RE is a regular expression library for OCaml" +description: """ +Pure OCaml regular expressions with: +* Perl-style regular expressions (module Re.Perl) +* Posix extended regular expressions (module Re.Posix) +* Emacs-style regular expressions (module Re.Emacs) +* Shell-style file globbing (module Re.Glob) +* Compatibility layer for OCaml's built-in Str module (module Re.Str) +"""