summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-03 17:38:41 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-07-03 17:38:41 +0000
commit654a54a6645d344bcdc0399fb3384d60215754f8 (patch)
tree2dd2ecf1486697be267c660194b85c6a98fbaef0 /numeric.c
parent3946e41bfe4ba4d650de03a358fbcc20ea24de42 (diff)
* numeric.c (check_uint, rb_num2uint): also needs checking negative
value. see [ruby-dev:33683] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/numeric.c b/numeric.c
index b7b60982a7..03f4afb356 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1600,11 +1600,12 @@ check_int(num)
}
static void
-check_uint(num)
+check_uint(num, sign)
unsigned long num;
+ int sign;
{
if (num > UINT_MAX) {
- rb_raise(rb_eRangeError, "integer %lu too big to convert to `unsigned int'", num);
+ rb_raise(rb_eRangeError, "integer %lu too %s to convert to `unsigned int'", num, sign ? "small" : "big");
}
}
@@ -1634,9 +1635,7 @@ rb_num2uint(val)
{
unsigned long num = rb_num2ulong(val);
- if (RTEST(rb_funcall(INT2FIX(0), '<', 1, val))) {
- check_uint(num);
- }
+ check_uint(num, RTEST(rb_funcall(val, '<', 1, INT2FIX(0))));
return num;
}
@@ -1650,9 +1649,7 @@ rb_fix2uint(val)
return rb_num2uint(val);
}
num = FIX2ULONG(val);
- if (FIX2LONG(val) > 0) {
- check_uint(num);
- }
+ check_uint(num, RTEST(rb_funcall(val, '<', INT2FIX(0))));
return num;
}
#else