diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-10 14:52:19 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-10 14:52:19 +0000 |
commit | a73d958c33904fdabac95f49d9834779ca33c599 (patch) | |
tree | 18cde65b79b9002421da9848fcf35e4324a8ea67 /ext | |
parent | efae6194582001cb12108bc101d22dc1ed9a660c (diff) | |
download | ruby-a73d958c33904fdabac95f49d9834779ca33c599.tar.gz |
* st.c: add st_foreach_check for fixing iteration over packed table
and st_delete_safe. patched by Sokolov Yura at
https://github.com/ruby/ruby/pull/84
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/-test-/st/numhash/numhash.c | 4 | ||||
-rw-r--r-- | ext/tk/tkutil/tkutil.c | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/ext/-test-/st/numhash/numhash.c b/ext/-test-/st/numhash/numhash.c index 9b7df3844e..599678dde1 100644 --- a/ext/-test-/st/numhash/numhash.c +++ b/ext/-test-/st/numhash/numhash.c @@ -54,7 +54,9 @@ numhash_i(st_data_t key, st_data_t value, st_data_t arg, int error) static VALUE numhash_each(VALUE self) { - return st_foreach((st_table *)DATA_PTR(self), numhash_i, self) ? Qtrue : Qfalse; + st_table *table = DATA_PTR(self); + st_data_t data = (st_data_t)self; + return st_foreach_check(table, numhash_i, data, data) ? Qtrue : Qfalse; } static int diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c index 09ad7ce143..956c6737c9 100644 --- a/ext/tk/tkutil/tkutil.c +++ b/ext/tk/tkutil/tkutil.c @@ -266,7 +266,6 @@ to_strkey(key, value, hash) VALUE value; VALUE hash; { - if (key == Qundef) return ST_CONTINUE; rb_hash_aset(hash, rb_funcall(key, ID_to_s, 0, 0), value); return ST_CHECK; } @@ -280,7 +279,7 @@ tk_symbolkey2str(self, keys) if NIL_P(keys) return new_keys; keys = rb_convert_type(keys, T_HASH, "Hash", "to_hash"); - st_foreach(RHASH_TBL(keys), to_strkey, new_keys); + st_foreach_check(RHASH_TBL(keys), to_strkey, new_keys, Qundef); return new_keys; } @@ -653,7 +652,6 @@ push_kv(key, val, args) ary = RARRAY_PTR(args)[0]; - if (key == Qundef) return ST_CONTINUE; #if 0 rb_ary_push(ary, key2keyname(key)); if (val != TK_None) rb_ary_push(ary, val); @@ -676,7 +674,7 @@ hash2kv(hash, ary, self) volatile VALUE dst = rb_ary_new2(2 * RHASH_SIZE(hash)); volatile VALUE args = rb_ary_new3(2, dst, self); - st_foreach(RHASH_TBL(hash), push_kv, args); + st_foreach_check(RHASH_TBL(hash), push_kv, args, Qundef); if (NIL_P(ary)) { return dst; @@ -695,7 +693,6 @@ push_kv_enc(key, val, args) ary = RARRAY_PTR(args)[0]; - if (key == Qundef) return ST_CONTINUE; #if 0 rb_ary_push(ary, key2keyname(key)); if (val != TK_None) { @@ -721,7 +718,7 @@ hash2kv_enc(hash, ary, self) volatile VALUE dst = rb_ary_new2(2 * RHASH_SIZE(hash)); volatile VALUE args = rb_ary_new3(2, dst, self); - st_foreach(RHASH_TBL(hash), push_kv_enc, args); + st_foreach_check(RHASH_TBL(hash), push_kv_enc, args, Qundef); if (NIL_P(ary)) { return dst; |