diff options
author | kosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-15 12:39:25 +0000 |
---|---|---|
committer | kosako <kosako@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-05-15 12:39:25 +0000 |
commit | 8c5f9ef2eab6fe7e9f0531d0c670d053616d69be (patch) | |
tree | 5eb308c55edeb0acc744e74b19ece69f7cdc006c /re.c | |
parent | 2d80e59b76d67617e08d9f6f2c455c2255fc2ecc (diff) | |
download | ruby-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.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -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(®2, (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); } } |