summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-13 14:57:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-13 14:57:36 +0000
commit4de0bb549b9d28e7f6e0799d3c3a08f615a49f51 (patch)
tree6c1961b725aa2c92aaf0926964c80dbdc02347a2 /variable.c
parent1b8c124c8d19a572d94a6187372da1f3295f11ed (diff)
* eval.c (rb_feature_p): match by classified suffix.
* eval.c (rb_require_safe): require library in the specified safe level. * variable.c (rb_autoload, rb_autoload_load): restore safe level when autoload was called. [ruby-dev:21338] * intern.h: prototypes; rb_require_safe. * test/runner.rb: accept non-option arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/variable.c b/variable.c
index 3cee63b..1e0aea4 100644
--- a/variable.c
+++ b/variable.c
@@ -1147,7 +1147,7 @@ rb_autoload(mod, id, file)
ID id;
const char *file;
{
- VALUE av;
+ VALUE av, fn;
struct st_table *tbl;
if (!rb_is_const_id(id)) {
@@ -1170,21 +1170,25 @@ rb_autoload(mod, id, file)
st_add_direct(tbl, autoload, av);
DATA_PTR(av) = tbl = st_init_numtable();
}
- st_insert(tbl, id, rb_str_new2(file));
+ fn = rb_str_new2(file);
+ FL_UNSET(fn, FL_TAINT);
+ OBJ_FREEZE(fn);
+ st_insert(tbl, id, (st_data_t)rb_node_newnode(NODE_MEMO, fn, ruby_safe_level, 0));
}
-static VALUE
+static NODE*
autoload_delete(mod, id)
VALUE mod;
ID id;
{
- VALUE val, file = Qnil;
+ VALUE val;
+ st_data_t load = 0;
st_delete(RCLASS(mod)->iv_tbl, (st_data_t*)&id, 0);
if (st_lookup(RCLASS(mod)->iv_tbl, autoload, &val)) {
struct st_table *tbl = check_autoload_table(val);
- if (!st_delete(tbl, (st_data_t*)&id, &file)) file = Qnil;
+ st_delete(tbl, (st_data_t*)&id, &load);
if (tbl->num_entries == 0) {
DATA_PTR(val) = 0;
@@ -1196,7 +1200,7 @@ autoload_delete(mod, id)
}
}
- return file;
+ return (NODE *)load;
}
void
@@ -1205,13 +1209,12 @@ rb_autoload_load(klass, id)
ID id;
{
VALUE file;
+ NODE *load = autoload_delete(klass, id);
- file = autoload_delete(klass, id);
- if (NIL_P(file) || rb_provided(RSTRING(file)->ptr)) {
+ if (!load || !(file = load->nd_lit) || rb_provided(RSTRING(file)->ptr)) {
const_missing(klass, id);
}
- FL_UNSET(file, FL_TAINT);
- rb_f_require(Qnil, file);
+ rb_require_safe(file, load->nd_nth);
}
static VALUE
@@ -1221,11 +1224,13 @@ autoload_file(mod, id)
{
VALUE val, file;
struct st_table *tbl;
+ st_data_t load;
if (!st_lookup(RCLASS(mod)->iv_tbl, autoload, &val) ||
- !(tbl = check_autoload_table(val)) || !st_lookup(tbl, id, &file)) {
+ !(tbl = check_autoload_table(val)) || !st_lookup(tbl, id, &load)) {
return Qnil;
}
+ file = ((NODE *)load)->nd_lit;
Check_Type(file, T_STRING);
if (!RSTRING(file)->ptr) {
rb_raise(rb_eArgError, "empty file name");