diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | intern.h | 1 | ||||
-rw-r--r-- | object.c | 20 | ||||
-rw-r--r-- | string.c | 6 |
5 files changed, 31 insertions, 3 deletions
@@ -4,6 +4,11 @@ Fri Nov 30 00:25:28 2001 Usaku Nakamura <usa@ruby-lang.org> * README.EXT.ja: ditto. +Thu Nov 29 00:28:07 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * string.c (rb_str_equal): object with to_str must be treated as a + string. + Wed Nov 28 18:46:28 2001 Ville Mattila <mulperi@iki.fi> * eval.c (rb_thread_select): should subtract timeofday() from @@ -7680,7 +7680,7 @@ rb_thread_schedule() if (select_timeout && n == 0) { if (now < 0.0) now = timeofday(); FOREACH_THREAD_FROM(curr, th) { - if ((th->wait_for & (WAIT_SELECT|WAIT_TIME)) && th->delay < now) { + if ((th->wait_for & (WAIT_SELECT|WAIT_TIME)) && th->delay <= now) { th->status = THREAD_RUNNABLE; th->wait_for = 0; th->select_value = 0; @@ -251,6 +251,7 @@ VALUE rb_obj_id _((VALUE)); VALUE rb_obj_class _((VALUE)); VALUE rb_class_real _((VALUE)); VALUE rb_convert_type _((VALUE,int,const char*,const char*)); +VALUE rb_check_convert_type _((VALUE,int,const char*,const char*)); VALUE rb_to_int _((VALUE)); VALUE rb_Integer _((VALUE)); VALUE rb_Float _((VALUE)); @@ -876,6 +876,26 @@ rb_convert_type(val, type, tname, method) return val; } +VALUE +rb_check_convert_type(val, type, tname, method) + VALUE val; + int type; + const char *tname, *method; +{ + struct arg_to arg1, arg2; + + if (TYPE(val) == type) return val; + arg1.val = arg2.val = val; + arg1.s = method; + arg2.s = tname; + val = rb_rescue(to_type, (VALUE)&arg1, 0, 0); + if (!NIL_P(val) && TYPE(val) != type) { + rb_raise(rb_eTypeError, "%s#%s should return %s", + rb_class2name(CLASS_OF(arg1.val)), method, tname); + } + return val; +} + static VALUE rb_to_integer(val, method) VALUE val; @@ -722,8 +722,10 @@ 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) { + str2 = rb_check_convert_type(str2, T_STRING, "String", "to_str"); + if (NIL_P(str2)) return Qfalse; + } if (RSTRING(str1)->len == RSTRING(str2)->len && rb_str_cmp(str1, str2) == 0) { |