summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-26 05:29:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-26 05:29:06 +0000
commitdf2d69b49ab1c8b42dd6c18fb63df26aec95f364 (patch)
treef352837db7633a5d6355461ca14f0f870d951e86 /eval.c
parent69739b14a5f8950c1da8b86f90a70903ed975fee (diff)
* eval.c (proc_call): should not modify ruby_block->frame.iter
based on ruby_frame->iter altered by PUSH_ITER(). * eval.c (rb_thread_fd_close): should save current context before raising exception. * io.c (set_stdin): preserve original stdin. * io.c (set_outfile): preserve original stdout/stderr. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c61
1 files changed, 19 insertions, 42 deletions
diff --git a/eval.c b/eval.c
index fc46baa..0008961 100644
--- a/eval.c
+++ b/eval.c
@@ -3608,24 +3608,6 @@ rb_yield_0(val, self, klass, acheck)
pop_state:
POP_ITER();
POP_CLASS();
-#if 0
- if (ruby_dyna_vars && (block->flags & BLOCK_D_SCOPE) &&
- (!(ruby_scope->flags & SCOPE_DONT_RECYCLE) ||
- !(block->tag->flags & BLOCK_DYNAMIC) ||
- !FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE))) {
- struct RVarmap *vars, *tmp;
-
- if (ruby_dyna_vars->id == 0) {
- vars = ruby_dyna_vars->next;
- rb_gc_force_recycle((VALUE)ruby_dyna_vars);
- while (vars && vars->id != 0) {
- tmp = vars->next;
- rb_gc_force_recycle((VALUE)vars);
- vars = tmp;
- }
- }
- }
-#else
if (ruby_dyna_vars && (block->flags & BLOCK_D_SCOPE) &&
!FL_TEST(ruby_dyna_vars, DVAR_DONT_RECYCLE)) {
struct RVarmap *vars = ruby_dyna_vars;
@@ -3640,7 +3622,6 @@ rb_yield_0(val, self, klass, acheck)
}
}
}
-#endif
POP_VARS();
ruby_block = block;
ruby_frame = ruby_frame->prev;
@@ -6182,7 +6163,7 @@ proc_new(klass)
struct RVarmap *vars;
if (!rb_block_given_p() && !rb_f_block_given_p()) {
- rb_raise(rb_eArgError, "tried to create Procedure-Object without a block");
+ rb_raise(rb_eArgError, "tried to create Proc object without a block");
}
proc = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
@@ -6280,10 +6261,20 @@ proc_call(proc, args)
Data_Get_Struct(proc, struct BLOCK, data);
orphan = blk_orphan(data);
+ if (orphan) {/* orphan procedure */
+ if (rb_block_given_p()) {
+ ruby_block->frame.iter = ITER_CUR;
+ }
+ else {
+ ruby_block->frame.iter = ITER_NOT;
+ }
+ }
+
/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
ruby_block = &_block;
+
PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR;
@@ -6291,15 +6282,6 @@ proc_call(proc, args)
args = callargs(args);
}
- if (orphan) {/* orphan procedure */
- if (rb_block_given_p()) {
- ruby_block->frame.iter = ITER_CUR;
- }
- else {
- ruby_block->frame.iter = ITER_NOT;
- }
- }
-
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
if (state == 0) {
@@ -6993,6 +6975,8 @@ rb_thread_check(data)
return (rb_thread_t)RDATA(data)->data;
}
+static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t));
+
static int th_raise_argc;
static VALUE th_raise_argv[2];
static char *th_raise_file;
@@ -7176,20 +7160,15 @@ void
rb_thread_fd_close(fd)
int fd;
{
- rb_thread_t th;
+ rb_thread_t th, curr = curr_thread;
- FOREACH_THREAD(th) {
+ FOREACH_THREAD_FROM(curr, th) {
if ((th->wait_for & WAIT_FD) && fd == th->fd) {
- th_raise_argc = 1;
- th_raise_argv[0] = rb_exc_new2(rb_eIOError, "stream closed");
- th_raise_file = ruby_sourcefile;
- th_raise_line = ruby_sourceline;
- curr_thread = th;
- rb_thread_ready(th);
- rb_thread_restore_context(curr_thread, RESTORE_RAISE);
+ VALUE exc = rb_exc_new2(rb_eIOError, "stream closed");
+ rb_thread_raise(1, &exc, th);
}
}
- END_FOREACH(th);
+ END_FOREACH_FROM(curr, th);
}
static void
@@ -7976,8 +7955,6 @@ catch_timer(sig)
int rb_thread_tick = THREAD_TICK;
#endif
-static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t));
-
#define SCOPE_SHARED FL_USER1
#if defined(HAVE_SETITIMER)
@@ -8460,7 +8437,7 @@ rb_thread_inspect(thread)
void
rb_thread_atfork()
{
-#if 0 /* enable on 1.7 */
+#if 1 /* enable on 1.7 */
rb_thread_t th;
if (rb_thread_alone()) return;