* 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
parent 5c9d3fac30
commit f92f8b565f
3 changed files with 17 additions and 1 deletions

View File

@ -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> Tue Apr 8 11:49:31 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (Init_Proc): make Method and UnboundMethod independent. * 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. * 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> Sat Apr 5 01:41:28 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (backtrace): skip internal allocator frame. * eval.c (backtrace): skip internal allocator frame.

View File

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

View File

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