* random.c (rb_f_rand): normalize bignum argument.

* sprintf.c (rb_f_sprintf): was decrementing width even if there
  is no sign character.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-04-08 09:02:04 +00:00
Родитель 5c9d3fac30
Коммит f92f8b565f
3 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Tue Apr 8 17:13:53 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* random.c (rb_f_rand): normalize bignum argument.
Tue Apr 8 11:49:31 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (Init_Proc): make Method and UnboundMethod independent.
@ -34,6 +38,11 @@ Sat Apr 5 23:41:28 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): small but serious typo.
Sat Apr 5 04:23:05 2003 Warren Brown <wkb@airmail.net>
* sprintf.c (rb_f_sprintf): was decrementing width even if there
is no sign character.
Sat Apr 5 01:41:28 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (backtrace): skip internal allocator frame.

Просмотреть файл

@ -215,6 +215,11 @@ rb_f_rand(argc, argv, obj)
vmax = rb_dbl2big(RFLOAT(vmax)->value);
/* fall through */
case T_BIGNUM:
vmax = rb_big_norm(vmax);
if (FIXNUM_P(vmax)) {
max = FIX2INT(vmax);
break;
}
bignum:
{
long len = RBIGNUM(vmax)->len;

Просмотреть файл

@ -475,14 +475,16 @@ rb_f_sprintf(argc, argv)
if (s[0] == '-') {
s++;
sc = '-';
width--;
}
else if (flags & FPLUS) {
sc = '+';
width--;
}
else if (flags & FSPACE) {
sc = ' ';
width--;
}
width--;
goto format_integer;
}
if (!RBIGNUM(val)->sign) {