ruby-changes:17478
From: naruse <ko1@a...>
Date: Wed, 13 Oct 2010 21:13:58 +0900 (JST)
Subject: [ruby-changes:17478] Ruby:r29483 (trunk): * numeric.c (int_chr): raise error when the value is negative.
naruse 2010-10-13 21:13:53 +0900 (Wed, 13 Oct 2010) New Revision: 29483 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29483 Log: * numeric.c (int_chr): raise error when the value is negative. Modified files: trunk/ChangeLog trunk/numeric.c Index: ChangeLog =================================================================== --- ChangeLog (revision 29482) +++ ChangeLog (revision 29483) @@ -1,3 +1,7 @@ +Wed Oct 13 21:13:00 2010 NARUSE, Yui <naruse@r...> + + * numeric.c (int_chr): raise error when the value is negative. + Wed Oct 13 19:24:08 2010 URABE Shyouhei <shyouhei@r...> * vm.c (ruby_vm_destruct): This function type was wrong; correct to the prototype. Index: numeric.c =================================================================== --- numeric.c (revision 29482) +++ numeric.c (revision 29483) @@ -2120,9 +2120,18 @@ int_chr(int argc, VALUE *argv, VALUE num) { char c; - unsigned int i = NUM2UINT(num); + unsigned int i; rb_encoding *enc; + if (rb_num_to_uint(num, &i) == 0) { + } + else if (FIXNUM_P(num)) { + rb_raise(rb_eRangeError, "%ld out of char range", FIX2LONG(num)); + } + else { + rb_raise(rb_eRangeError, "bignum out of char range"); + } + switch (argc) { case 0: if (0xff < i) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/