summaryrefslogtreecommitdiff
path: root/ext/strscan
diff options
context:
space:
mode:
Diffstat (limited to 'ext/strscan')
-rw-r--r--ext/strscan/strscan.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 8c94d1c60d..99c0451e36 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -403,7 +403,9 @@ strscan_set_pos(VALUE self, VALUE v)
static VALUE
strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly)
{
+ regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
struct strscanner *p;
+ regex_t *re;
int ret;
Check_Type(regex, T_REGEXP);
@@ -413,13 +415,14 @@ strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly)
if (S_RESTLEN(p) < 0) {
return Qnil;
}
+ re = rb_reg_prepare_re(regex, p->str);
if (headonly) {
- ret = onig_match(RREGEXP(regex)->ptr, (UChar* )CURPTR(p),
+ ret = onig_match(re, (UChar* )CURPTR(p),
(UChar* )(CURPTR(p) + S_RESTLEN(p)),
(UChar* )CURPTR(p), &(p->regs), ONIG_OPTION_NONE);
}
else {
- ret = onig_search(RREGEXP(regex)->ptr,
+ ret = onig_search(re,
(UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
(UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
&(p->regs), ONIG_OPTION_NONE);