ruby-changes:17476
From: naruse <ko1@a...>
Date: Wed, 13 Oct 2010 15:04:48 +0900 (JST)
Subject: [ruby-changes:17476] Ruby:r29481 (trunk): * numeric.c (rb_num_to_uint): fix 32bit logic.
naruse 2010-10-13 14:58:35 +0900 (Wed, 13 Oct 2010) New Revision: 29481 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29481 Log: * numeric.c (rb_num_to_uint): fix 32bit logic. Modified files: trunk/ChangeLog trunk/numeric.c Index: ChangeLog =================================================================== --- ChangeLog (revision 29480) +++ ChangeLog (revision 29481) @@ -1,3 +1,7 @@ +Wed Oct 13 14:58:09 2010 NARUSE, Yui <naruse@r...> + + * numeric.c (rb_num_to_uint): fix 32bit logic. + Wed Oct 13 12:53:43 2010 NARUSE, Yui <naruse@r...> * numeric.c (rb_num_to_uint): added to check the range of arguments. Index: numeric.c =================================================================== --- numeric.c (revision 29480) +++ numeric.c (revision 29481) @@ -122,7 +122,9 @@ #define NUMERR_TOOLARGE 3 if (FIXNUM_P(val)) { long v = FIX2LONG(val); - if (v > UINT_MAX) return NUMERR_TOOLARGE; +#if SIZEOF_INT < SIZEOF_LONG + if (v > (long)UINT_MAX) return NUMERR_TOOLARGE; +#endif if (v < 0) return NUMERR_NEGATIVE; *ret = (unsigned int)v; return 0; @@ -136,7 +138,8 @@ return NUMERR_TOOLARGE; #else /* long is 32bit */ - if (RBIGNUM_LEN(x) > DIGSPERLONG) return NUMERR_TOOLARGE; +#define DIGSPERLONG (SIZEOF_LONG/SIZEOF_BDIGITS) + if (RBIGNUM_LEN(val) > DIGSPERLONG) return NUMERR_TOOLARGE; *ret = (unsigned int)rb_big2ulong((VALUE)val); return 0; #endif -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/