diff options
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -4719,6 +4719,14 @@ break_jump(retval) static VALUE bmcall _((VALUE, VALUE)); static int method_arity _((VALUE)); +void +rb_need_block() +{ + if (!rb_block_given_p()) { + localjump_error("no block given", Qnil, 0); + } +} + static VALUE rb_yield_0(val, self, klass, flags, avalue) VALUE val, self, klass; /* OK */ @@ -4736,9 +4744,7 @@ rb_yield_0(val, self, klass, flags, avalue) int lambda = flags & YIELD_LAMBDA_CALL; int state; - if (!rb_block_given_p()) { - localjump_error("no block given", Qnil, 0); - } + rb_need_block(); PUSH_VARS(); block = ruby_block; @@ -6078,8 +6084,9 @@ backtrace(lev) } } } - while (frame && (n = frame->node)) { + for (; frame && (n = frame->node); frame = frame->prev) { if (frame->prev && frame->prev->this_func) { + if (frame->prev->node == n) continue; snprintf(buf, BUFSIZ, "%s:%d:in `%s'", n->nd_file, nd_line(n), rb_id2name(frame->prev->this_func)); @@ -6088,7 +6095,6 @@ backtrace(lev) snprintf(buf, BUFSIZ, "%s:%d", n->nd_file, nd_line(n)); } rb_ary_push(ary, rb_str_new2(buf)); - frame = frame->prev; } return ary; |