* bignum.c (bignorm): sizeof(long) may be smaller than

sizeof(VALUE).  [ruby-dev:29013]

* ruby.h (FIXNUM_MAX): fixnum may be bigger than long.

* ruby.h (SIGNED_VALUE): signed integer of size of VALUE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2006-07-11 05:00:02 +00:00
parent fd66442a1d
commit 4bacdc1e46
8 changed files with 63 additions and 22 deletions

View File

@ -1,3 +1,21 @@
Tue Jul 11 13:40:52 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* bignum.c (bignorm): sizeof(long) may be smaller than
sizeof(VALUE). [ruby-dev:29013]
* ruby.h (FIXNUM_MAX): fixnum may be bigger than long.
* ruby.h (SIGNED_VALUE): signed integer of size of VALUE.
Mon Jul 10 23:37:14 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/soap/rpc/proxy.rb (Proxy::Operation::response_doc): remove
splat star from return statements.
* lib/soap/rpc/proxy.rb (Proxy::Operation::response_obj): retrieve
the first value from the result array if response has only one
value.
Mon Jul 10 19:22:19 2006 Tanaka Akira <akr@fsij.org> Mon Jul 10 19:22:19 2006 Tanaka Akira <akr@fsij.org>
* gc.c (gc_sweep): expand heap earlier. * gc.c (gc_sweep): expand heap earlier.

View File

@ -103,7 +103,7 @@ bignorm(VALUE x)
RBIGNUM(x)->len = ++len; RBIGNUM(x)->len = ++len;
if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) { if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) {
long num = 0; SIGNED_VALUE num = 0;
while (len--) { while (len--) {
num = BIGUP(num) + ds[len]; num = BIGUP(num) + ds[len];
} }
@ -125,7 +125,7 @@ rb_big_norm(VALUE x)
} }
VALUE VALUE
rb_uint2big(unsigned long n) rb_uint2big(VALUE n)
{ {
BDIGIT_DBL num = n; BDIGIT_DBL num = n;
long i = 0; long i = 0;
@ -146,7 +146,7 @@ rb_uint2big(unsigned long n)
} }
VALUE VALUE
rb_int2big(long n) rb_int2big(SIGNED_VALUE n)
{ {
long neg = 0; long neg = 0;
VALUE big; VALUE big;
@ -163,14 +163,14 @@ rb_int2big(long n)
} }
VALUE VALUE
rb_uint2inum(unsigned long n) rb_uint2inum(VALUE n)
{ {
if (POSFIXABLE(n)) return LONG2FIX(n); if (POSFIXABLE(n)) return LONG2FIX(n);
return rb_uint2big(n); return rb_uint2big(n);
} }
VALUE VALUE
rb_int2inum(long n) rb_int2inum(SIGNED_VALUE n)
{ {
if (FIXABLE(n)) return LONG2FIX(n); if (FIXABLE(n)) return LONG2FIX(n);
return rb_int2big(n); return rb_int2big(n);
@ -1236,7 +1236,7 @@ bigdivrem(VALUE x, VALUE y, VALUE *divp, VALUE *modp)
} }
RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign; RBIGNUM(z)->sign = RBIGNUM(x)->sign==RBIGNUM(y)->sign;
if (modp) { if (modp) {
*modp = rb_uint2big((unsigned long)t2); *modp = rb_uint2big((VALUE)t2);
RBIGNUM(*modp)->sign = RBIGNUM(x)->sign; RBIGNUM(*modp)->sign = RBIGNUM(x)->sign;
} }
if (divp) *divp = z; if (divp) *divp = z;

View File

@ -2496,14 +2496,25 @@ VpAlloc(U_LONG mx, const char *szVal)
return vp; return vp;
} }
/* Skip all spaces */ /* Skip all '_' after digit: 2006-6-30 */
ni = 0;
psz = ALLOCA_N(char,strlen(szVal)+1); psz = ALLOCA_N(char,strlen(szVal)+1);
i = 0; i = 0;
ipn = 0; ipn = 0;
while(psz[i]=szVal[ipn]) { while(psz[i]=szVal[ipn]) {
if(ISSPACE(szVal[ipn])) {ipn++;continue;} if(ISDIGIT(psz[i])) ++ni;
if(psz[i]=='_') {
if(ni>0) {ipn++;continue;}
psz[i]=0;
break;
}
++i; ++ipn; ++i; ++ipn;
} }
/* Skip trailing spaces */
while((--i)>0) {
if(ISSPACE(psz[i])) psz[i] = 0;
else break;
}
szVal = psz; szVal = psz;
/* Check on Inf & NaN */ /* Check on Inf & NaN */

View File

@ -46,11 +46,10 @@ class BigDecimal < Numeric
numerator = sign*digits.to_i numerator = sign*digits.to_i
denomi_power = power - digits.size # base is always 10 denomi_power = power - digits.size # base is always 10
if denomi_power < 0 if denomi_power < 0
denominator = base ** (-denomi_power) Rational(numerator,base ** (-denomi_power))
else else
denominator = base ** denomi_power Rational(numerator * (base ** denomi_power),1)
end end
Rational(numerator,denominator)
end end
end end

View File

@ -142,7 +142,7 @@ class PP < PrettyPrint
# Object#pretty_print_cycle is used when +obj+ is already # Object#pretty_print_cycle is used when +obj+ is already
# printed, a.k.a the object reference chain has a cycle. # printed, a.k.a the object reference chain has a cycle.
def pp(obj) def pp(obj)
id = obj.__id__ id = obj.object_id
if check_inspect_key(id) if check_inspect_key(id)
group {obj.pretty_print_cycle self} group {obj.pretty_print_cycle self}
@ -180,7 +180,7 @@ class PP < PrettyPrint
end end
def object_address_group(obj, &block) def object_address_group(obj, &block)
id = PointerFormat % (obj.__id__ * 2 & PointerMask) id = PointerFormat % (obj.object_id * 2 & PointerMask)
group(1, "\#<#{obj.class}:0x#{id}", '>', &block) group(1, "\#<#{obj.class}:0x#{id}", '>', &block)
end end

View File

@ -788,7 +788,7 @@ public
if ele.is_a?(Array) if ele.is_a?(Array)
deep_map(ele, &block) deep_map(ele, &block)
else else
new_obj = block.call(ele) new_obj = yield(ele)
new_obj.elename = ITEM_NAME new_obj.elename = ITEM_NAME
new_obj new_obj
end end

View File

@ -345,7 +345,12 @@ private
if @response_style == :rpc if @response_style == :rpc
response_rpc(body, mapping_registry, literal_mapping_registry, opt) response_rpc(body, mapping_registry, literal_mapping_registry, opt)
else else
response_doc(body, mapping_registry, literal_mapping_registry, opt) ret = response_doc(body, mapping_registry, literal_mapping_registry, opt)
if ret.size == 1
ret[0]
else
ret
end
end end
end end
@ -439,9 +444,9 @@ private
def response_doc(body, mapping_registry, literal_mapping_registry, opt) def response_doc(body, mapping_registry, literal_mapping_registry, opt)
if @response_use == :encoded if @response_use == :encoded
return *response_doc_enc(body, mapping_registry, opt) return response_doc_enc(body, mapping_registry, opt)
else else
return *response_doc_lit(body, literal_mapping_registry, opt) return response_doc_lit(body, literal_mapping_registry, opt)
end end
end end

18
ruby.h
View File

@ -93,9 +93,12 @@ extern "C" {
#if SIZEOF_LONG == SIZEOF_VOIDP #if SIZEOF_LONG == SIZEOF_VOIDP
typedef unsigned long VALUE; typedef unsigned long VALUE;
typedef unsigned long ID; typedef unsigned long ID;
# define SIGNED_VALUE long
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
typedef unsigned LONG_LONG VALUE; typedef unsigned LONG_LONG VALUE;
typedef unsigned LONG_LONG ID; typedef unsigned LONG_LONG ID;
# define SIGNED_VALUE LONG_LONG
# define LONG_LONG_VALUE 1
#else #else
# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<---- # error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
#endif #endif
@ -145,18 +148,23 @@ typedef unsigned LONG_LONG ID;
# endif # endif
#endif #endif
#define FIXNUM_MAX (LONG_MAX>>1) #if LONG_LONG_VALUE
#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1) # define FIXNUM_MAX (LLONG_MAX>>1)
# define FIXNUM_MIN RSHIFT((LONG_LONG)LLONG_MIN,1)
#else
# define FIXNUM_MAX (LONG_MAX>>1)
# define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
#endif
#define FIXNUM_FLAG 0x01 #define FIXNUM_FLAG 0x01
#define INT2FIX(i) ((VALUE)(((long)(i))<<1 | FIXNUM_FLAG)) #define INT2FIX(i) ((VALUE)(((SIGNED_VALUE)(i))<<1 | FIXNUM_FLAG))
#define LONG2FIX(i) INT2FIX(i) #define LONG2FIX(i) INT2FIX(i)
#define rb_fix_new(v) INT2FIX(v) #define rb_fix_new(v) INT2FIX(v)
VALUE rb_int2inum(long); VALUE rb_int2inum(SIGNED_VALUE);
#define INT2NUM(v) rb_int2inum(v) #define INT2NUM(v) rb_int2inum(v)
#define LONG2NUM(v) INT2NUM(v) #define LONG2NUM(v) INT2NUM(v)
#define rb_int_new(v) rb_int2inum(v) #define rb_int_new(v) rb_int2inum(v)
VALUE rb_uint2inum(unsigned long); VALUE rb_uint2inum(VALUE);
#define UINT2NUM(v) rb_uint2inum(v) #define UINT2NUM(v) rb_uint2inum(v)
#define ULONG2NUM(v) UINT2NUM(v) #define ULONG2NUM(v) UINT2NUM(v)
#define rb_uint_new(v) rb_uint2inum(v) #define rb_uint_new(v) rb_uint2inum(v)