diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | array.c | 7 | ||||
-rw-r--r-- | hash.c | 7 | ||||
-rw-r--r-- | io.c | 7 | ||||
-rw-r--r-- | sample/README | 2 | ||||
-rw-r--r-- | string.c | 7 |
6 files changed, 38 insertions, 7 deletions
@@ -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 "==" @@ -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])) @@ -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) && @@ -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; } diff --git a/sample/README b/sample/README index 82db05eec9..53d16de335 100644 --- a/sample/README +++ b/sample/README @@ -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 @@ -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; |