summaryrefslogtreecommitdiff
path: root/eval_jump.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-16 11:42:03 (GMT)
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-02-16 11:42:03 (GMT)
commit36a0a1a3f3d6ede4c8d42c3beb2e5c24ea649f3c (patch)
treede1c5a4fa3147dba0cf70117320b639ab3feae20 /eval_jump.c
parent90b86c51ab8161f49b5d88f35a3ce6cf78fe7274 (diff)
* eval_jump.c (rb_exec_end_proc): changed at_exit and END proc
evaluation order. [Bug #4400] [ruby-core:35237] * eval_jump.c (rb_mark_end_proc): ditto. * test/ruby/test_beginendblock.rb (TestBeginEndBlock#test_nested_at_exit): added a test for nested at_exit. * test/ruby/test_beginendblock.rb (TestBeginEndBlock#test_beginendblock): changed the test to adopt new spec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_jump.c')
-rw-r--r--eval_jump.c62
1 files changed, 26 insertions, 36 deletions
diff --git a/eval_jump.c b/eval_jump.c
index 18b6835..8d55256 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -54,7 +54,7 @@ struct end_proc_data {
struct end_proc_data *next;
};
-static struct end_proc_data *end_procs, *ephemeral_end_procs, *tmp_end_procs;
+static struct end_proc_data *end_procs, *ephemeral_end_procs;
void
rb_set_end_proc(void (*func)(VALUE), VALUE data)
@@ -91,11 +91,6 @@ rb_mark_end_proc(void)
rb_gc_mark(link->data);
link = link->next;
}
- link = tmp_end_procs;
- while (link) {
- rb_gc_mark(link->data);
- link = link->next;
- }
}
void
@@ -107,40 +102,35 @@ rb_exec_end_proc(void)
volatile int safe = rb_safe_level();
while (ephemeral_end_procs) {
- tmp_end_procs = link = ephemeral_end_procs;
- ephemeral_end_procs = 0;
- while (link) {
- PUSH_TAG();
- if ((status = EXEC_TAG()) == 0) {
- rb_set_safe_level_force(link->safe);
- (*link->func) (link->data);
- }
- POP_TAG();
- if (status) {
- error_handle(status);
- }
- tmp = link;
- tmp_end_procs = link = link->next;
- xfree(tmp);
+ link = ephemeral_end_procs;
+ ephemeral_end_procs = link->next;
+
+ PUSH_TAG();
+ if ((status = EXEC_TAG()) == 0) {
+ rb_set_safe_level_force(link->safe);
+ (*link->func) (link->data);
}
+ POP_TAG();
+ if (status) {
+ error_handle(status);
+ }
+ xfree(link);
}
+
while (end_procs) {
- tmp_end_procs = link = end_procs;
- end_procs = 0;
- while (link) {
- PUSH_TAG();
- if ((status = EXEC_TAG()) == 0) {
- rb_set_safe_level_force(link->safe);
- (*link->func) (link->data);
- }
- POP_TAG();
- if (status) {
- error_handle(status);
- }
- tmp = link;
- tmp_end_procs = link = link->next;
- xfree(tmp);
+ link = end_procs;
+ end_procs = link->next;
+
+ PUSH_TAG();
+ if ((status = EXEC_TAG()) == 0) {
+ rb_set_safe_level_force(link->safe);
+ (*link->func) (link->data);
+ }
+ POP_TAG();
+ if (status) {
+ error_handle(status);
}
+ xfree(link);
}
rb_set_safe_level_force(safe);
}