diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-24 09:33:30 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-24 09:33:30 +0000 |
commit | 9ce253a2cfc26cc7a0d2cfeeaf15d6216d522077 (patch) | |
tree | 6f6334590a5705de7f7288d3eb8e572bfe75453f /object.c | |
parent | 8581fa1549787fc64e0d8a198838fe47104726c1 (diff) |
gtk/nested local variables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -794,10 +794,32 @@ num2dbl(val) } static VALUE +to_s(obj) + VALUE obj; +{ + return rb_funcall(obj, rb_intern("to_s"), 0); +} + +static VALUE +fail_to_str(val) + VALUE val; +{ + TypeError("failed to convert %s into Sting", + rb_class2name(CLASS_OF(val))); +} + +static VALUE f_string(obj, arg) VALUE obj, arg; { - return rb_funcall(arg, rb_intern("to_s"), 0); + return rb_rescue(to_s, arg, fail_to_str, arg); +} + +static VALUE +to_str(obj) + VALUE obj; +{ + return rb_funcall(obj, rb_intern("to_str"), 0); } char* @@ -805,7 +827,10 @@ str2cstr(str) VALUE str; { if (NIL_P(str)) return NULL; - Check_Type(str, T_STRING); + if (TYPE(str) != T_STRING) { + str = rb_rescue(to_str, str, fail_to_str, str); + Check_Type(str, T_STRING); + } return RSTRING(str)->ptr; } |