[Pkg-ocaml-maint-commits] [pcre-ocaml] 08/18: Imported Upstream version 7.2.0
Stéphane Glondu
glondu at moszumanska.debian.org
Wed Aug 3 11:58:36 UTC 2016
This is an automated email from the git hooks/post-receive script.
glondu pushed a commit to branch master
in repository pcre-ocaml.
commit 0d0b646c154ef47685dbab27d6531127d8a02d40
Author: Stephane Glondu <steph at glondu.net>
Date: Wed Aug 3 13:44:42 2016 +0200
Imported Upstream version 7.2.0
---
CHANGES.txt | 4 ++++
_oasis | 6 ++---
examples/pcregrep/pcregrep.ml | 5 ++---
lib/META | 4 ++--
lib/pcre.ml | 50 +++++++++++++++---------------------------
lib/pcre.mli | 5 ++---
lib/pcre_stubs.c | 51 +++++++++++++++++++++++--------------------
myocamlbuild.ml | 8 ++++---
setup.ml | 13 ++++++-----
9 files changed, 70 insertions(+), 76 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 072bfc1..21b00c2 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,7 @@
+2016-02-22: Fixed a subgroup matching bug.
+
+ Thanks to Cheng Lou for the bug report!
+
2015-08-21: Made GC less aggressive reclaiming regexps and chartables.
2014-12-10: Fixed another limit handling bug in the full_split function.
diff --git a/_oasis b/_oasis
index 0488f46..6d6758d 100644
--- a/_oasis
+++ b/_oasis
@@ -1,10 +1,10 @@
OASISFormat: 0.4
Name: pcre
-Version: 7.1.6
+Version: 7.2.0
Synopsis: pcre-ocaml - bindings to the Perl Compatibility Regular Expressions library
Description: pcre-ocaml offers library functions for string pattern matching and substitution, similar to the functionality offered by the Perl language.
Authors: Markus Mottl <markus.mottl at gmail.com>
-Copyrights: (C) 1999-2015 Markus Mottl <markus.mottl at gmail.com>
+Copyrights: (C) 1999-2016 Markus Mottl <markus.mottl at gmail.com>
Maintainers: Markus Mottl <markus.mottl at gmail.com>
LicenseFile: COPYING.txt
License: LGPL-2.1+ with OCaml linking exception
@@ -32,7 +32,7 @@ Library pcre
BuildDepends: bytes
CCOpt: -g -O2 -fPIC -DPIC
if flag(strict) && ccomp_type(cc)
- CCOpt+: -Wall -pedantic -Wextra -Wunused -Wno-long-long
+ CCOpt+: -Wall -pedantic -Wextra -Wunused -Wno-long-long -Wno-keyword-macro
# Examples
diff --git a/examples/pcregrep/pcregrep.ml b/examples/pcregrep/pcregrep.ml
index 125ae16..1c31528 100644
--- a/examples/pcregrep/pcregrep.ml
+++ b/examples/pcregrep/pcregrep.ml
@@ -54,7 +54,7 @@ let _ =
let rex, files = parse_args ()
and rfl = rflags [] in
- let subgroups2, ovector = make_ovector rex in
+ let _, ovector = make_ovector rex in
let pcregrep file name =
let ret_code = ref 1
@@ -72,8 +72,7 @@ let _ =
let try_match line =
let matched =
try
- unsafe_pcre_exec
- rfl rex ~pos:0 ~subj_start:0 ~subj:line ~subgroups2 ovector None;
+ unsafe_pcre_exec rfl rex ~pos:0 ~subj_start:0 ~subj:line ovector None;
if !whole_lines && ovector.(1) <> String.length line then false
else true
with Not_found -> false in
diff --git a/lib/META b/lib/META
index bb49166..ba54349 100644
--- a/lib/META
+++ b/lib/META
@@ -1,6 +1,6 @@
# OASIS_START
-# DO NOT EDIT (digest: 46f60b1fadbd7e6335f389b0d4471def)
-version = "7.1.6"
+# DO NOT EDIT (digest: 093107e478c4b229806291bc9be362f2)
+version = "7.2.0"
description =
"pcre-ocaml - bindings to the Perl Compatibility Regular Expressions library"
requires = "bytes"
diff --git a/lib/pcre.ml b/lib/pcre.ml
index 07f162d..8bcd5ef 100644
--- a/lib/pcre.ml
+++ b/lib/pcre.ml
@@ -384,7 +384,6 @@ external unsafe_pcre_exec :
pos : int ->
subj_start : int ->
subj : string ->
- subgroups2 : int ->
int array ->
callout option ->
unit = "pcre_exec_stub_bc" "pcre_exec_stub"
@@ -398,9 +397,8 @@ let pcre_exec ?(iflags = 0) ?flags ?(rex = def_rex) ?pat ?(pos = 0)
?callout subj =
let rex = match pat with Some str -> regexp str | _ -> rex in
let iflags = match flags with Some flags -> rflags flags | _ -> iflags in
- let subgroups2, ovector = make_ovector rex in
- unsafe_pcre_exec
- iflags rex ~pos ~subj_start:0 ~subj ~subgroups2 ovector callout;
+ let _, ovector = make_ovector rex in
+ unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout;
ovector
let exec ?iflags ?flags ?rex ?pat ?pos ?callout subj =
@@ -581,7 +579,7 @@ let replace ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
try
unsafe_pcre_exec
iflags rex ~pos:cur_pos ~subj_start:0 ~subj
- ~subgroups2 ovector callout;
+ ovector callout;
false
with Not_found -> true
then
@@ -625,14 +623,13 @@ let qreplace ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
let subj_len = String.length subj in
if pos < 0 || pos > subj_len then invalid_arg "Pcre.qreplace: illegal offset";
let templ_len = String.length templ in
- let subgroups2, ovector = make_ovector rex in
+ let _, ovector = make_ovector rex in
let rec loop full_len subst_lst cur_pos =
if
cur_pos > subj_len ||
try
unsafe_pcre_exec
- iflags rex ~pos:cur_pos ~subj_start:0 ~subj
- ~subgroups2 ovector callout;
+ iflags rex ~pos:cur_pos ~subj_start:0 ~subj ovector callout;
false
with Not_found -> true
then
@@ -674,14 +671,13 @@ let substitute_substrings ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
let iflags = match flags with Some flags -> rflags flags | _ -> iflags in
let subj_len = String.length subj in
if pos < 0 || pos > subj_len then invalid_arg "Pcre.substitute: illegal offset";
- let subgroups2, ovector = make_ovector rex in
+ let _, ovector = make_ovector rex in
let rec loop full_len subst_lst cur_pos =
if
cur_pos > subj_len ||
try
unsafe_pcre_exec
- iflags rex ~pos:cur_pos ~subj_start:0 ~subj
- ~subgroups2 ovector callout;
+ iflags rex ~pos:cur_pos ~subj_start:0 ~subj ovector callout;
false
with Not_found -> true
then
@@ -736,9 +732,7 @@ let replace_first ?(iflags = 0) ?flags ?(rex = def_rex) ?pat ?(pos = 0)
failwith "Pcre.replace_first: backreference denotes nonexistent subpattern";
if with_lp && nsubs = 0 then failwith "Pcre.replace_first: no backreferences";
try
- unsafe_pcre_exec
- iflags rex ~pos ~subj_start:0 ~subj
- ~subgroups2 ovector callout;
+ unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout;
let res_len, trans_lst =
calc_trans_lst subgroups2 ovector subj templ subst_lst in
let first = Array.unsafe_get ovector 0 in
@@ -757,11 +751,9 @@ let qreplace_first ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
?(pos = 0) ?(templ = "") ?callout subj =
let rex = match pat with Some str -> regexp str | _ -> rex in
let iflags = match flags with Some flags -> rflags flags | _ -> iflags in
- let subgroups2, ovector = make_ovector rex in
+ let _, ovector = make_ovector rex in
try
- unsafe_pcre_exec
- iflags rex ~pos ~subj_start:0 ~subj
- ~subgroups2 ovector callout;
+ unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout;
let first = Array.unsafe_get ovector 0 in
let last = Array.unsafe_get ovector 1 in
let len = String.length templ in
@@ -778,11 +770,9 @@ let substitute_substrings_first ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
?(pos = 0) ?callout ~subst subj =
let rex = match pat with Some str -> regexp str | _ -> rex in
let iflags = match flags with Some flags -> rflags flags | _ -> iflags in
- let subgroups2, ovector = make_ovector rex in
+ let _, ovector = make_ovector rex in
try
- unsafe_pcre_exec
- iflags rex ~pos ~subj_start:0 ~subj
- ~subgroups2 ovector callout;
+ unsafe_pcre_exec iflags rex ~pos ~subj_start:0 ~subj ovector callout;
let subj_len = String.length subj in
let prefix_len = Array.unsafe_get ovector 0 in
let last = Array.unsafe_get ovector 1 in
@@ -841,8 +831,7 @@ let internal_psplit flags rex max pos callout subj =
if prematch &&
try
unsafe_pcre_exec
- flags rex ~pos ~subj_start:pos ~subj
- ~subgroups2 ovector callout;
+ flags rex ~pos ~subj_start:pos ~subj ovector callout;
true
with Not_found -> false
then
@@ -856,8 +845,7 @@ let internal_psplit flags rex max pos callout subj =
if
try
unsafe_pcre_exec
- flags rex ~pos ~subj_start:pos ~subj
- ~subgroups2 ovector callout;
+ flags rex ~pos ~subj_start:pos ~subj ovector callout;
false
with Not_found -> true
then string_unsafe_sub subj pos len :: strs
@@ -872,7 +860,7 @@ let internal_psplit flags rex max pos callout subj =
try
unsafe_pcre_exec
(flags lor 0x0410) rex ~pos ~subj_start:pos ~subj
- ~subgroups2 ovector callout;
+ ovector callout;
true
with Not_found -> false
then
@@ -964,8 +952,7 @@ let full_split ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
if prematch &&
try
unsafe_pcre_exec
- iflags rex ~pos ~subj_start:pos ~subj
- ~subgroups2 ovector callout;
+ iflags rex ~pos ~subj_start:pos ~subj ovector callout;
true
with Not_found -> false
then
@@ -983,8 +970,7 @@ let full_split ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
if
try
unsafe_pcre_exec
- iflags rex ~pos ~subj_start:pos ~subj
- ~subgroups2 ovector callout;
+ iflags rex ~pos ~subj_start:pos ~subj ovector callout;
false
with Not_found -> true
then
@@ -1002,7 +988,7 @@ let full_split ?(iflags = 0) ?flags ?(rex = def_rex) ?pat
try
unsafe_pcre_exec
(iflags lor 0x0410) rex ~pos ~subj_start:pos ~subj
- ~subgroups2 ovector callout;
+ ovector callout;
true
with Not_found -> false
then
diff --git a/lib/pcre.mli b/lib/pcre.mli
index 723f517..b446a4d 100644
--- a/lib/pcre.mli
+++ b/lib/pcre.mli
@@ -916,12 +916,11 @@ external unsafe_pcre_exec :
pos : int ->
subj_start : int ->
subj : string ->
- subgroups2 : int ->
int array ->
callout option ->
unit = "pcre_exec_stub_bc" "pcre_exec_stub"
-(** [unsafe_pcre_exec flags rex ~pos ~subj_start ~subj ~subgroups2
- offset_vector]. You should read the C-source to know what happens.
+(** [unsafe_pcre_exec flags rex ~pos ~subj_start ~subj offset_vector].
+ You should read the C-source to know what happens.
If you do not understand it - {b don't use this function!} *)
val make_ovector : regexp -> int * int array
diff --git a/lib/pcre_stubs.c b/lib/pcre_stubs.c
index 68702be..dbee6f6 100644
--- a/lib/pcre_stubs.c
+++ b/lib/pcre_stubs.c
@@ -70,7 +70,7 @@ typedef const unsigned char *chartables; /* Type of chartable sets */
/* Contents of callout data */
struct cod {
- long subj_start; /* Start of subject string */
+ long subj_start; /* Start of subject string */
value *v_substrings_p; /* Pointer to substrings matched so far */
value *v_cof_p; /* Pointer to callout function */
value v_exn; /* Possible exception raised by callout function */
@@ -187,7 +187,7 @@ static void pcre_dealloc_regexp(value v_rex)
{
void *extra = (void *) Field(v_rex, 2);
(pcre_free)((void *) Field(v_rex, 1));
- if (extra != NULL) (pcre_free)(extra);
+ if (extra != NULL) pcre_free_study(extra);
}
/* Makes OCaml-string from PCRE-version */
@@ -306,7 +306,7 @@ CAMLprim value pcre_set_imp_match_limit_recursion_stub(value v_rex, value v_lim)
{
pcre_extra *extra = (pcre_extra *) Field(v_rex, 2);
if (extra == NULL) {
- extra = caml_stat_alloc(sizeof(pcre_extra));
+ extra = pcre_malloc(sizeof(pcre_extra));
extra->flags = PCRE_EXTRA_MATCH_LIMIT_RECURSION;
Field(v_rex, 2) = (value) extra;
} else {
@@ -336,7 +336,7 @@ CAMLprim value pcre_set_imp_match_limit_stub(value v_rex, value v_lim)
{
pcre_extra *extra = (pcre_extra *) Field(v_rex, 2);
if (extra == NULL) {
- extra = caml_stat_alloc(sizeof(pcre_extra));
+ extra = pcre_malloc(sizeof(pcre_extra));
extra->flags = PCRE_EXTRA_MATCH_LIMIT;
Field(v_rex, 2) = (value) extra;
} else {
@@ -496,19 +496,33 @@ static inline void handle_exec_error(char *loc, const int ret)
}
}
+static inline void handle_pcre_exec_result(
+ value v_ovec, long ovec_len, long subj_start, int ret)
+{
+ int *ovec = (int *) &Field(v_ovec, 0);
+ const int subgroups2 = ret * 2;
+ const int subgroups2_1 = subgroups2 - 1;
+ const int *ovec_src = ovec + subgroups2_1;
+ ovec_dst_ptr ovec_clear_stop = (ovec_dst_ptr) ovec + (ovec_len * 2) / 3;
+ ovec_dst_ptr ovec_dst = (ovec_dst_ptr) ovec + subgroups2_1;
+ copy_ovector(subj_start, ovec_src, ovec_dst, subgroups2);
+ while (++ovec_dst < ovec_clear_stop) *ovec_dst = -1;
+}
+
/* Executes a pattern match with runtime options, a regular expression, a
matching position, the start of the the subject string, a subject string,
a number of subgroup offsets, an offset vector and an optional callout
function */
CAMLprim value pcre_exec_stub(value v_opt, value v_rex, value v_pos,
value v_subj_start, value v_subj,
- value v_subgroups2, value v_ovec,
- value v_maybe_cof)
+ value v_ovec, value v_maybe_cof)
{
+ int ret;
long
pos = Long_val(v_pos),
len = caml_string_length(v_subj),
subj_start = Long_val(v_subj_start);
+ long ovec_len = caml_array_length(v_ovec);
if (pos > len || pos < subj_start)
caml_invalid_argument("Pcre.pcre_exec_stub: illegal position");
@@ -525,24 +539,16 @@ CAMLprim value pcre_exec_stub(value v_opt, value v_rex, value v_pos,
const char *ocaml_subj =
String_val(v_subj) + subj_start; /* Subject string */
const int opt = Int_val(v_opt); /* Runtime options */
- int subgroups2 = Int_val(v_subgroups2);
- const int subgroups2_1 = subgroups2 - 1;
- const int subgroups3 = (subgroups2 >> 1) + subgroups2;
/* Special case when no callout functions specified */
if (v_maybe_cof == None) {
int *ovec = (int *) &Field(v_ovec, 0);
/* Performs the match */
- const int ret =
- pcre_exec(code, extra, ocaml_subj, len, pos, opt, ovec, subgroups3);
+ ret = pcre_exec(code, extra, ocaml_subj, len, pos, opt, ovec, ovec_len);
if (ret < 0) handle_exec_error("pcre_exec_stub", ret);
- else {
- const int *ovec_src = ovec + subgroups2_1;
- ovec_dst_ptr ovec_dst = (ovec_dst_ptr) ovec + subgroups2_1;
- copy_ovector(subj_start, ovec_src, ovec_dst, subgroups2);
- }
+ else handle_pcre_exec_result(v_ovec, ovec_len, subj_start, ret);
}
/* There are callout functions */
@@ -550,8 +556,7 @@ CAMLprim value pcre_exec_stub(value v_opt, value v_rex, value v_pos,
value v_cof = Field(v_maybe_cof, 0);
value v_substrings;
char *subj = caml_stat_alloc(sizeof(char) * len);
- int *ovec = caml_stat_alloc(sizeof(int) * subgroups3);
- int ret;
+ int *ovec = caml_stat_alloc(sizeof(int) * ovec_len);
struct cod cod = { 0, (value *) NULL, (value *) NULL, (value) NULL };
struct pcre_extra new_extra =
#ifdef PCRE_EXTRA_MATCH_LIMIT_RECURSION
@@ -585,7 +590,7 @@ CAMLprim value pcre_exec_stub(value v_opt, value v_rex, value v_pos,
if (extra == NULL) {
ret = pcre_exec(code, &new_extra, subj, len, pos, opt, ovec,
- subgroups3);
+ ovec_len);
}
else {
new_extra.flags = PCRE_EXTRA_CALLOUT_DATA | extra->flags;
@@ -597,7 +602,7 @@ CAMLprim value pcre_exec_stub(value v_opt, value v_rex, value v_pos,
#endif
ret = pcre_exec(code, &new_extra, subj, len, pos, opt, ovec,
- subgroups3);
+ ovec_len);
}
caml_stat_free(subj);
@@ -608,9 +613,7 @@ CAMLprim value pcre_exec_stub(value v_opt, value v_rex, value v_pos,
if (ret == PCRE_ERROR_CALLOUT) caml_raise(cod.v_exn);
else handle_exec_error("pcre_exec_stub(callout)", ret);
} else {
- int *ovec_src = ovec + subgroups2_1;
- ovec_dst_ptr ovec_dst = &Field(v_ovec, 0) + subgroups2_1;
- copy_ovector(subj_start, ovec_src, ovec_dst, subgroups2);
+ handle_pcre_exec_result(v_ovec, ovec_len, subj_start, ret);
caml_stat_free(ovec);
}
}
@@ -624,7 +627,7 @@ CAMLprim value pcre_exec_stub(value v_opt, value v_rex, value v_pos,
CAMLprim value pcre_exec_stub_bc(value *argv, int __unused argn)
{
return pcre_exec_stub(argv[0], argv[1], argv[2], argv[3],
- argv[4], argv[5], argv[6], argv[7]);
+ argv[4], argv[5], argv[6]);
}
/* Generates a new set of chartables for the current locale (see man
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index 94937a5..a2a8bd9 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -1,5 +1,5 @@
(* OASIS_START *)
-(* DO NOT EDIT (digest: 0a2bbc688e326d6a5236c3ef397baf42) *)
+(* DO NOT EDIT (digest: f0facc1ae39d5d65514819e5e196ebdd) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)
@@ -647,7 +647,9 @@ let package_default =
A "-ccopt";
A "-Wunused";
A "-ccopt";
- A "-Wno-long-long"
+ A "-Wno-long-long";
+ A "-ccopt";
+ A "-Wno-keyword-macro"
])
])
];
@@ -665,7 +667,7 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
-# 669 "myocamlbuild.ml"
+# 671 "myocamlbuild.ml"
(* OASIS_STOP *)
let () =
diff --git a/setup.ml b/setup.ml
index 340bf63..4f5840e 100644
--- a/setup.ml
+++ b/setup.ml
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.3.0 *)
(* OASIS_START *)
-(* DO NOT EDIT (digest: 9386999e3424345a63db8a4c91e5ae7d) *)
+(* DO NOT EDIT (digest: 60f0fcaadee205d5fbe6f170edbc241e) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
@@ -6683,7 +6683,7 @@ let setup_t =
alpha_features = [];
beta_features = [];
name = "pcre";
- version = "7.1.6";
+ version = "7.2.0";
license =
OASISLicense.DEP5License
(OASISLicense.DEP5Unit
@@ -6694,7 +6694,7 @@ let setup_t =
});
license_file = Some "COPYING.txt";
copyrights =
- ["(C) 1999-2015 Markus Mottl <markus.mottl at gmail.com>"];
+ ["(C) 1999-2016 Markus Mottl <markus.mottl at gmail.com>"];
maintainers = ["Markus Mottl <markus.mottl at gmail.com>"];
authors = ["Markus Mottl <markus.mottl at gmail.com>"];
homepage = Some "http://mmottl.github.io/pcre-ocaml";
@@ -6785,7 +6785,8 @@ let setup_t =
"-pedantic";
"-Wextra";
"-Wunused";
- "-Wno-long-long"
+ "-Wno-long-long";
+ "-Wno-keyword-macro"
])
];
bs_cclib = [(OASISExpr.EBool true, [])];
@@ -6982,7 +6983,7 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
- oasis_digest = Some "�\146�\145\003bTN��J9<�Jc";
+ oasis_digest = Some "X\138�7\133-\026��z�\016E�\137�";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
@@ -6990,7 +6991,7 @@ let setup_t =
let setup () = BaseSetup.setup setup_t;;
-# 6994 "setup.ml"
+# 6995 "setup.ml"
(* OASIS_STOP *)
let pcre_config =
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/pcre-ocaml.git
More information about the Pkg-ocaml-maint-commits
mailing list