ruby-changes:17487
From: nobu <ko1@a...>
Date: Thu, 14 Oct 2010 07:22:28 +0900 (JST)
Subject: [ruby-changes:17487] Ruby:r29492 (trunk): * array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy),
nobu 2010-10-14 07:22:18 +0900 (Thu, 14 Oct 2010) New Revision: 29492 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29492 Log: * array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy), gc.c (undefine_final), time.c (time_mload): get rid of type-punning casts. Modified files: trunk/ChangeLog trunk/array.c trunk/class.c trunk/gc.c trunk/time.c Index: array.c =================================================================== --- array.c (revision 29491) +++ array.c (revision 29492) @@ -3341,7 +3341,8 @@ static VALUE rb_ary_and(VALUE ary1, VALUE ary2) { - VALUE hash, ary3, v, vv; + VALUE hash, ary3, v; + st_data_t vv; long i; ary2 = to_ary(ary2); @@ -3353,8 +3354,8 @@ return ary3; for (i=0; i<RARRAY_LEN(ary1); i++) { - v = vv = rb_ary_elt(ary1, i); - if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) { + vv = (st_data_t)(v = rb_ary_elt(ary1, i)); + if (st_delete(RHASH_TBL(hash), &vv, 0)) { rb_ary_push(ary3, v); } } @@ -3377,8 +3378,8 @@ static VALUE rb_ary_or(VALUE ary1, VALUE ary2) { - VALUE hash, ary3; - VALUE v, vv; + VALUE hash, ary3, v; + st_data_t vv; long i; ary2 = to_ary(ary2); @@ -3386,14 +3387,14 @@ hash = ary_add_hash(ary_make_hash(ary1), ary2); for (i=0; i<RARRAY_LEN(ary1); i++) { - v = vv = rb_ary_elt(ary1, i); - if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) { + vv = (st_data_t)(v = rb_ary_elt(ary1, i)); + if (st_delete(RHASH_TBL(hash), &vv, 0)) { rb_ary_push(ary3, v); } } for (i=0; i<RARRAY_LEN(ary2); i++) { - v = vv = rb_ary_elt(ary2, i); - if (st_delete(RHASH_TBL(hash), (st_data_t*)&vv, 0)) { + vv = (st_data_t)(v = rb_ary_elt(ary2, i)); + if (st_delete(RHASH_TBL(hash), &vv, 0)) { rb_ary_push(ary3, v); } } Index: time.c =================================================================== --- time.c (revision 29491) +++ time.c (revision 29492) @@ -4683,26 +4683,24 @@ long nsec; VALUE submicro, nano_num, nano_den, offset; wideval_t timew; + st_data_t data; time_modify(time); - nano_num = rb_attr_get(str, id_nano_num); - if (nano_num != Qnil) { - st_delete(rb_generic_ivar_table(str), (st_data_t*)&id_nano_num, 0); +#define get_attr(attr, iffound) \ + attr = rb_attr_get(str, id_##attr); \ + if (!NIL_P(attr)) { \ + data = id_##attr; \ + iffound; \ + st_delete(rb_generic_ivar_table(str), &data, 0); \ } - nano_den = rb_attr_get(str, id_nano_den); - if (nano_den != Qnil) { - st_delete(rb_generic_ivar_table(str), (st_data_t*)&id_nano_den, 0); - } - submicro = rb_attr_get(str, id_submicro); - if (submicro != Qnil) { - st_delete(rb_generic_ivar_table(str), (st_data_t*)&id_submicro, 0); - } - offset = rb_attr_get(str, id_offset); - if (offset != Qnil) { - validate_utc_offset(offset); - st_delete(rb_generic_ivar_table(str), (st_data_t*)&id_offset, 0); - } + + get_attr(nano_num, {}); + get_attr(nano_den, {}); + get_attr(submicro, {}); + get_attr(offset, validate_utc_offset(offset)); +#undef get_attr + rb_copy_generic_ivar(time, str); StringValue(str); Index: ChangeLog =================================================================== --- ChangeLog (revision 29491) +++ ChangeLog (revision 29492) @@ -1,3 +1,9 @@ +Thu Oct 14 07:22:12 2010 Nobuyoshi Nakada <nobu@r...> + + * array.c (rb_ary_and, rb_ary_or), class.c (rb_mod_init_copy), + gc.c (undefine_final), time.c (time_mload): get rid of + type-punning casts. + Thu Oct 14 04:16:41 2010 NARUSE, Yui <naruse@r...> * numeric.c (ruby_float_step): fix Numeric#step with infinity unit Index: gc.c =================================================================== --- gc.c (revision 29491) +++ gc.c (revision 29492) @@ -2679,7 +2679,8 @@ rb_objspace_t *objspace = &rb_objspace; if (OBJ_FROZEN(obj)) rb_error_frozen("object"); if (finalizer_table) { - st_delete(finalizer_table, (st_data_t*)&obj, 0); + st_data_t data = obj; + st_delete(finalizer_table, &data, 0); } FL_UNSET(obj, FL_FINALIZE); return obj; Index: class.c =================================================================== --- class.c (revision 29491) +++ class.c (revision 29492) @@ -150,16 +150,16 @@ } RCLASS_SUPER(clone) = RCLASS_SUPER(orig); if (RCLASS_IV_TBL(orig)) { - ID id; + st_data_t id; if (RCLASS_IV_TBL(clone)) { st_free_table(RCLASS_IV_TBL(clone)); } RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(orig)); CONST_ID(id, "__classpath__"); - st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0); + st_delete(RCLASS_IV_TBL(clone), &id, 0); CONST_ID(id, "__classid__"); - st_delete(RCLASS_IV_TBL(clone), (st_data_t*)&id, 0); + st_delete(RCLASS_IV_TBL(clone), &id, 0); } if (RCLASS_M_TBL(orig)) { struct clone_method_data data; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/