summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/thread.c b/thread.c
index 2ee530f6b6..0e743c68e0 100644
--- a/thread.c
+++ b/thread.c
@@ -4880,19 +4880,7 @@ static VALUE
exec_recursive_i(RB_BLOCK_CALL_FUNC_ARGLIST(tag, data))
{
struct exec_recursive_params *p = (void *)data;
- VALUE result = Qundef;
- int state;
-
- recursive_push(p->list, p->objid, p->pairid);
- PUSH_TAG();
- if ((state = EXEC_TAG()) == 0) {
- result = (*p->func)(p->obj, p->arg, FALSE);
- }
- POP_TAG();
- recursive_pop(p->list, p->objid, p->pairid);
- if (state)
- JUMP_TAG(state);
- return result;
+ return (*p->func)(p->obj, p->arg, FALSE);
}
/*
@@ -4926,18 +4914,30 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
return (*func)(obj, arg, TRUE);
}
else {
+ int state;
+
p.func = func;
if (outermost) {
recursive_push(p.list, ID2SYM(recursive_key), 0);
- result = rb_catch_obj(p.list, exec_recursive_i, (VALUE)&p);
+ recursive_push(p.list, p.objid, p.pairid);
+ result = rb_catch_protect(p.list, exec_recursive_i, (VALUE)&p, &state);
+ recursive_pop(p.list, p.objid, p.pairid);
recursive_pop(p.list, ID2SYM(recursive_key), 0);
+ if (state) JUMP_TAG(state);
if (result == p.list) {
result = (*func)(obj, arg, TRUE);
}
}
else {
- result = exec_recursive_i(0, (VALUE)&p, 0, 0, Qnil);
+ recursive_push(p.list, p.objid, p.pairid);
+ PUSH_TAG();
+ if ((state = EXEC_TAG()) == 0) {
+ result = (*func)(obj, arg, FALSE);
+ }
+ POP_TAG();
+ recursive_pop(p.list, p.objid, p.pairid);
+ if (state) JUMP_TAG(state);
}
}
*(volatile struct exec_recursive_params *)&p;