8 Commits

Author SHA1 Message Date
Andrew Gallant
fc3e6aa19a
license: remove license headers from files
The Rust project determined these were unnecessary a while back[1,2,3]
and we follow suite.

[1] - 0565653eec
[2] - https://github.com/rust-lang/rust/pull/43498
[3] - https://github.com/rust-lang/rust/pull/57108
2019-08-03 14:47:45 -04:00
marmeladema
67fca6cbff capi: add rure_escape_must function
This commit exposes two new functions in regex's C API: rure_escape_must
and rure_cstring_free. These permit escaping a pattern such that it
contains no special regex meta characters.

Currently, we only expose a routine that will abort the process if it
fails, but we document the precise error conditions. A more flexible but
less convenient routine should ideally be exposed in the future, but
that needs a bit more API design than what's here.

Closes #537
2019-03-30 10:47:45 -04:00
tiehuis
f54bd2428a Update rure_set documentation for new fields 2016-10-24 15:04:01 +13:00
tiehuis
01644e0f25 Update prototypes with mock values 2016-10-24 14:04:44 +13:00
tiehuis
1a71cfc03e Update documentation + add rure_set_len function 2016-10-20 20:06:04 +13:00
tiehuis
143ff2f531 Add RegexSet functionality to C API
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.
2016-10-19 18:32:12 +13:00
David Blewett
7f3d36402f Expose the CaptureNames iterator to the C API:
* 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
2016-09-25 23:25:29 -04:00
Andrew Gallant
97d374b680 Add rure, a C API.
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.
2016-04-29 10:42:11 -04:00