mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
908300d44f
commit
698a24674e
4 changed files with 55 additions and 40 deletions
20
compar.c
20
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue