From d300a4a2fb3eeaa5fad17adfc0407a885c9152ba Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 29 Nov 2001 15:57:25 +0000 Subject: * string.c (rb_str_equal): object with to_str must be treated as a string. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- object.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'object.c') diff --git a/object.c b/object.c index 73ae3d4e2..4020f54d0 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; -- cgit