diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-25 18:59:19 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-25 18:59:19 +0000 |
commit | c36f4b164bdf47046804103a403bec800aceac88 (patch) | |
tree | 9d6b6406bf03ba1079a2eb5df47323fea5638c36 | |
parent | 2292de78b1c8a467b16419d08f3376445fc46dd4 (diff) |
* variable.c, intern.h: Add rb_const_remove().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | intern.h | 1 | ||||
-rw-r--r-- | variable.c | 13 |
3 files changed, 16 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Fri Mar 26 03:58:37 2010 Akinori MUSHA <[email protected]> + + * variable.c, intern.h: Add rb_const_remove(). + Fri Mar 26 03:09:30 2010 Akinori MUSHA <[email protected]> * object.c (rb_obj_singleton_class): new method @@ -521,6 +521,7 @@ VALUE rb_const_get _((VALUE, ID)); VALUE rb_const_get_at _((VALUE, ID)); VALUE rb_const_get_from _((VALUE, ID)); void rb_const_set _((VALUE, ID, VALUE)); +VALUE rb_const_remove _((VALUE, ID)); VALUE rb_mod_constants _((VALUE)); VALUE rb_mod_const_missing _((VALUE,VALUE)); VALUE rb_cvar_defined _((VALUE, ID)); diff --git a/variable.c b/variable.c index d39335e7e1..eb245377ae 100644 --- a/variable.c +++ b/variable.c @@ -1479,12 +1479,21 @@ rb_mod_remove_const(mod, name) VALUE mod, name; { const ID id = rb_to_id(name); - VALUE val; - st_data_t v, n = id; if (!rb_is_const_id(id)) { rb_name_error(id, "`%s' is not allowed as a constant name", rb_id2name(id)); } + return rb_const_remove(mod, id); +} + +VALUE +rb_const_remove(mod, id) + VALUE mod; + ID id; +{ + VALUE val; + st_data_t v, n = id; + if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4) rb_raise(rb_eSecurityError, "Insecure: can't remove constant"); if (OBJ_FROZEN(mod)) rb_error_frozen("class/module"); |