pcre-ocaml icon indicating copy to clipboard operation
pcre-ocaml copied to clipboard

Please switch to pcre2

Open glondu opened this issue 3 years ago • 12 comments

PCRE (known as PCRE3 in Debian), used by pcre-ocaml, is obsolete. Pcre-ocaml should be ported to PCRE2.

glondu avatar Nov 18 '21 13:11 glondu

FTR: https://github.com/PhilipHazel/pcre2/issues/51

glondu avatar Dec 05 '21 12:12 glondu

Philip Hazel recently added support for more Unicode character properties in PCRE2, which is useful and lacking from PCRE1.

mjambon avatar Jan 15 '22 02:01 mjambon

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.

mmottl avatar Jan 17 '22 18:01 mmottl

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 avatar Mar 25 '23 12:03 tobil4sk

@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.

Uzume avatar Mar 25 '23 12:03 Uzume

@tobil4sk This looks great. Would you consider moving the code to https://github.com/ocaml-community/ ?

toots avatar Jul 29 '23 15:07 toots

@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 avatar Aug 13 '23 21:08 chetmurthy

@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 avatar Aug 15 '23 10:08 tobil4sk

@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?

chetmurthy avatar Aug 16 '23 05:08 chetmurthy

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.

glondu avatar Aug 18 '23 10:08 glondu

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.

tobil4sk avatar Aug 18 '23 12:08 tobil4sk

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.

mmottl avatar Aug 18 '23 14:08 mmottl