mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_hash): define Regexp#hash to make regexps to be
hash keys. * re.c (Init_Regexp): define Regexp#eql? (alias to Regexp#==). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d307881fe4
commit
f744cfd8d7
2 changed files with 28 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Thu Dec 12 17:27:19 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* re.c (rb_reg_hash): define Regexp#hash to make regexps to be
|
||||||
|
hash keys.
|
||||||
|
|
||||||
|
* re.c (Init_Regexp): define Regexp#eql? (alias to Regexp#==).
|
||||||
|
|
||||||
Thu Dec 12 16:26:31 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Thu Dec 12 16:26:31 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* marshal.c (r_object0): singleton class instance can't be loaded.
|
* marshal.c (r_object0): singleton class instance can't be loaded.
|
||||||
|
|
21
re.c
21
re.c
|
@ -1056,6 +1056,25 @@ rb_reg_cur_kcode(re)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rb_reg_hash(re)
|
||||||
|
VALUE re;
|
||||||
|
{
|
||||||
|
int hashval, len;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
rb_reg_check(re);
|
||||||
|
hashval = RREGEXP(re)->ptr->options;
|
||||||
|
len = RREGEXP(re)->len;
|
||||||
|
p = RREGEXP(re)->str;
|
||||||
|
while (len--) {
|
||||||
|
hashval = hashval * 33 + *p++;
|
||||||
|
}
|
||||||
|
hashval = hashval + (hashval>>5);
|
||||||
|
|
||||||
|
return INT2FIX(hashval);
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_reg_equal(re1, re2)
|
rb_reg_equal(re1, re2)
|
||||||
VALUE re1, re2;
|
VALUE re1, re2;
|
||||||
|
@ -1560,6 +1579,8 @@ Init_Regexp()
|
||||||
|
|
||||||
rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1);
|
rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1);
|
||||||
rb_define_method(rb_cRegexp, "copy_object", rb_reg_copy_object, 1);
|
rb_define_method(rb_cRegexp, "copy_object", rb_reg_copy_object, 1);
|
||||||
|
rb_define_method(rb_cRegexp, "hash", rb_reg_hash, 0);
|
||||||
|
rb_define_method(rb_cRegexp, "eql?", rb_reg_equal, 1);
|
||||||
rb_define_method(rb_cRegexp, "==", rb_reg_equal, 1);
|
rb_define_method(rb_cRegexp, "==", rb_reg_equal, 1);
|
||||||
rb_define_method(rb_cRegexp, "=~", rb_reg_match, 1);
|
rb_define_method(rb_cRegexp, "=~", rb_reg_match, 1);
|
||||||
rb_define_method(rb_cRegexp, "===", rb_reg_match, 1);
|
rb_define_method(rb_cRegexp, "===", rb_reg_match, 1);
|
||||||
|
|
Loading…
Reference in a new issue