summaryrefslogtreecommitdiff
path: root/compar.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-08 03:56:12 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-08 03:56:12 (GMT)
commit698a24674eb0707fdc8d934084932e845db955cd (patch)
tree14332a4426614ee3b43f69a5c51a1117ec8d1ab2 /compar.c
parent908300d44f0d072d4ef2e6813794aa9170b9f618 (diff)
* compar.c (rb_cmperr): raise comparison failure.
* intern.h: prototype; rb_cmperr * numeric.c (flo_gt, flo_ge, flo_lt, flo_le, fix_gt, fix_ge, fix_lt, fix_le): should fail unless the argument is comparable. (ruby-bugs-ja:PR#456) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compar.c')
-rw-r--r--compar.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/compar.c b/compar.c
index 0a5a10e..bb90125 100644
--- a/compar.c
+++ b/compar.c
@@ -30,13 +30,25 @@ rb_cmpint(val)
return 0;
}
-static VALUE
-cmperr()
+void
+rb_cmperr(x, y)
+ VALUE x, y;
{
- rb_raise(rb_eArgError, "comparison failed");
- return Qnil; /* not reached */
+ const char *classname;
+
+ if (SPECIAL_CONST_P(y)) {
+ y = rb_inspect(y);
+ classname = StringValuePtr(y);
+ }
+ else {
+ classname = rb_obj_classname(y);
+ }
+ rb_raise(rb_eArgError, "comparison of %s to %s failed",
+ rb_obj_classname(x), classname);
}
+#define cmperr() (rb_cmperr(x, y), Qnil)
+
static VALUE
cmp_equal(x, y)
VALUE x, y;