1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_equal): object with to_str must be treated as a

string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-11-29 15:57:25 +00:00
parent 080aa35bba
commit 23303b8a63
5 changed files with 31 additions and 3 deletions

View file

@ -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

2
eval.c
View file

@ -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;

View file

@ -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));

View file

@ -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;

View file

@ -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) {