summaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-29 15:57:25 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-29 15:57:25 +0000
commitd300a4a2fb3eeaa5fad17adfc0407a885c9152ba (patch)
treedd7c8c1a9bb43c226ca5e1702b418f11a94ffd3e /object.c
parent8c1a41589c8cdd898b0da42cef09f9c68e0bcf1f (diff)
downloadruby-d300a4a2fb3eeaa5fad17adfc0407a885c9152ba.tar.gz
ruby-d300a4a2fb3eeaa5fad17adfc0407a885c9152ba.tar.xz
ruby-d300a4a2fb3eeaa5fad17adfc0407a885c9152ba.zip
* 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
Diffstat (limited to 'object.c')
-rw-r--r--object.c20
1 files changed, 20 insertions, 0 deletions
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;