mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Resurrect rb_reg_prepare_re C API
Existing strscan releases rely on this C API. It means that the current Ruby master doesn't work if your Gemfile.lock has strscan unless it's locked to 3.0.7, which is not released yet. To fix it, let's not remove the C API we've exposed to users.
This commit is contained in:
parent
5669a28fde
commit
9721972175
2 changed files with 22 additions and 1 deletions
|
@ -105,6 +105,27 @@ long rb_reg_adjust_startpos(VALUE re, VALUE str, long pos, int dir);
|
||||||
*/
|
*/
|
||||||
VALUE rb_reg_quote(VALUE str);
|
VALUE rb_reg_quote(VALUE str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exercises various checks and preprocesses so that the given regular
|
||||||
|
* expression can be applied to the given string. The preprocess here includes
|
||||||
|
* (but not limited to) for instance encoding conversion.
|
||||||
|
*
|
||||||
|
* @param[in] re Target regular expression.
|
||||||
|
* @param[in] str What `re` is about to run on.
|
||||||
|
* @exception rb_eArgError `re` does not fit for `str`.
|
||||||
|
* @exception rb_eEncCompatError `re` and `str` are incompatible.
|
||||||
|
* @exception rb_eRegexpError `re` is malformed.
|
||||||
|
* @return A preprocessesed pattern buffer ready to be applied to `str`.
|
||||||
|
* @note The return value is manages by our GC. Don't free.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* The return type, `regex_t *`, is defined in `<ruby/onigmo.h>`, _and_
|
||||||
|
* _conflicts_ with POSIX's `<regex.h>`. We can no longer save the situation
|
||||||
|
* at this point. Just don't mix the two.
|
||||||
|
*/
|
||||||
|
regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a regular expression match using function `match`. Performs preparation,
|
* Runs a regular expression match using function `match`. Performs preparation,
|
||||||
* error handling, and memory cleanup.
|
* error handling, and memory cleanup.
|
||||||
|
|
2
re.c
2
re.c
|
@ -1575,7 +1575,7 @@ rb_reg_prepare_enc(VALUE re, VALUE str, int warn)
|
||||||
return enc;
|
return enc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static regex_t *
|
regex_t *
|
||||||
rb_reg_prepare_re(VALUE re, VALUE str)
|
rb_reg_prepare_re(VALUE re, VALUE str)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue