зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
3c6df5c037
Коммит
75d3a3d0df
|
@ -1,3 +1,7 @@
|
|||
Fri Jul 4 17:51:07 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* numeric.c (check_uint, rb_num2uint, rb_fix2uint): proper check.
|
||||
|
||||
Fri Jul 4 14:17:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/net/ftp.rb (Net::FTP#sendport): use divmod. [ruby-core:17557]
|
||||
|
|
14
numeric.c
14
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче