summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/string.c b/string.c
index c6379bbf5b..f2ee280a75 100644
--- a/string.c
+++ b/string.c
@@ -2385,9 +2385,9 @@ rb_str_cmp_m(VALUE str1, VALUE str2)
int result;
if (!RB_TYPE_P(str2, T_STRING)) {
- VALUE tmp;
- if (!rb_respond_to(str2, rb_intern("to_str"))) {
- return Qnil;
+ VALUE tmp = rb_check_funcall(str2, rb_intern("to_str"), 0, 0);
+ if (RB_TYPE_P(tmp, T_STRING)) {
+ result = rb_str_cmp(str1, tmp);
}
else if ((tmp = rb_check_funcall(str2, rb_intern("<=>"), 1, &str1)) ==
Qundef) {