diff options
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -11,7 +11,7 @@ **********************************************************************/ -#include "ruby/config.h" +#include "ruby/3/config.h" #include <errno.h> @@ -150,10 +150,12 @@ rb_hash(VALUE obj) unsigned long ul; sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0, INTEGER_PACK_NATIVE_BYTE_ORDER); - ul &= (1UL << (sizeof(long)*CHAR_BIT-1)) - 1; - if (sign < 0) - return LONG2FIX(-(long)ul); - return LONG2FIX((long)ul); + if (sign < 0) { + hval = LONG2FIX(ul | FIXNUM_MIN); + } + else { + hval = LONG2FIX(ul & FIXNUM_MAX); + } } hval = rb_to_int(hval); } |