diff --git a/History.txt b/History.txt index 31fc2c2..2e3aa50 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,9 @@ += 1.2.0 / 2010-10-02 + * Minor Changes + * OTP-8540 (http://erlang.org/download/otp_src_R14B.readme): + "External format of integers changed to make full use of + all 32 bits of INTEGER_EXT" + = 1.1.2 / 2010-02-08 * Bug fixes * Fix bignum handling on 256 byte boundary diff --git a/VERSION b/VERSION index 45a1b3f..26aaba0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.2 +1.2.0 diff --git a/ext/bert/c/decode.c b/ext/bert/c/decode.c index af9475e..73f3fe3 100644 --- a/ext/bert/c/decode.c +++ b/ext/bert/c/decode.c @@ -14,6 +14,8 @@ #define ERL_STRING 107 #define ERL_LIST 108 #define ERL_BIN 109 +#define RB_MAX_FIXNUM (1 << 30) - 1 +#define RB_MIN_FIXNUM -(1 << 30) static VALUE mBERT; static VALUE cDecode; @@ -287,7 +289,10 @@ VALUE read_int(unsigned char **pData) { value = (value - ((long long) 1 << 32)); } - return INT2FIX(value); + if(value < RB_MIN_FIXNUM || value > RB_MAX_FIXNUM) + return INT2NUM(value); + else + return INT2FIX(value); } VALUE read_small_bignum(unsigned char **pData) { diff --git a/lib/bert/decode.rb b/lib/bert/decode.rb index 2e71cf3..8f6e2f2 100644 --- a/lib/bert/decode.rb +++ b/lib/bert/decode.rb @@ -113,7 +113,11 @@ def read_int value = read_4 negative = (value >> 31)[0] == 1 value = (value - (1 << 32)) if negative - value = Fixnum.induced_from(value) + if value < RB_MIN_FIXNUM or value > RB_MAX_FIXNUM + value = Bignum.induced_from(value) + else + value = Fixnum.induced_from(value) + end end def read_small_bignum diff --git a/lib/bert/types.rb b/lib/bert/types.rb index 09bcd00..828b4d6 100644 --- a/lib/bert/types.rb +++ b/lib/bert/types.rb @@ -15,7 +15,9 @@ module Types FUN = 117 NEW_FUN = 112 MAGIC = 131 - MAX_INT = (1 << 27) -1 - MIN_INT = -(1 << 27) + MAX_INT = (1 << 31) - 1 + MIN_INT = -(1 << 31) + RB_MAX_FIXNUM = (1 << 30) - 1 + RB_MIN_FIXNUM = -(1 << 30) end end \ No newline at end of file