diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-11-17 07:30:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-11-17 07:30:37 +0000 |
commit | b1d45b805c22e9dba70400100aa080c515e0f2c9 (patch) | |
tree | 4aface79ce936ccfadbedab533c57b939bbcee8d /re.c | |
parent | aa6ca26e8bdb71795582d9f0d511cf370f9fe585 (diff) |
19991117
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -182,6 +182,21 @@ kcode_reset_option() } } +int +rb_mbclen2(c, re) + unsigned char c; + VALUE re; +{ + int len; + + if (!FL_TEST(re, KCODE_FIXED)) + return mbclen(c); + kcode_set_option(re); + len = mbclen(c); + kcode_reset_option(); + return len; +} + extern int ruby_in_compile; static void @@ -260,10 +275,7 @@ static VALUE rb_reg_source(re) VALUE re; { - VALUE str = rb_str_new(0,0); - rb_reg_expr_str(str, RREGEXP(re)->str,RREGEXP(re)->len); - - return str; + return rb_str_new(RREGEXP(re)->str,RREGEXP(re)->len); } static VALUE @@ -538,6 +550,7 @@ rb_reg_search(reg, str, pos, reverse) } result = re_search(RREGEXP(reg)->ptr,RSTRING(str)->ptr,RSTRING(str)->len, pos, range, regs); + if (FL_TEST(reg, KCODE_FIXED)) kcode_reset_option(); @@ -710,7 +723,7 @@ static VALUE match_string(match) VALUE match; { - return rb_str_dup(RMATCH(match)->str); + return RMATCH(match)->str; /* str is frozen */ } VALUE rb_cRegexp; @@ -1263,7 +1276,9 @@ Init_Regexp() rb_global_variable(®_cache); rb_global_variable(&matchcache); - rb_cMatch = rb_define_class("MatchingData", rb_cData); + rb_cMatch = rb_define_class("MatchingData", rb_cObject); + rb_undef_method(CLASS_OF(rb_cMatch), "new"); + rb_define_method(rb_cMatch, "clone", match_clone, 0); rb_define_method(rb_cMatch, "size", match_size, 0); rb_define_method(rb_cMatch, "length", match_size, 0); |