summaryrefslogtreecommitdiff
path: root/re.c
diff options
context:
space:
mode:
authorkosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-05-15 12:39:25 +0000
committerkosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-05-15 12:39:25 +0000
commit8c5f9ef2eab6fe7e9f0531d0c670d053616d69be (patch)
tree5eb308c55edeb0acc744e74b19ece69f7cdc006c /re.c
parent2d80e59b76d67617e08d9f6f2c455c2255fc2ecc (diff)
downloadruby-8c5f9ef2eab6fe7e9f0531d0c670d053616d69be.tar.gz
don't use onig_recompile()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/re.c b/re.c
index e1ca4a00c7..08df5b38f3 100644
--- a/re.c
+++ b/re.c
@@ -906,7 +906,7 @@ rb_reg_prepare_re(VALUE re)
char err[ONIG_MAX_ERROR_MESSAGE_LEN];
int r;
OnigErrorInfo einfo;
- regex_t *reg;
+ regex_t *reg, *reg2;
UChar *pattern;
if (FL_TEST(re, KCODE_FIXED))
@@ -914,14 +914,18 @@ rb_reg_prepare_re(VALUE re)
rb_reg_check(re);
reg = RREGEXP(re)->ptr;
pattern = ((UChar*)RREGEXP(re)->str);
- r = onig_recompile(reg, pattern, pattern + RREGEXP(re)->len,
- reg->options, onigenc_get_default_encoding(),
- OnigDefaultSyntax, &einfo);
- if (r != 0) {
- (void )onig_error_code_to_str((UChar*)err, r, &einfo);
- rb_reg_raise(pattern, RREGEXP(re)->len, err, re, Qfalse);
+ r = onig_new(&reg2, (UChar* )pattern,
+ (UChar* )(pattern + RREGEXP(re)->len),
+ reg->options, onigenc_get_default_encoding(),
+ OnigDefaultSyntax, &einfo);
+ if (r) {
+ onig_error_code_to_str((UChar*)err, r, &einfo);
+ rb_reg_raise((char* )pattern, RREGEXP(re)->len, err, re, Qfalse);
}
+
+ RREGEXP(re)->ptr = reg2;
+ onig_free(reg);
}
}