From: Tanaka Akira Date: 2010-08-20T09:53:00+09:00 Subject: [ruby-core:31784] Re: [Bug #3721] Unsigned formats broken in 1.9.2's unpack 2010/8/20 Daniel Gutmanas : > Bug #3721: Unsigned formats broken in 1.9.2's unpack > http://redmine.ruby-lang.org/issues/show/3721 > > Author: Daniel Gutmanas > Status: Open, Priority: Normal > ruby -v: ruby 1.9.2p0 (2010-08-18 revision 29036) [x64-mswin64_100] > > When specifying the V format code, unpack should treat the four bytes as an unsigned long integer. As can be seen in the following example, it treats it as a signed integer instead: > "\xFF\xFF\xFF\xFF".unpack(?V) => [-1] > The same code worked properly in 1.9.1. It seems a problem on LLP64 environments. How about this patch? Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 29051) +++ include/ruby/ruby.h (working copy) @@ -952,7 +952,7 @@ struct RBignum { #define OBJ_FROZEN(x) (!!FL_TEST((x), FL_FREEZE)) #define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE) -#if SIZEOF_INT < SIZEOF_VALUE +#if SIZEOF_INT < SIZEOF_LONG # define INT2NUM(v) INT2FIX((int)(v)) # define UINT2NUM(v) LONG2FIX((unsigned int)(v)) #else -- Tanaka Akira