summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-04 08:52:51 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-04 08:52:51 +0000
commit75d3a3d0dfac771054346519c588112b43a6f4bc (patch)
tree86f087873a41fd8c3a228278c1fc83643883aefb /numeric.c
parent3c6df5c0375974cce16e396d6145389877bbd037 (diff)
* numeric.c (check_uint, rb_num2uint, rb_fix2uint): proper check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/numeric.c b/numeric.c
index 07b5ae6..83f1d3c 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1585,10 +1585,10 @@ check_int(SIGNED_VALUE num)
}
static void
-check_uint(VALUE num, int sign)
+check_uint(VALUE num)
{
if (num > UINT_MAX) {
- rb_raise(rb_eRangeError, "integer %"PRIuVALUE " too %s to convert to `unsigned int'", num, sign ? "small" : "big");
+ rb_raise(rb_eRangeError, "integer %"PRIuVALUE " too big to convert to `unsigned int'", num);
}
}
@@ -1615,7 +1615,10 @@ rb_num2uint(VALUE val)
{
unsigned long num = rb_num2ulong(val);
- check_uint(num, RTEST(rb_funcall(val, '<', 1, INT2FIX(0))));
+ if (RTEST(rb_funcall(val, '<', 1, INT2FIX(0))))
+ check_int(num);
+ else
+ check_uint(num);
return num;
}
@@ -1628,7 +1631,10 @@ rb_fix2uint(VALUE val)
return rb_num2uint(val);
}
num = FIX2ULONG(val);
- check_uint(num, RTEST(rb_funcall(val, '<', 1, INT2FIX(0))));
+ if (RTEST(rb_funcall(val, '<', 1, INT2FIX(0))))
+ check_int(num);
+ else
+ check_uint(num);
return num;
}
#else