зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_equal): a == b is true when b is non T_ARRAY
object, if b has "to_ary" and b == a. * hash.c (rb_hash_equal): a == b is true when b is non T_HASH object, if b has "to_hash" and b == a. * string.c (rb_str_equal): a == b is true when b is non T_STRING object, if b has "to_str" and b == a. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
c46774cdb3
Коммит
1d5e19f624
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
Tue Feb 4 16:11:30 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_equal): a == b is true when b is non T_ARRAY
|
||||
object, if b has "to_ary" and b == a.
|
||||
|
||||
* hash.c (rb_hash_equal): a == b is true when b is non T_HASH
|
||||
object, if b has "to_hash" and b == a.
|
||||
|
||||
* string.c (rb_str_equal): a == b is true when b is non T_STRING
|
||||
object, if b has "to_str" and b == a.
|
||||
|
||||
Mon Feb 3 23:46:48 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* io.c (argf_getline): should not increment lineno at EOF.
|
||||
|
||||
Mon Feb 3 16:49:19 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (Init_Object): default Object#=== now calls "=="
|
||||
|
|
7
array.c
7
array.c
|
@ -1563,7 +1563,12 @@ rb_ary_equal(ary1, ary2)
|
|||
long i;
|
||||
|
||||
if (ary1 == ary2) return Qtrue;
|
||||
if (TYPE(ary2) != T_ARRAY) return Qfalse;
|
||||
if (TYPE(ary2) != T_ARRAY) {
|
||||
if (!rb_respond_to(ary2, rb_intern("to_str"))) {
|
||||
return Qfalse;
|
||||
}
|
||||
return rb_equal(ary2, ary1);
|
||||
}
|
||||
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
|
||||
for (i=0; i<RARRAY(ary1)->len; i++) {
|
||||
if (!rb_equal(RARRAY(ary1)->ptr[i], RARRAY(ary2)->ptr[i]))
|
||||
|
|
7
hash.c
7
hash.c
|
@ -866,7 +866,12 @@ rb_hash_equal(hash1, hash2)
|
|||
struct equal_data data;
|
||||
|
||||
if (hash1 == hash2) return Qtrue;
|
||||
if (TYPE(hash2) != T_HASH) return Qfalse;
|
||||
if (TYPE(hash2) != T_HASH) {
|
||||
if (!rb_respond_to(hash2, rb_intern("to_hash"))) {
|
||||
return Qfalse;
|
||||
}
|
||||
return rb_equal(hash2, hash1);
|
||||
}
|
||||
if (RHASH(hash1)->tbl->num_entries != RHASH(hash2)->tbl->num_entries)
|
||||
return Qfalse;
|
||||
if (!(rb_equal(RHASH(hash1)->ifnone, RHASH(hash2)->ifnone) &&
|
||||
|
|
7
io.c
7
io.c
|
@ -3037,9 +3037,10 @@ argf_getline(argc, argv)
|
|||
next_p = 1;
|
||||
goto retry;
|
||||
}
|
||||
gets_lineno++;
|
||||
lineno = INT2FIX(gets_lineno);
|
||||
|
||||
if (!NIL_P(line)) {
|
||||
gets_lineno++;
|
||||
lineno = INT2FIX(gets_lineno);
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ list.rb stupid object sample
|
|||
list2.rb stupid object sample
|
||||
list3.rb stupid object sample
|
||||
mine.rb simple mine sweeper
|
||||
mkproto.rb extract protptype from C
|
||||
mkproto.rb extract prototype from C
|
||||
mpart.rb split file int multi part
|
||||
mrshtest.rb test marshal
|
||||
observ.rb observer design pattern sample
|
||||
|
|
7
string.c
7
string.c
|
@ -773,7 +773,12 @@ rb_str_equal(str1, str2)
|
|||
VALUE str1, str2;
|
||||
{
|
||||
if (str1 == str2) return Qtrue;
|
||||
if (TYPE(str2) != T_STRING) return Qfalse;
|
||||
if (TYPE(str2) != T_STRING) {
|
||||
if (!rb_respond_to(str2, rb_intern("to_str"))) {
|
||||
return Qfalse;
|
||||
}
|
||||
return rb_equal(str2, str1);
|
||||
}
|
||||
if (RSTRING(str1)->len == RSTRING(str2)->len &&
|
||||
rb_str_cmp(str1, str2) == 0) {
|
||||
return Qtrue;
|
||||
|
|
Загрузка…
Ссылка в новой задаче