diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-07-15 06:13:08 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-07-15 06:13:08 +0000 |
commit | c30c3bffe472ee999fc722f63dd1c1984db1d1ce (patch) | |
tree | fd5a1cd95ad875ce2768b09c88cecc155dba74b8 /variable.c | |
parent | 35c6e6af5ba2c405a91dc6b9e4af833d0979ed22 (diff) |
1.1b9_31
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r-- | variable.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/variable.c b/variable.c index 7a827ed88b..c05853899e 100644 --- a/variable.c +++ b/variable.c @@ -650,7 +650,7 @@ rb_gvar_defined(entry) } static int -var_i(key, entry, ary) +gvar_i(key, entry, ary) ID key; struct global_entry *entry; VALUE ary; @@ -666,7 +666,7 @@ f_global_variables() char buf[4]; char *s = "&`'+123456789"; - st_foreach(global_tbl, var_i, ary); + st_foreach(global_tbl, gvar_i, ary); if (!NIL_P(backref_get())) { while (*s) { sprintf(buf, "$%c", *s++); @@ -757,6 +757,18 @@ rb_ivar_defined(obj, id) return FALSE; } +static int +ivar_i(key, entry, ary) + ID key; + struct global_entry *entry; + VALUE ary; +{ + if (rb_is_instance_id(key)) { + ary_push(ary, str_new2(rb_id2name(key))); + } + return ST_CONTINUE; +} + VALUE obj_instance_variables(obj) VALUE obj; @@ -769,7 +781,7 @@ obj_instance_variables(obj) case T_MODULE: ary = ary_new(); if (ROBJECT(obj)->iv_tbl) { - st_foreach(ROBJECT(obj)->iv_tbl, var_i, ary); + st_foreach(ROBJECT(obj)->iv_tbl, ivar_i, ary); } return ary; } |