[Pkg-ocaml-maint-commits] [ocaml-re] 06/15: Imported Upstream version 1.6.0
Stéphane Glondu
glondu at moszumanska.debian.org
Fri Aug 5 11:15:33 UTC 2016
This is an automated email from the git hooks/post-receive script.
glondu pushed a commit to branch master
in repository ocaml-re.
commit 3f30730d9572e6ff76dc1589f7f4a4f368a379e1
Author: Stephane Glondu <steph at glondu.net>
Date: Fri Aug 5 12:50:06 2016 +0200
Imported Upstream version 1.6.0
---
.travis-ci.sh | 40 ------------
.travis.yml | 11 +++-
CHANGES | 5 ++
_oasis | 7 ++-
lib/META | 16 ++---
lib/re.ml | 90 +++++++++++++++-----------
lib/re.mldylib | 3 +-
lib/re.mli | 5 ++
lib/re.mllib | 3 +-
lib/re_automata.ml | 62 +++++++++---------
lib/re_automata.mli | 6 +-
lib/re_cset.ml | 15 ++---
lib/re_cset.mli | 2 +-
lib/re_fmt.ml | 25 ++++++++
lib/re_glob.mli | 2 +-
lib_test/META | 4 +-
lib_test/re_match.ml | 2 +-
myocamlbuild.ml | 174 ++++++++++++++++++++++++++++++++++++++++++++++++---
opam | 1 +
setup.ml | 82 +++++++++++++++---------
20 files changed, 382 insertions(+), 173 deletions(-)
diff --git a/.travis-ci.sh b/.travis-ci.sh
deleted file mode 100755
index 66cd0c6..0000000
--- a/.travis-ci.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-set -e
-
-OPAM_DEPENDS="ounit"
-
-case "$OCAML_VERSION,$OPAM_VERSION" in
-4.00.1,1.1.0) ppa=avsm/ocaml40+opam11 ;;
-4.00.1,1.2.0) ppa=avsm/ocaml40+opam12 ;;
-4.01.0,1.1.0) ppa=avsm/ocaml41+opam11 ;;
-4.01.0,1.2.0) ppa=avsm/ocaml41+opam12 ;;
-4.02.1,1.1.0) ppa=avsm/ocaml42+opam11 ;;
-4.02.1,1.2.0) ppa=avsm/ocaml42+opam12 ;;
-*) echo Unknown $OCAML_VERSION,$OPAM_VERSION; exit 1 ;;
-esac
-
-echo "yes" | sudo add-apt-repository ppa:$ppa
-sudo apt-get update -qq
-sudo apt-get install -qq ocaml ocaml-native-compilers camlp4-extra opam time libssl-dev
-
-export OPAMYES=1
-echo OCaml version
-ocaml -version
-echo OPAM versions
-opam --version
-opam --git-version
-
-opam init -a
-opam remote add mirage-dev git://github.com/mirage/mirage-dev
-opam update
-opam install ${OPAM_DEPENDS}
-
-eval `opam config env`
-
-# test opam installation
-opam pin add re .
-# run tests
-./configure --enable-tests
-make test
-
-# Check that there's no new diff
-git status
diff --git a/.travis.yml b/.travis.yml
index 5518b3f..7e8a190 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,11 @@
language: c
-script: bash -ex .travis-ci.sh
sudo: required
+install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-opam.sh
+script: bash -ex .travis-opam.sh
env:
- - OCAML_VERSION=4.01.0 OPAM_VERSION=1.2.0
- - OCAML_VERSION=4.02.1 OPAM_VERSION=1.2.0
+ - OCAML_VERSION=4.01
+ - OCAML_VERSION=4.02
+ - OCAML_VERSION=4.03
+os:
+ - linux
+ - osx
diff --git a/CHANGES b/CHANGES
index 880e70c..fb14350 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+1.6.0 (30-May-2016)
+
+* Add Re.pp and Re.pp_re (#55)
+* Fix ocamldoc syntax (#87)
+
1.5.0 (04-Jan-2016)
* Add Re.exec_opt. Like exec but doesn't raise
diff --git a/_oasis b/_oasis
index cfedbb1..9a03b54 100644
--- a/_oasis
+++ b/_oasis
@@ -1,16 +1,17 @@
OASISFormat: 0.4
Name: re
-Version: 1.5.0
+Version: 1.6.0
Synopsis: Pure OCaml regular expression library
Authors: Jerome Vouillon, Thomas Gazagnaire, Anil Madhavapeddy
License: LGPL-2.0 with OCaml linking exception
Plugins: META (0.4), DevFiles (0.4)
-AlphaFeatures: compiled_setup_ml
+AlphaFeatures: compiled_setup_ml, ocamlbuild_more_args
BuildTools: ocamlbuild
+XOCamlbuildExtraArgs: "-cflags '-w +a-40-42-44-3-4-48 -warn-error +1..49'"
Library re
Path: lib
- InternalModules: Re_cset, Re_automata
+ InternalModules: Re_fmt, Re_cset, Re_automata
Modules: Re
Findlibname: re
BuildDepends: bytes
diff --git a/lib/META b/lib/META
index 8e7f180..a86354c 100644
--- a/lib/META
+++ b/lib/META
@@ -1,6 +1,6 @@
# OASIS_START
-# DO NOT EDIT (digest: 0bb765a7710327dab365a6447f85236c)
-version = "1.5.0"
+# DO NOT EDIT (digest: f617609bf72ea371afe897fad8c64b8e)
+version = "1.6.0"
description = "Pure OCaml regular expression library"
requires = "bytes"
archive(byte) = "re.cma"
@@ -9,7 +9,7 @@ archive(native) = "re.cmxa"
archive(native, plugin) = "re.cmxs"
exists_if = "re.cma"
package "str" (
- version = "1.5.0"
+ version = "1.6.0"
description = "Str-compatible regexps"
requires = "re re.emacs"
archive(byte) = "re_str.cma"
@@ -20,7 +20,7 @@ package "str" (
)
package "posix" (
- version = "1.5.0"
+ version = "1.6.0"
description = "POSIX-compatible regexps"
requires = "re"
archive(byte) = "re_posix.cma"
@@ -31,7 +31,7 @@ package "posix" (
)
package "perl" (
- version = "1.5.0"
+ version = "1.6.0"
description = "Perl-compatible regexps"
requires = "re"
archive(byte) = "re_perl.cma"
@@ -42,7 +42,7 @@ package "perl" (
)
package "pcre" (
- version = "1.5.0"
+ version = "1.6.0"
description = "subset of PCRE using the Re engine"
requires = "re re.perl"
archive(byte) = "re_pcre.cma"
@@ -53,7 +53,7 @@ package "pcre" (
)
package "glob" (
- version = "1.5.0"
+ version = "1.6.0"
description = "Shell glob regexps"
requires = "re"
archive(byte) = "re_glob.cma"
@@ -64,7 +64,7 @@ package "glob" (
)
package "emacs" (
- version = "1.5.0"
+ version = "1.6.0"
description = "Emacs-compatible regexps"
requires = "re"
archive(byte) = "re_emacs.cma"
diff --git a/lib/re.ml b/lib/re.ml
index bf5ea40..7c4fff7 100644
--- a/lib/re.ml
+++ b/lib/re.ml
@@ -24,13 +24,6 @@ module Cset = Re_cset
module Automata = Re_automata
module MarkSet = Automata.PmarkSet
-let rec first f l =
- match l with
- [] -> None
- | x :: r -> match f x with
- None -> first f r
- | Some _ as res -> res
-
let rec iter n f v = if n = 0 then v else iter (n - 1) f (f v)
(****)
@@ -95,7 +88,9 @@ type re =
group_count : int
(* Number of groups in the regular expression *) }
-let print_re ch re = Automata.print_expr ch re.initial
+let pp_re ch re = Automata.pp ch re.initial
+
+let print_re = pp_re
(* Information used during matching *)
type info =
@@ -145,12 +140,12 @@ let unknown_state =
next = dummy_next; final = [];
desc = Automata.dummy_state }
-let count = ref 0
let mk_state ncol ((idx, _, _, _, _) as desc) =
let break_state =
match Automata.status desc with
- Automata.Running -> false
- | _ -> true
+ | Automata.Running -> false
+ | Automata.Failed
+ | Automata.Match _ -> true
in
{ idx = if break_state then break else idx;
real_idx = idx;
@@ -268,8 +263,6 @@ let find_initial_state re cat =
re.initial_states <- (cat, st) :: re.initial_states;
st
-let dummy_substrings = `Match ("", [], [||], 0)
-
let get_color re (s:string) pos =
if pos < 0 then -1 else
let slen = String.length s in
@@ -377,13 +370,10 @@ let cseq c c' = Cset.seq (Char.code c) (Char.code c')
let cadd c s = Cset.add (Char.code c) s
let csingle c = Cset.single (Char.code c)
-let rec interval i j = if i > j then [] else i :: interval (i + 1) j
-
let rec cset_hash_rec l =
match l with
[] -> 0
| (i, j)::r -> i + 13 * j + 257 * cset_hash_rec r
-let cset_hash l = (cset_hash_rec l) land 0x3FFFFFFF
module CSetMap =
Map.Make
@@ -412,8 +402,6 @@ let trans_set cache cm s =
(****)
-type sem_status = Compulsory | Indicative
-
type regexp =
Set of Cset.t
| Sequence of regexp list
@@ -432,6 +420,41 @@ type regexp =
| Difference of regexp * regexp
| Pmark of Automata.Pmark.t * regexp
+let rec pp fmt t =
+ let open Re_fmt in
+ let var s re = sexp fmt s pp re in
+ let seq s rel = sexp fmt s (list pp) rel in
+ match t with
+ | Set s -> sexp fmt "Set" Cset.pp s
+ | Sequence sq -> seq "Sequence" sq
+ | Alternative alt -> seq "Alternative" alt
+ | Repeat (re, start, stop) ->
+ let pp' fmt () = fprintf fmt "%a@ %d%a" pp re start optint stop in
+ sexp fmt "Repeat" pp' ()
+ | Beg_of_line -> str fmt "Beg_of_line"
+ | End_of_line -> str fmt "End_of_line"
+ | Beg_of_word -> str fmt "Beg_of_word"
+ | End_of_word -> str fmt "End_of_word"
+ | Not_bound -> str fmt "Not_bound"
+ | Beg_of_str -> str fmt "Beg_of_str"
+ | End_of_str -> str fmt "End_of_str"
+ | Last_end_of_line -> str fmt "Last_end_of_line"
+ | Start -> str fmt "Start"
+ | Stop -> str fmt "Stop"
+ | Sem (sem, re) ->
+ sexp fmt "Sem" (pair Automata.pp_sem pp) (sem, re)
+ | Sem_greedy (k, re) ->
+ sexp fmt "Sem_greedy" (pair Automata.pp_rep_kind pp) (k, re)
+ | Group c -> var "Group" c
+ | No_group c -> var "No_group" c
+ | Nest c -> var "Nest" c
+ | Case c -> var "Case" c
+ | No_case c -> var "No_case" c
+ | Intersection c -> seq "Intersection" c
+ | Complement c -> seq "Complement" c
+ | Difference (a, b) -> sexp fmt "Difference" (pair pp pp) (a, b)
+ | Pmark (m, r) -> sexp fmt "Pmark" (pair Automata.Pmark.pp pp) (m, r)
+
let rec is_charset r =
match r with
Set _ ->
@@ -608,7 +631,7 @@ let rec translate ids kind ign_group ign_case greedy pos cache (c:Bytes.t) r =
let (cr, kind') =
translate ids kind ign_group ign_case greedy pos cache c r' in
(enforce_kind ids kind kind' cr, kind)
- | l' ->
+ | _ ->
(A.alt ids
(List.map
(fun r' ->
@@ -955,8 +978,8 @@ let exec_opt ?pos ?len re s =
let execp ?pos ?len re s =
match exec_internal "Re.execp" ?pos ?len re s with
- Match substr -> true
- | _ -> false
+ Match _substr -> true
+ | _ -> false
let exec_partial ?pos ?len re s =
match exec_internal "Re.exec_partial" ?pos ?len re s with
@@ -964,18 +987,11 @@ let exec_partial ?pos ?len re s =
| Running -> `Partial
| Failed -> `Mismatch
-let rec find_mark (i : int) l =
- match l with
- [] ->
- raise Not_found
- | (j, idx) :: r ->
- if i = j then idx else find_mark i r
-
module Group = struct
type t = groups
- let get {s ; marks ; gpos} i =
+ let get {s ; marks ; gpos ; _} i =
if 2 * i + 1 >= Array.length marks then raise Not_found;
let m1 = marks.(2 * i) in
if m1 = -1 then raise Not_found;
@@ -983,7 +999,7 @@ module Group = struct
let p2 = gpos.(marks.(2 * i + 1)) - 1 in
String.sub s p1 (p2 - p1)
- let offset {s ; marks ; gpos} i =
+ let offset {marks ; gpos ; _} i =
if 2 * i + 1 >= Array.length marks then raise Not_found;
let m1 = marks.(2 * i) in
if m1 = -1 then raise Not_found;
@@ -995,14 +1011,14 @@ module Group = struct
let stop subs i = snd (offset subs i)
- let test { s ; marks } i =
+ let test { marks ; _ } i =
if 2 * i >= Array.length marks then false else
let idx = marks.(2 * i) in
idx <> -1
let dummy_offset = (-1, -1)
- let all_offset {s ; marks ; gpos ; gcount } =
+ let all_offset {marks ; gpos ; gcount ; _} =
let res = Array.make gcount dummy_offset in
for i = 0 to Array.length marks / 2 - 1 do
let m1 = marks.(2 * i) in
@@ -1016,7 +1032,7 @@ module Group = struct
let dummy_string = ""
- let all {s ; marks ; gpos ; gcount } =
+ let all {s ; marks ; gpos ; gcount ; _ } =
let res = Array.make gcount dummy_string in
for i = 0 to Array.length marks / 2 - 1 do
let m1 = marks.(2 * i) in
@@ -1034,7 +1050,7 @@ module Mark = struct
type t = Automata.Pmark.t
- let test {pmarks} p =
+ let test {pmarks ; _} p =
Automata.PmarkSet.mem p pmarks
let all s = s.pmarks
@@ -1097,8 +1113,8 @@ let matches ?pos ?len re s =
in iter ()
type split_token =
- [ `Text of string (** Text between delimiters *)
- | `Delim of groups (** Delimiter *)
+ [ `Text of string
+ | `Delim of groups
]
let split_full_gen ?(pos=0) ?len re s =
@@ -1115,7 +1131,7 @@ let split_full_gen ?(pos=0) ?len re s =
let pos0 = pos in
let state = ref `Idle in
let i = ref pos and pos = ref pos in
- let rec next () = match !state with
+ let next () = match !state with
| `Idle when !pos >= limit ->
if !i < limit then (
let sub = String.sub s !i (limit - !i) in
diff --git a/lib/re.mldylib b/lib/re.mldylib
index 83f60ea..1b9d5c4 100644
--- a/lib/re.mldylib
+++ b/lib/re.mldylib
@@ -1,6 +1,7 @@
# OASIS_START
-# DO NOT EDIT (digest: d5cab46013d91e556f48bca720b3595e)
+# DO NOT EDIT (digest: de0cfc6fef391be3b2a03b93326d4594)
Re
+Re_fmt
Re_cset
Re_automata
# OASIS_STOP
diff --git a/lib/re.mli b/lib/re.mli
index 00c8a44..04a2c27 100644
--- a/lib/re.mli
+++ b/lib/re.mli
@@ -359,6 +359,11 @@ val no_case : t -> t
(** {2 Internal debugging} *)
+val pp : Format.formatter -> t -> unit
+
+val pp_re : Format.formatter -> re -> unit
+
+(** Alias for {!pp_re}. Deprecated *)
val print_re : Format.formatter -> re -> unit
diff --git a/lib/re.mllib b/lib/re.mllib
index 83f60ea..1b9d5c4 100644
--- a/lib/re.mllib
+++ b/lib/re.mllib
@@ -1,6 +1,7 @@
# OASIS_START
-# DO NOT EDIT (digest: d5cab46013d91e556f48bca720b3595e)
+# DO NOT EDIT (digest: de0cfc6fef391be3b2a03b93326d4594)
Re
+Re_fmt
Re_cset
Re_automata
# OASIS_STOP
diff --git a/lib/re_automata.ml b/lib/re_automata.ml
index 9a808e6..fc8440f 100644
--- a/lib/re_automata.ml
+++ b/lib/re_automata.ml
@@ -35,6 +35,7 @@ module Pmark : sig
val equal : t -> t -> bool
val compare : t -> t -> int
val gen : unit -> t
+ val pp : Format.formatter -> t -> unit
end
= struct
type t = int
@@ -42,6 +43,8 @@ end
let compare (x : int) (y : int) = compare x y
let r = ref 0
let gen () = incr r ; !r
+
+ let pp = Format.pp_print_int
end
type expr = { id : int; def : def }
@@ -74,38 +77,41 @@ type e =
(****)
-let print_kind ch k =
- Format.fprintf ch "%s"
+let pp_sem ch k =
+ Format.pp_print_string ch
(match k with
`Shortest -> "short"
| `Longest -> "long"
| `First -> "first")
-let rec print_expr ch e =
+
+let pp_rep_kind fmt = function
+ | `Greedy -> Format.pp_print_string fmt "Greedy"
+ | `Non_greedy -> Format.pp_print_string fmt "Non_greedy"
+
+let rec pp ch e =
+ let open Re_fmt in
match e.def with
Cst l ->
- Format.fprintf ch "@[<3>(cst@ %a)@]" Cset.print l;
+ sexp ch "cst" Cset.pp l;
| Alt l ->
- Format.fprintf ch "@[<3>(alt";
- List.iter (fun e -> Format.fprintf ch "@ %a" print_expr e) l;
- Format.fprintf ch ")@]"
+ sexp ch "alt" (list pp) l
| Seq (k, e, e') ->
- Format.fprintf ch "@[<3>(seq %a@ %a@ %a)@]"
- print_kind k print_expr e print_expr e'
+ sexp ch "seq" (triple pp_sem pp pp) (k, e, e')
| Eps ->
- Format.fprintf ch "eps"
- | Rep (rk, k, e) ->
- Format.fprintf ch "@[<3>(rep@ %a %a)@]" print_kind k print_expr e
+ str ch "eps"
+ | Rep (_rk, k, e) ->
+ sexp ch "rep" (pair pp_sem pp) (k, e)
| Mark i ->
- Format.fprintf ch "@[<3>(mark@ %d)@]" i
+ sexp ch "mark" int i
| Pmark i ->
- Format.fprintf ch "@[<3>(pmark@ %d)@]" (i :> int)
+ sexp ch "pmark" int (i :> int)
| Erase (b, e) ->
- Format.fprintf ch "@[<3>(erase@ %d %d)@]" b e
+ sexp ch "erase" (pair int int) (b, e)
| Before c ->
- Format.fprintf ch "@[<3>(before@ %d)@]" c
+ sexp ch "before" int c
| After c ->
- Format.fprintf ch "@[<3>(after@ %d)@]" c
+ sexp ch "after" int c
let print_marks ch l =
@@ -120,14 +126,14 @@ let rec print_state_rec ch e y =
match e with
TMatch marks ->
Format.fprintf ch "@[<2>(Match@ %a)@]" print_marks marks
- | TSeq (l', x, kind) ->
+ | TSeq (l', x, _kind) ->
Format.fprintf ch "@[<2>(Seq@ ";
print_state_lst ch l' x;
- Format.fprintf ch " %a)@]" print_expr x
+ Format.fprintf ch " %a)@]" pp x
| TExp (marks, {def = Eps; _}) ->
Format.fprintf ch "(Exp %d (%a) (eps))" y.id print_marks marks
| TExp (marks, x) ->
- Format.fprintf ch "(Exp %d (%a) %a)" x.id print_marks marks print_expr x
+ Format.fprintf ch "(Exp %d (%a) %a)" x.id print_marks marks pp x
and print_state_lst ch l y =
match l with
@@ -206,7 +212,7 @@ let texp marks x = TExp (marks, x)
let tseq kind x y rem =
match x with
[] -> rem
- | [TExp (marks, {def = Eps})] -> TExp (marks, y) :: rem
+ | [TExp (marks, {def = Eps ; _})] -> TExp (marks, y) :: rem
| _ -> TSeq (x, y, kind) :: rem
(****)
@@ -277,7 +283,7 @@ let equal_state (idx1, cat1, desc1, _, h1) (idx2, cat2, desc2, _, h2) =
(h1 : int) = h2 && (idx1 : int) = idx2 &&
(cat1 : int) = cat2 && equal_e desc1 desc2
-let compare_state (idx1, cat1, desc1, _, h1) (idx2, cat2, desc2, _, h2) =
+let compare_state (_idx1, cat1, desc1, _, h1) (_idx2, cat2, desc2, _, h2) =
let c = compare (h1 : int) h2 in
if c <> 0 then c else
let c = compare (cat1 : int) cat2 in
@@ -343,19 +349,19 @@ let rec remove_duplicates prev l y =
match l with
[] ->
([], prev)
- | TMatch _ as x :: r -> (* Truncate after first match *)
+ | TMatch _ as x :: _ -> (* Truncate after first match *)
([x], prev)
| TSeq (l', x, kind) :: r ->
let (l'', prev') = remove_duplicates prev l' x in
let (r', prev'') = remove_duplicates prev' r y in
(tseq kind l'' x r', prev'')
- | TExp (marks, {def = Eps; _}) as e :: r ->
+ | TExp (_marks, {def = Eps; _}) as e :: r ->
if List.memq y.id prev then
remove_duplicates prev r y
else
let (r', prev') = remove_duplicates (y.id :: prev) r y in
(e :: r', prev')
- | TExp (marks, x) as e :: r ->
+ | TExp (_marks, x) as e :: r ->
if List.memq x.id prev then
remove_duplicates prev r y
else
@@ -490,9 +496,9 @@ let rec prepend s x l =
match s, l with
[], _ ->
l
- | _, [] ->
+ | _r, [] ->
[]
- | (c, c') :: r, ([d, d'], x') :: r' when c' < d ->
+ | (_c, c') :: r, ([d, _d'], _x') :: _r' when c' < d ->
prepend r x l
| (c, c') :: r, ([d, d'], x') :: r' ->
if c <= d then begin
@@ -604,7 +610,7 @@ and deriv_2 all_chars categories marks cat l rem =
and deriv_seq all_chars categories cat kind y z rem =
if
List.exists
- (fun (s, xl) ->
+ (fun (_s, xl) ->
List.exists (fun x -> match x with TMatch _ -> true | _ -> false) xl)
y
then
diff --git a/lib/re_automata.mli b/lib/re_automata.mli
index 6be3100..ead5334 100644
--- a/lib/re_automata.mli
+++ b/lib/re_automata.mli
@@ -28,11 +28,15 @@ type mark = int
type sem = [ `Longest | `Shortest | `First ]
type rep_kind = [ `Greedy | `Non_greedy ]
+val pp_sem : Format.formatter -> sem -> unit
+val pp_rep_kind : Format.formatter -> rep_kind -> unit
+
module Pmark : sig
type t = private int
val equal : t -> t -> bool
val compare : t -> t -> int
val gen : unit -> t
+ val pp : Format.formatter -> t -> unit
end
type expr
@@ -48,7 +52,7 @@ type def =
| After of category
| Pmark of Pmark.t
val def : expr -> def
-val print_expr : Format.formatter -> expr -> unit
+val pp : Format.formatter -> expr -> unit
type ids
val create_ids : unit -> ids
diff --git a/lib/re_cset.ml b/lib/re_cset.ml
index 001477e..9c5e872 100644
--- a/lib/re_cset.ml
+++ b/lib/re_cset.ml
@@ -97,17 +97,10 @@ let hash l = (hash_rec l) land 0x3FFFFFFF
(****)
-let print_one ch c1 c2 =
+let print_one ch (c1, c2) =
if c1 = c2 then
- Format.fprintf ch "@ %d" c1
+ Format.fprintf ch "%d" c1
else
- Format.fprintf ch "@ %d-%d" c1 c2
+ Format.fprintf ch "%d-%d" c1 c2
-let print ch l =
- match l with
- [] ->
- ()
- | (c1, c2) :: rem ->
- print_one ch c1 c2;
- List.iter
- (fun (c1, c2) -> Format.fprintf ch "@ "; print_one ch c1 c2) rem
+let pp = Re_fmt.list print_one
diff --git a/lib/re_cset.mli b/lib/re_cset.mli
index 45b5019..1fb018c 100644
--- a/lib/re_cset.mli
+++ b/lib/re_cset.mli
@@ -40,4 +40,4 @@ val mem : c -> t -> bool
type hash
val hash : t -> hash
-val print : Format.formatter -> t -> unit
+val pp : Format.formatter -> t -> unit
diff --git a/lib/re_fmt.ml b/lib/re_fmt.ml
new file mode 100644
index 0000000..2c7cf5e
--- /dev/null
+++ b/lib/re_fmt.ml
@@ -0,0 +1,25 @@
+(** Very small tooling for format printers. *)
+
+include Format
+
+(* Only in the stdlib since 4.02, so we copy. *)
+let rec list pp ppf = function
+ | [] -> ()
+ | [v] -> pp ppf v
+ | v :: vs ->
+ pp ppf v;
+ pp_print_space ppf ();
+ list pp ppf vs
+
+let str = pp_print_string
+let sexp fmt s pp x = fprintf fmt "@[<3>(%s@ %a@)]" s pp x
+let pair pp1 pp2 fmt (v1,v2) =
+ pp1 fmt v1; pp_print_space fmt () ; pp2 fmt v2
+let triple pp1 pp2 pp3 fmt (v1, v2, v3) =
+ pp1 fmt v1; pp_print_space fmt () ;
+ pp2 fmt v2; pp_print_space fmt () ;
+ pp3 fmt v3
+let int = pp_print_int
+let optint fmt = function
+ | None -> ()
+ | Some i -> fprintf fmt "@ %d" i
diff --git a/lib/re_glob.mli b/lib/re_glob.mli
index 8f38db5..4559a70 100644
--- a/lib/re_glob.mli
+++ b/lib/re_glob.mli
@@ -54,7 +54,7 @@ val glob :
slash. Defaults to true.
If [expand_braces] is true, braced sets will expand into multiple globs,
- e.g. a{x,y}b{1,2} matches axb1, axb2, ayb1, ayb2. As specified for bash, brace
+ e.g. a\{x,y\}b\{1,2\} matches axb1, axb2, ayb1, ayb2. As specified for bash, brace
expansion is purely textual and can be nested. Defaults to false. *)
val glob' : ?anchored:bool -> bool -> string -> Re.t
diff --git a/lib_test/META b/lib_test/META
index 58690ef..d5fae05 100644
--- a/lib_test/META
+++ b/lib_test/META
@@ -1,6 +1,6 @@
# OASIS_START
-# DO NOT EDIT (digest: 16cf6121c8ebd6199b65b6f8ddd610a5)
-version = "1.5.0"
+# DO NOT EDIT (digest: 2f3aecdc681b02148ad0a4004aea972f)
+version = "1.6.0"
description = "Pure OCaml regular expression library"
requires = "oUnit"
archive(byte) = "fort_unit.cma"
diff --git a/lib_test/re_match.ml b/lib_test/re_match.ml
index 415b115..4858013 100644
--- a/lib_test/re_match.ml
+++ b/lib_test/re_match.ml
@@ -50,7 +50,7 @@ let check_phone cnt must_print line =
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
+for _i = 2 to n do
List.iter (check_phone (ref 1) false) phones
done;
List.iter (check_phone (ref 1) true) phones
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index a4c86f9..0696d3a 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -1,5 +1,5 @@
(* OASIS_START *)
-(* DO NOT EDIT (digest: f9c8a0ea318f44d9c8a85053927fb8c2) *)
+(* DO NOT EDIT (digest: e21dda14fe9fbcc90604493f9f1acd1d) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)
@@ -29,6 +29,166 @@ module OASISGettext = struct
end
+module OASISString = struct
+(* # 22 "src/oasis/OASISString.ml" *)
+
+
+ (** Various string utilities.
+
+ Mostly inspired by extlib and batteries ExtString and BatString libraries.
+
+ @author Sylvain Le Gall
+ *)
+
+
+ let nsplitf str f =
+ if str = "" then
+ []
+ else
+ let buf = Buffer.create 13 in
+ let lst = ref [] in
+ let push () =
+ lst := Buffer.contents buf :: !lst;
+ Buffer.clear buf
+ in
+ let str_len = String.length str in
+ for i = 0 to str_len - 1 do
+ if f str.[i] then
+ push ()
+ else
+ Buffer.add_char buf str.[i]
+ done;
+ push ();
+ List.rev !lst
+
+
+ (** [nsplit c s] Split the string [s] at char [c]. It doesn't include the
+ separator.
+ *)
+ let nsplit str c =
+ nsplitf str ((=) c)
+
+
+ let find ~what ?(offset=0) str =
+ let what_idx = ref 0 in
+ let str_idx = ref offset in
+ while !str_idx < String.length str &&
+ !what_idx < String.length what do
+ if str.[!str_idx] = what.[!what_idx] then
+ incr what_idx
+ else
+ what_idx := 0;
+ incr str_idx
+ done;
+ if !what_idx <> String.length what then
+ raise Not_found
+ else
+ !str_idx - !what_idx
+
+
+ let sub_start str len =
+ let str_len = String.length str in
+ if len >= str_len then
+ ""
+ else
+ String.sub str len (str_len - len)
+
+
+ let sub_end ?(offset=0) str len =
+ let str_len = String.length str in
+ if len >= str_len then
+ ""
+ else
+ String.sub str 0 (str_len - len)
+
+
+ let starts_with ~what ?(offset=0) str =
+ let what_idx = ref 0 in
+ let str_idx = ref offset in
+ let ok = ref true in
+ while !ok &&
+ !str_idx < String.length str &&
+ !what_idx < String.length what do
+ if str.[!str_idx] = what.[!what_idx] then
+ incr what_idx
+ else
+ ok := false;
+ incr str_idx
+ done;
+ if !what_idx = String.length what then
+ true
+ else
+ false
+
+
+ let strip_starts_with ~what str =
+ if starts_with ~what str then
+ sub_start str (String.length what)
+ else
+ raise Not_found
+
+
+ let ends_with ~what ?(offset=0) str =
+ let what_idx = ref ((String.length what) - 1) in
+ let str_idx = ref ((String.length str) - 1) in
+ let ok = ref true in
+ while !ok &&
+ offset <= !str_idx &&
+ 0 <= !what_idx do
+ if str.[!str_idx] = what.[!what_idx] then
+ decr what_idx
+ else
+ ok := false;
+ decr str_idx
+ done;
+ if !what_idx = -1 then
+ true
+ else
+ false
+
+
+ let strip_ends_with ~what str =
+ if ends_with ~what str then
+ sub_end str (String.length what)
+ else
+ raise Not_found
+
+
+ let replace_chars f s =
+ let buf = Buffer.create (String.length s) in
+ String.iter (fun c -> Buffer.add_char buf (f c)) s;
+ Buffer.contents buf
+
+ let lowercase_ascii =
+ replace_chars
+ (fun c ->
+ if (c >= 'A' && c <= 'Z') then
+ Char.chr (Char.code c + 32)
+ else
+ c)
+
+ let uncapitalize_ascii s =
+ if s <> "" then
+ (lowercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+ else
+ s
+
+ let uppercase_ascii =
+ replace_chars
+ (fun c ->
+ if (c >= 'a' && c <= 'z') then
+ Char.chr (Char.code c - 32)
+ else
+ c)
+
+ let capitalize_ascii s =
+ if s <> "" then
+ (uppercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+ else
+ s
+
+end
+
module OASISExpr = struct
(* # 22 "src/oasis/OASISExpr.ml" *)
@@ -129,7 +289,7 @@ module OASISExpr = struct
end
-# 132 "myocamlbuild.ml"
+# 292 "myocamlbuild.ml"
module BaseEnvLight = struct
(* # 22 "src/base/BaseEnvLight.ml" *)
@@ -234,7 +394,7 @@ module BaseEnvLight = struct
end
-# 237 "myocamlbuild.ml"
+# 397 "myocamlbuild.ml"
module MyOCamlbuildFindlib = struct
(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
@@ -516,7 +676,7 @@ module MyOCamlbuildBase = struct
| nm, [], intf_modules ->
ocaml_lib nm;
let cmis =
- List.map (fun m -> (String.uncapitalize m) ^ ".cmi")
+ List.map (fun m -> (OASISString.uncapitalize_ascii m) ^ ".cmi")
intf_modules in
dep ["ocaml"; "link"; "library"; "file:"^nm^".cma"] cmis
| nm, dir :: tl, intf_modules ->
@@ -529,7 +689,7 @@ module MyOCamlbuildBase = struct
["compile"; "infer_interface"; "doc"])
tl;
let cmis =
- List.map (fun m -> dir^"/"^(String.uncapitalize m)^".cmi")
+ List.map (fun m -> dir^"/"^(OASISString.uncapitalize_ascii m)^".cmi")
intf_modules in
dep ["ocaml"; "link"; "library"; "file:"^dir^"/"^nm^".cma"]
cmis)
@@ -603,7 +763,7 @@ module MyOCamlbuildBase = struct
end
-# 606 "myocamlbuild.ml"
+# 766 "myocamlbuild.ml"
open Ocamlbuild_plugin;;
let package_default =
{
@@ -628,6 +788,6 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
-# 632 "myocamlbuild.ml"
+# 792 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
diff --git a/opam b/opam
index 04eb114..b1c385a 100644
--- a/opam
+++ b/opam
@@ -25,6 +25,7 @@ build-test: [
remove: [["ocamlfind" "remove" "re"]]
depends: [
"ocamlfind" {build}
+ "ocamlbuild" {build}
"base-bytes"
"ounit" {test}
]
diff --git a/setup.ml b/setup.ml
index 793fd2b..9c5bef9 100644
--- a/setup.ml
+++ b/setup.ml
@@ -1,9 +1,9 @@
(* setup.ml generated for the first time by OASIS v0.2.1~alpha1 *)
(* OASIS_START *)
-(* DO NOT EDIT (digest: 2de2d6327c0a784427ed0a0b709445e8) *)
+(* DO NOT EDIT (digest: 9ca7744eb2d1e0439500041d071e4367) *)
(*
- Regenerated by OASIS v0.4.5
+ Regenerated by OASIS v0.4.6
Visit http://oasis.forge.ocamlcore.org for more information and
documentation about functions used in this file.
*)
@@ -246,6 +246,33 @@ module OASISString = struct
String.iter (fun c -> Buffer.add_char buf (f c)) s;
Buffer.contents buf
+ let lowercase_ascii =
+ replace_chars
+ (fun c ->
+ if (c >= 'A' && c <= 'Z') then
+ Char.chr (Char.code c + 32)
+ else
+ c)
+
+ let uncapitalize_ascii s =
+ if s <> "" then
+ (lowercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+ else
+ s
+
+ let uppercase_ascii =
+ replace_chars
+ (fun c ->
+ if (c >= 'a' && c <= 'z') then
+ Char.chr (Char.code c - 32)
+ else
+ c)
+
+ let capitalize_ascii s =
+ if s <> "" then
+ (uppercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
+ else
+ s
end
@@ -315,19 +342,15 @@ module OASISUtils = struct
let compare_csl s1 s2 =
- String.compare (String.lowercase s1) (String.lowercase s2)
+ String.compare (OASISString.lowercase_ascii s1) (OASISString.lowercase_ascii s2)
module HashStringCsl =
Hashtbl.Make
(struct
type t = string
-
- let equal s1 s2 =
- (String.lowercase s1) = (String.lowercase s2)
-
- let hash s =
- Hashtbl.hash (String.lowercase s)
+ let equal s1 s2 = (compare_csl s1 s2) = 0
+ let hash s = Hashtbl.hash (OASISString.lowercase_ascii s)
end)
module SetStringCsl =
@@ -365,7 +388,7 @@ module OASISUtils = struct
else
buf
in
- String.lowercase buf
+ OASISString.lowercase_ascii buf
end
@@ -471,7 +494,7 @@ module PropList = struct
order = Queue.create ();
name_norm =
(if case_insensitive then
- String.lowercase
+ OASISString.lowercase_ascii
else
fun s -> s);
}
@@ -1822,13 +1845,13 @@ module OASISUnixPath = struct
let capitalize_file f =
let dir = dirname f in
let base = basename f in
- concat dir (String.capitalize base)
+ concat dir (OASISString.capitalize_ascii base)
let uncapitalize_file f =
let dir = dirname f in
let base = basename f in
- concat dir (String.uncapitalize base)
+ concat dir (OASISString.uncapitalize_ascii base)
end
@@ -2890,7 +2913,7 @@ module OASISFileUtil = struct
end
-# 2893 "setup.ml"
+# 2916 "setup.ml"
module BaseEnvLight = struct
(* # 22 "src/base/BaseEnvLight.ml" *)
@@ -2995,7 +3018,7 @@ module BaseEnvLight = struct
end
-# 2998 "setup.ml"
+# 3021 "setup.ml"
module BaseContext = struct
(* # 22 "src/base/BaseContext.ml" *)
@@ -5406,7 +5429,7 @@ module BaseSetup = struct
end
-# 5409 "setup.ml"
+# 5432 "setup.ml"
module InternalConfigurePlugin = struct
(* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *)
@@ -5845,8 +5868,8 @@ module InternalInstallPlugin = struct
let make_fnames modul sufx =
List.fold_right
begin fun sufx accu ->
- (String.capitalize modul ^ sufx) ::
- (String.uncapitalize modul ^ sufx) ::
+ (OASISString.capitalize_ascii modul ^ sufx) ::
+ (OASISString.uncapitalize_ascii modul ^ sufx) ::
accu
end
sufx
@@ -6270,7 +6293,7 @@ module InternalInstallPlugin = struct
end
-# 6273 "setup.ml"
+# 6296 "setup.ml"
module OCamlbuildCommon = struct
(* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *)
@@ -6648,7 +6671,7 @@ module OCamlbuildDocPlugin = struct
end
-# 6651 "setup.ml"
+# 6674 "setup.ml"
module CustomPlugin = struct
(* # 22 "src/plugins/custom/CustomPlugin.ml" *)
@@ -6796,13 +6819,15 @@ module CustomPlugin = struct
end
-# 6799 "setup.ml"
+# 6822 "setup.ml"
open OASISTypes;;
let setup_t =
{
BaseSetup.configure = InternalConfigurePlugin.configure;
- build = OCamlbuildPlugin.build [];
+ build =
+ OCamlbuildPlugin.build
+ ["-cflags '-w +a-40-42-44-3-4-48 -warn-error +1..49'"];
test =
[
("re_test_re",
@@ -7002,10 +7027,10 @@ let setup_t =
oasis_version = "0.4";
ocaml_version = None;
findlib_version = None;
- alpha_features = ["compiled_setup_ml"];
+ alpha_features = ["compiled_setup_ml"; "ocamlbuild_more_args"];
beta_features = [];
name = "re";
- version = "1.5.0";
+ version = "1.6.0";
license =
OASISLicense.DEP5License
(OASISLicense.DEP5Unit
@@ -7084,7 +7109,8 @@ let setup_t =
{
lib_modules = ["Re"];
lib_pack = false;
- lib_internal_modules = ["Re_cset"; "Re_automata"];
+ lib_internal_modules =
+ ["Re_fmt"; "Re_cset"; "Re_automata"];
lib_findlib_parent = None;
lib_findlib_name = Some "re";
lib_findlib_containers = []
@@ -7759,8 +7785,8 @@ let setup_t =
plugin_data = []
};
oasis_fn = Some "_oasis";
- oasis_version = "0.4.5";
- oasis_digest = Some "�\014\001��\146\155>�a\015�>3\012\031";
+ oasis_version = "0.4.6";
+ oasis_digest = Some "\211\024:\168\249\128Yt&\200\190[m\210\175\204";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
@@ -7768,6 +7794,6 @@ let setup_t =
let setup () = BaseSetup.setup setup_t;;
-# 7772 "setup.ml"
+# 7798 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/ocaml-re.git
More information about the Pkg-ocaml-maint-commits
mailing list