1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-10-13 22:22:18 +00:00
parent 421076be67
commit 7735e63593
5 changed files with 35 additions and 29 deletions

View file

@ -1,3 +1,9 @@
Thu Oct 14 07:22:12 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@ruby-lang.org>
* numeric.c (ruby_float_step): fix Numeric#step with infinity unit

19
array.c
View file

@ -3341,7 +3341,8 @@ rb_ary_diff(VALUE ary1, VALUE ary2)
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 @@ rb_ary_and(VALUE ary1, VALUE ary2)
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 @@ rb_ary_and(VALUE ary1, VALUE ary2)
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 @@ rb_ary_or(VALUE ary1, VALUE ary2)
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);
}
}

View file

@ -150,16 +150,16 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
}
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;

3
gc.c
View file

@ -2679,7 +2679,8 @@ undefine_final(VALUE os, VALUE obj)
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;

30
time.c
View file

@ -4683,26 +4683,24 @@ time_mload(VALUE time, VALUE str)
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);
}
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);
#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); \
}
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);