ruby-changes:15171
From: knu <ko1@a...>
Date: Fri, 26 Mar 2010 04:00:37 +0900 (JST)
Subject: [ruby-changes:15171] Ruby:r27051 (ruby_1_8): * variable.c, intern.h: Add rb_const_remove().
knu 2010-03-26 03:59:19 +0900 (Fri, 26 Mar 2010) New Revision: 27051 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27051 Log: * variable.c, intern.h: Add rb_const_remove(). Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/intern.h branches/ruby_1_8/variable.c Index: ruby_1_8/intern.h =================================================================== --- ruby_1_8/intern.h (revision 27050) +++ ruby_1_8/intern.h (revision 27051) @@ -521,6 +521,7 @@ 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)); Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 27050) +++ ruby_1_8/ChangeLog (revision 27051) @@ -1,3 +1,7 @@ +Fri Mar 26 03:58:37 2010 Akinori MUSHA <knu@i...> + + * variable.c, intern.h: Add rb_const_remove(). + Fri Mar 26 03:09:30 2010 Akinori MUSHA <knu@i...> * object.c (rb_obj_singleton_class): new method Index: ruby_1_8/variable.c =================================================================== --- ruby_1_8/variable.c (revision 27050) +++ ruby_1_8/variable.c (revision 27051) @@ -1479,12 +1479,21 @@ 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"); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/