pcre-ocaml
pcre-ocaml copied to clipboard
Please switch to pcre2
PCRE (known as PCRE3 in Debian), used by pcre-ocaml, is obsolete. Pcre-ocaml should be ported to PCRE2.
FTR: https://github.com/PhilipHazel/pcre2/issues/51
Philip Hazel recently added support for more Unicode character properties in PCRE2, which is useful and lacking from PCRE1.
It would certainly make sense to switch to PCRE2. Unfortunately, I do not currently have time to work on this. I don't know to which extent PCRE2 is backward-compatible. I assume many parts of the resulting API would be significantly different, but most functions for e.g. splitting, replacing, etc., can probably be adapted easily.
I'd suggest forking pcre-ocaml
to pcre2-ocaml
and leaving pcre-ocaml
as-is. Once pcre2-ocaml
is sufficiently stable, pcre-ocaml
could be marked as obsolete.
Hello, I've created a fork as we needed to update the pcre bindings for the Haxe compiler. It's available here if anyone is interested: https://github.com/tobil4sk/pcre2-ocaml
I've just rewritten the existing ocaml functions to use pcre2, without adding much of the new pcre2 functionality which could be added. However, jit compilation is missing, and get_match_limit
and get_match_limit_recursion
(would now be get_depth_limit
) also had to be removed for now since there is no easy way to implement them in pcre2, though the values could be stored manually. A few function names have also been changed to reflect the new pcre2 api, though exec
remained the same as match
is a reserved keyword.
I'm happy to accept PRs if anyone wants to expand the functionality, however, I unfortunately don't have the OCaml knowledge to maintain a package, so I don't plan to work on it myself any more than what is needed by Haxe. So if anyone would like to fork and properly maintain it, feel free to do so.
@tobil4sk: Yes, it would be good to get this up on opam (even in its current state). Perhaps this will stimulate interest and someone will step up (it seems like Markus does not want to maintain this further). Many things still depend on pcre-ocaml and I am sure if they are maintained at all they want to get off it. I know Plato inspired the proverb "necessity is the mother of invention" but often it also begets interest.
@tobil4sk This looks great. Would you consider moving the code to https://github.com/ocaml-community/ ?
@tobil4sk If nobody else volunteers to help with maintenance and publishing to opam, I will be happy to volunteer. Camlp5's pa_ppx_regexp
relies on pcre, and I certainly want pcre to be available to ocaml for the foreseeable future.
@chetmurthy Do feel free to take it on. As I said before I'm not currently deep enough into the OCaml ecosystem to be able to properly maintain a package myself. Might be worth considering https://github.com/ocaml-community/ as @toots mentioned. If you have any questions or anything, let me know, I can try my best to answer.
It might also be good if someone with more experience than me with OCaml C bindings would have a look to make sure there aren't any glaring issues before a proper release is made. I tried to follow the guidance in the OCaml docs and the bindings work fine so far for our project (Haxe) but C code is always prone to random memory issues and the like.
@tobil4sk OK, before I do so, I thought I'd ask on the OCaml discussion forum if anybody wanted to take it on? Just b/c .... well, I feel a little odd picking up something that's this .... useful. I maintain a bunch of stuff that's pretty peripheral, and .... pcre
is anything but peripheral (to me).
Re: OCaml/C bindings, I've had a lot of experience with that, and will do a (trying to be) careful scan before I release, if I take this up.
Can you let me know if it's OK for mme to post on the OCaml forum, asking if anybody else wants to take this project up?
Can you let me know if it's OK for mme to post on the OCaml forum, asking if anybody else wants to take this project up?
@chetmurthy Please proceed.
Can you let me know if it's OK for mme to post on the OCaml forum, asking if anybody else wants to take this project up?
@chetmurthy That's all good with me, thanks.
Just checking in after a long hiatus. For the while being, I will maintain pcre-ocaml
to make sure it still compiles and works with recent compiler releases. But future work should preferably go into new bindings for more recent PCRE versions.