Project

General

Profile

bignum_objid.patch

h.shirosaki (Hiroshi Shirosaki), 12/24/2012 01:20 AM

View differences:

bignum.c
1710 1710
 *     68719476736.eql?(68719476736.0)   #=> false
1711 1711
 */
1712 1712

  
1713
static VALUE
1713
VALUE
1714 1714
rb_big_eql(VALUE x, VALUE y)
1715 1715
{
1716 1716
    if (!RB_TYPE_P(y, T_BIGNUM)) return Qfalse;
include/ruby/intern.h
124 124
double rb_big2dbl(VALUE);
125 125
VALUE rb_big_cmp(VALUE, VALUE);
126 126
VALUE rb_big_eq(VALUE, VALUE);
127
VALUE rb_big_eql(VALUE, VALUE);
127 128
VALUE rb_big_plus(VALUE, VALUE);
128 129
VALUE rb_big_minus(VALUE, VALUE);
129 130
VALUE rb_big_mul(VALUE, VALUE);
thread.c
4598 4598
}
4599 4599

  
4600 4600
/*
4601
 * Returns Qtrue iff obj_id (or the pair <obj, paired_obj>) is already
4601
 * Returns Qtrue if obj_id (or the pair <obj, paired_obj>) is already
4602 4602
 * in the recursion list.
4603 4603
 * Assumes the recursion list is valid.
4604 4604
 */
......
4606 4606
static VALUE
4607 4607
recursive_check(VALUE list, VALUE obj_id, VALUE paired_obj_id)
4608 4608
{
4609
#if SIZEOF_LONG == SIZEOF_VOIDP
4610
  #define OBJ_ID_EQL(obj_id, other) ((obj_id) == (other))
4611
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
4612
  #define OBJ_ID_EQL(obj_id, other) (RB_TYPE_P((obj_id), T_BIGNUM) ? \
4613
    rb_big_eql((obj_id), (other)) : ((obj_id) == (other)))
4614
#endif
4615

  
4609 4616
    VALUE pair_list = rb_hash_lookup2(list, obj_id, Qundef);
4610 4617
    if (pair_list == Qundef)
4611 4618
	return Qfalse;
4612 4619
    if (paired_obj_id) {
4613 4620
	if (!RB_TYPE_P(pair_list, T_HASH)) {
4614
	if (pair_list != paired_obj_id)
4615
	    return Qfalse;
4621
	    if (!OBJ_ID_EQL(paired_obj_id, pair_list))
4622
		return Qfalse;
4616 4623
	}
4617 4624
	else {
4618
	if (NIL_P(rb_hash_lookup(pair_list, paired_obj_id)))
4619
	    return Qfalse;
4625
	    if (NIL_P(rb_hash_lookup(pair_list, paired_obj_id)))
4626
		return Qfalse;
4620 4627
	}
4621 4628
    }
4622 4629
    return Qtrue;