Unfortunately, there is a bit of confusion about the regular expression backend used by Ocamlnet. Traditionally, this was always PCRE, and not the Str library coming with the OCaml distribution. The reason was that Str did not have a thread-safe API, but it was required to make Ocamlnet thread-safe.
However, recent OCaml releases ship with a version of Str that can be easily made thread-safe. Because of this, the default regexp backend is now Str, with an option to use PCRE instead.
So we have now by default:
Netstring_str: This is a thread-safe API around Str. All uses of regular expressions inside the OCamlnet code base call functions of this module only.
You can enable PCRE in the configure script with
-enable-full-pcre. The effects are as follows:
Netstring_str: If only
-enable-pcreis configured, this is still an API around Str. If, however,
-enable-full-pcreis configured, the module maps the functions to PCRE calls. Note that the regular expressions still use Str-compatible syntax, so this switch of the backend is normally invisible to the caller.
Netstring_pcre: This module is now available for both configure options.
Netstring_pcreprovides the same API, but uses PCRE-style regular expression syntax. We provide this module solely for backward compatibility with older versions of Ocamlnet. Note that previous versions of Ocamlnet added this module to the
netstringlibrary, but it is now in the new
The meanings of the configuration options are thus:
-enable-pcre: The default regexp engine is still Str, and
Netstring_pcreis available in the separate library
-enable-full-pcre: The regexp engine is changed to PCRE, and
Netstring_pcreis also available in the separate library
OPAM users: Note that the OPAM package for OCamlnet does not
build with PCRE support by default. The trigger for this is the presence
pcre OPAM package, i.e. do
opam install pcre
netstring-pcre in a rebuild.
Actually, Ocamlnet stepped away from PCRE in several phases.
Netstring_strused Str syntax, but mapped this to PCRE syntax.
Netstring_strcan now use Str as backend. There are still thread-safety issues, so this was not made the default, and only active after
-enable-pcrereverted to the previous behavior: PCRE backed
Netstring_pcrewas built. The latter module was moved to its own library
-enable-full-pcrewith the meaning that PCRE becomes the backend, and
-enable-pcrehas now the weaker meaning that
For packagers of Ocamlnet, the recommendation is to build Ocamlnet
with Str as default engine, and to offer PCRE as option (i.e.
-enable-pcre). The latter allows it to easily port other software
to the new Ocamlnet style.
It is discouraged to switch completely to PCRE (
For users of Ocamlnet, the recommendations are: