These functions implement a C interface to the RegexSet api.
Some notes:
* These do not include start offsets as the standard regex functions
do. The reason being is down to how these are implemented in the core
regex crate. The RegexSet api does not expose a public is_match_at
whilst the Regex api does.
* This only tests a complete compile/match mainly for sanity. One or
two more tests targetting the specific areas would be preferred.
* Set matches take a mutuable array to fill with results. This is more
C-like and allows the caller to manage the memory on the stack if
they want.
* Add new `rure_iter_capture_names` struct
- Opaque pointer encapsulates access to:
- Underyling Rust iterator
- Each capture group name CString
* Add functions for instantiating the iterator and processing:
- `rure_iter_capture_names_new`
- `rure_iter_capture_names_next`
- `rure_iter_capture_names_free`
* Track CString objects handed out, and free them when called.
* Add unit test for new functions
This commit contains a new sub-crate called `regex-capi` which provides
a C library called `rure`.
A new `RegexBuilder` type was also added to the Rust API proper, which
permits both users of C and Rust to tweak various knobs on a `Regex`.
This fixes issue #166.
Since it's likely that this API will be used to provide bindings to
other languages, I've created bindings to Go as a proof of concept:
https://github.com/BurntSushi/rure-go --- to my knowledge, the wrapper
has as little overhead as it can. It was in particular important for the
C library to not store any pointers provided by the caller, as this can
be problematic in languages with managed runtimes and a moving GC.
The C API doesn't expose `RegexSet` and a few other convenience functions
such as splitting or replacing. That can be future work.
Note that the regex-capi crate requires Rust 1.9, since it uses
`panic::catch_unwind`.
This also includes tests of basic API functionality and a commented
example. Both should now run as part of CI.