summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--eval.c2
-rw-r--r--intern.h1
-rw-r--r--object.c20
-rw-r--r--string.c6
5 files changed, 31 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f6b296390e..c269549f31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/eval.c b/eval.c
index 0277f54879..18abc8a6de 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/intern.h b/intern.h
index cdd56ba4ef..0780524a5b 100644
--- a/intern.h
+++ b/intern.h
@@ -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));
diff --git a/object.c b/object.c
index 73ae3d4e2c..4020f54d03 100644
--- a/object.c
+++ b/object.c
@@ -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;
diff --git a/string.c b/string.c
index 1e55148f47..f1dd8b3b35 100644
--- a/string.c
+++ b/string.c
@@ -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) {