* eval.c (rb_f_at_exit): should not be called without a block.
block_given check added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
697af8e54c
commit
3d621a4c3d
@ -1,3 +1,8 @@
|
|||||||
|
Thu Aug 7 12:51:38 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_f_at_exit): should not be called without a block.
|
||||||
|
block_given check added.
|
||||||
|
|
||||||
Thu Aug 7 06:46:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Aug 7 06:46:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (rb_call0): forgot to pop ruby_class.
|
* eval.c (rb_call0): forgot to pop ruby_class.
|
||||||
|
36
eval.c
36
eval.c
@ -897,8 +897,9 @@ static struct tag *prot_tag;
|
|||||||
VALUE ruby_class;
|
VALUE ruby_class;
|
||||||
static VALUE ruby_wrapper; /* security wrapper */
|
static VALUE ruby_wrapper; /* security wrapper */
|
||||||
|
|
||||||
#define PUSH_CLASS() do { \
|
#define PUSH_CLASS(c) do { \
|
||||||
VALUE _class = ruby_class
|
VALUE _class = ruby_class; \
|
||||||
|
ruby_class = (c)
|
||||||
|
|
||||||
#define POP_CLASS() ruby_class = _class; \
|
#define POP_CLASS() ruby_class = _class; \
|
||||||
} while (0)
|
} while (0)
|
||||||
@ -1475,8 +1476,7 @@ rb_eval_string_wrap(str, state)
|
|||||||
VALUE wrapper = ruby_wrapper;
|
VALUE wrapper = ruby_wrapper;
|
||||||
VALUE val;
|
VALUE val;
|
||||||
|
|
||||||
PUSH_CLASS();
|
PUSH_CLASS(ruby_wrapper = rb_module_new());
|
||||||
ruby_class = ruby_wrapper = rb_module_new();
|
|
||||||
ruby_top_self = rb_obj_clone(ruby_top_self);
|
ruby_top_self = rb_obj_clone(ruby_top_self);
|
||||||
rb_extend_object(ruby_top_self, ruby_wrapper);
|
rb_extend_object(ruby_top_self, ruby_wrapper);
|
||||||
PUSH_FRAME();
|
PUSH_FRAME();
|
||||||
@ -3664,8 +3664,7 @@ module_setup(module, n)
|
|||||||
frame.tmp = ruby_frame;
|
frame.tmp = ruby_frame;
|
||||||
ruby_frame = &frame;
|
ruby_frame = &frame;
|
||||||
|
|
||||||
PUSH_CLASS();
|
PUSH_CLASS(module);
|
||||||
ruby_class = module;
|
|
||||||
PUSH_SCOPE();
|
PUSH_SCOPE();
|
||||||
PUSH_VARS();
|
PUSH_VARS();
|
||||||
|
|
||||||
@ -4047,7 +4046,6 @@ rb_yield_0(val, self, klass, flags, avalue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PUSH_VARS();
|
PUSH_VARS();
|
||||||
PUSH_CLASS();
|
|
||||||
block = ruby_block;
|
block = ruby_block;
|
||||||
frame = block->frame;
|
frame = block->frame;
|
||||||
frame.prev = ruby_frame;
|
frame.prev = ruby_frame;
|
||||||
@ -4069,12 +4067,8 @@ rb_yield_0(val, self, klass, flags, avalue)
|
|||||||
/* FOR does not introduce new scope */
|
/* FOR does not introduce new scope */
|
||||||
ruby_dyna_vars = block->dyna_vars;
|
ruby_dyna_vars = block->dyna_vars;
|
||||||
}
|
}
|
||||||
if (klass) {
|
PUSH_CLASS(klass ? klass : block->klass);
|
||||||
ruby_class = klass;
|
if (!klass) {
|
||||||
PUSH_CREF(klass);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ruby_class = block->klass;
|
|
||||||
self = block->self;
|
self = block->self;
|
||||||
}
|
}
|
||||||
node = block->body;
|
node = block->body;
|
||||||
@ -4946,8 +4940,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||||||
saved_cref = ruby_cref;
|
saved_cref = ruby_cref;
|
||||||
ruby_cref = (NODE*)body->nd_rval;
|
ruby_cref = (NODE*)body->nd_rval;
|
||||||
}
|
}
|
||||||
PUSH_CLASS();
|
PUSH_CLASS(ruby_cbase);
|
||||||
ruby_class = ruby_cbase;
|
|
||||||
if (body->nd_tbl) {
|
if (body->nd_tbl) {
|
||||||
local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
|
local_vars = TMP_ALLOC(body->nd_tbl[0]+1);
|
||||||
*local_vars++ = (VALUE)body;
|
*local_vars++ = (VALUE)body;
|
||||||
@ -5429,9 +5422,7 @@ eval(self, src, scope, file, line)
|
|||||||
file = ruby_sourcefile;
|
file = ruby_sourcefile;
|
||||||
line = ruby_sourceline;
|
line = ruby_sourceline;
|
||||||
}
|
}
|
||||||
PUSH_CLASS();
|
PUSH_CLASS(ruby_cbase);
|
||||||
ruby_class = ruby_cbase;
|
|
||||||
|
|
||||||
ruby_in_eval++;
|
ruby_in_eval++;
|
||||||
if (TYPE(ruby_class) == T_ICLASS) {
|
if (TYPE(ruby_class) == T_ICLASS) {
|
||||||
ruby_class = RBASIC(ruby_class)->klass;
|
ruby_class = RBASIC(ruby_class)->klass;
|
||||||
@ -5567,8 +5558,7 @@ exec_under(func, under, cbase, args)
|
|||||||
int state;
|
int state;
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
PUSH_CLASS();
|
PUSH_CLASS(under);
|
||||||
ruby_class = under;
|
|
||||||
PUSH_FRAME();
|
PUSH_FRAME();
|
||||||
ruby_frame->self = _frame.prev->self;
|
ruby_frame->self = _frame.prev->self;
|
||||||
ruby_frame->last_func = _frame.prev->last_func;
|
ruby_frame->last_func = _frame.prev->last_func;
|
||||||
@ -5736,8 +5726,7 @@ rb_load(fname, wrap)
|
|||||||
|
|
||||||
ruby_errinfo = Qnil; /* ensure */
|
ruby_errinfo = Qnil; /* ensure */
|
||||||
PUSH_VARS();
|
PUSH_VARS();
|
||||||
PUSH_CLASS();
|
PUSH_CLASS(ruby_wrapper);
|
||||||
wrapper = ruby_wrapper;
|
|
||||||
ruby_cref = top_cref;
|
ruby_cref = top_cref;
|
||||||
if (!wrap) {
|
if (!wrap) {
|
||||||
rb_secure(4); /* should alter global state */
|
rb_secure(4); /* should alter global state */
|
||||||
@ -6455,6 +6444,9 @@ rb_f_at_exit()
|
|||||||
{
|
{
|
||||||
VALUE proc;
|
VALUE proc;
|
||||||
|
|
||||||
|
if (!rb_block_given_p()) {
|
||||||
|
rb_raise(rb_eArgError, "called without a block");
|
||||||
|
}
|
||||||
proc = rb_block_proc();
|
proc = rb_block_proc();
|
||||||
rb_set_end_proc(call_end_proc, proc);
|
rb_set_end_proc(call_end_proc, proc);
|
||||||
return proc;
|
return proc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user