summaryrefslogtreecommitdiff
path: root/string.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
commit23303b8a63df927cd81b9947dd48e1b416e2a39c (patch)
treedd7c8c1a9bb43c226ca5e1702b418f11a94ffd3e /string.c
parent080aa35bbaa08513e47ef4e7952da5fb4cc0b685 (diff)
* 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
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/string.c b/string.c
index 1e55148..f1dd8b3 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) {