summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-01 02:52:21 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-08-01 02:52:21 +0000
commit601354bd6b661950663746bc41fe364b67bb8cd5 (patch)
tree0d3a28d2d017105b74cc60301cf522134b0a4692 /hash.c
parent81f52e532b8923f2544d129f90ccb1514f1615e0 (diff)
* eval.c (BEGIN_CALLARGS): should not always reset ruby_iter,
need to restore previous value. [ruby-talk:77577] * array.c (rb_ary_fill): array length may be changed during the block execution. [ruby-talk:77579] * array.c (rb_ary_zip): ditto. * array.c (rb_ary_fill): ditto. * hash.c (env_reject_bang): length may be changed during the block execution. * hash.c (env_clear): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/hash.c b/hash.c
index 622c84b..1a4ab1e 100644
--- a/hash.c
+++ b/hash.c
@@ -1372,25 +1372,21 @@ static VALUE
env_reject_bang()
{
volatile VALUE keys;
- VALUE *ptr;
- long len;
+ long i;
int del = 0;
rb_secure(4);
keys = env_keys();
- ptr = RARRAY(keys)->ptr;
- len = RARRAY(keys)->len;
- while (len--) {
- VALUE val = rb_f_getenv(Qnil, *ptr);
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
if (!NIL_P(val)) {
- if (RTEST(rb_yield_values(2, *ptr, val))) {
- FL_UNSET(*ptr, FL_TAINT);
- env_delete(Qnil, *ptr);
+ if (RTEST(rb_yield_values(2, RARRAY(keys)->ptr[i], val))) {
+ FL_UNSET(RARRAY(keys)->ptr[i], FL_TAINT);
+ env_delete(Qnil, RARRAY(keys)->ptr[i]);
del++;
}
}
- ptr++;
}
if (del == 0) return Qnil;
return envtbl;
@@ -1454,20 +1450,16 @@ static VALUE
env_clear()
{
volatile VALUE keys;
- VALUE *ptr;
- long len;
+ long i;
rb_secure(4);
keys = env_keys();
- ptr = RARRAY(keys)->ptr;
- len = RARRAY(keys)->len;
- while (len--) {
- VALUE val = rb_f_getenv(Qnil, *ptr);
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ VALUE val = rb_f_getenv(Qnil, RARRAY(keys)->ptr[i]);
if (!NIL_P(val)) {
- env_delete(Qnil, *ptr);
+ env_delete(Qnil, RARRAY(keys)->ptr[i]);
}
- ptr++;
}
return envtbl;
}
@@ -1719,18 +1711,14 @@ env_replace(env, hash)
VALUE env, hash;
{
volatile VALUE keys = env_keys();
- VALUE *ptr;
- long len;
+ long i;
if (env == hash) return env;
hash = to_hash(hash);
st_foreach(RHASH(hash)->tbl, env_replace_i, keys);
- ptr = RARRAY(keys)->ptr;
- len = RARRAY(keys)->len;
-
- while (len--) {
- env_delete(env, *ptr++);
+ for (i=0; i<RARRAY(keys)->len; i++) {
+ env_delete(env, RARRAY(keys)->ptr[i]);
}
return env;
}