summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authoreban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-13 05:27:24 +0000
committereban <eban@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-05-13 05:27:24 +0000
commit30a9fd3f174000f4bb456a2d7470a25da58cddef (patch)
treeb02e80659f3259ebd1ffbde59c499b7538cc704c /hash.c
parent32d051b6922cbc4ada1d02aa08cc792efb5a4093 (diff)
* hash.c (delete_if_i): use st_delete_safe() (via
rb_hash_delete()) instead of returning ST_DELETE. backport from HEAD. [ruby-dev:23487] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/hash.c b/hash.c
index 9d1c5d0..209fe26 100644
--- a/hash.c
+++ b/hash.c
@@ -679,12 +679,13 @@ rb_hash_shift(hash)
}
static enum st_retval
-delete_if_i(key, value)
- VALUE key, value;
+delete_if_i(key, value, hash)
+ VALUE key, value, hash;
{
if (key == Qundef) return ST_CONTINUE;
- if (RTEST(rb_yield_values(2, key, value)))
- return ST_DELETE;
+ if (RTEST(rb_yield_values(2, key, value))) {
+ rb_hash_delete(hash, key);
+ }
return ST_CONTINUE;
}
@@ -705,7 +706,7 @@ rb_hash_delete_if(hash)
VALUE hash;
{
rb_hash_modify(hash);
- rb_hash_foreach(hash, delete_if_i, 0);
+ rb_hash_foreach(hash, delete_if_i, hash);
return hash;
}