summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-13 05:09:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-02-13 05:09:11 +0000
commit8be410f0653bfb22970381447acf685af4795c00 (patch)
tree8946eb2e9437f998c332d5d7326032efce9dd141 /eval.c
parent32ce4317d8077c926d0c00172cfac8001dd5ff98 (diff)
* io.c (rb_io_ctl): do not call ioctl/fcntl for f2, if f and f2
have same fileno. * eval.c (rb_load): raise LocaJumpError if unexpected local jumps appear during load. * ext/socket/socket.c (bsock_close_read): don't call rb_thread_fd_close(); it's supposed to be called by io_io_close(). * ext/socket/socket.c (bsock_close_read): do not modify f and f2. * ext/socket/socket.c (bsock_close_write): ditto. * ext/socket/socket.c (sock_new): avoid dup(2) on sockets. * parse.y (primary): preserve and clear in_single and in_def using stack to prevent nested method errors in singleton class bodies. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c74
1 files changed, 36 insertions, 38 deletions
diff --git a/eval.c b/eval.c
index 1dd7290..e8a22de 100644
--- a/eval.c
+++ b/eval.c
@@ -1298,6 +1298,34 @@ rb_eval_string_wrap(str, state)
return val;
}
+static void
+jump_tag_but_local_jump(state)
+ int state;
+{
+ switch (state) {
+ case 0:
+ break;
+ case TAG_RETURN:
+ rb_raise(rb_eLocalJumpError, "unexpected return");
+ break;
+ case TAG_NEXT:
+ rb_raise(rb_eLocalJumpError, "unexpected next");
+ break;
+ case TAG_BREAK:
+ rb_raise(rb_eLocalJumpError, "unexpected break");
+ break;
+ case TAG_REDO:
+ rb_raise(rb_eLocalJumpError, "unexpected redo");
+ break;
+ case TAG_RETRY:
+ rb_raise(rb_eLocalJumpError, "retry outside of rescue clause");
+ break;
+ default:
+ JUMP_TAG(state);
+ break;
+ }
+}
+
VALUE
rb_eval_cmd(cmd, arg)
VALUE cmd, arg;
@@ -1333,28 +1361,7 @@ rb_eval_cmd(cmd, arg)
POP_TAG();
POP_CLASS();
- switch (state) {
- case 0:
- break;
- case TAG_RETURN:
- rb_raise(rb_eLocalJumpError, "unexpected return");
- break;
- case TAG_NEXT:
- rb_raise(rb_eLocalJumpError, "unexpected next");
- break;
- case TAG_BREAK:
- rb_raise(rb_eLocalJumpError, "unexpected break");
- break;
- case TAG_REDO:
- rb_raise(rb_eLocalJumpError, "unexpected redo");
- break;
- case TAG_RETRY:
- rb_raise(rb_eLocalJumpError, "retry outside of rescue clause");
- break;
- default:
- JUMP_TAG(state);
- break;
- }
+ jump_tag_but_local_jump(state);
return val;
}
@@ -3644,10 +3651,8 @@ rb_yield_0(val, self, klass, acheck)
if (!block->tag) {
switch (state & TAG_MASK) {
case TAG_BREAK:
- rb_raise(rb_eLocalJumpError, "unexpected break");
- break;
case TAG_RETURN:
- rb_raise(rb_eLocalJumpError, "unexpected return");
+ jump_tag_but_local_jump(state & TAG_MASK);
break;
}
}
@@ -4454,21 +4459,14 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
case 0:
break;
- case TAG_NEXT:
- rb_raise(rb_eLocalJumpError, "unexpected next");
- break;
- case TAG_BREAK:
- rb_raise(rb_eLocalJumpError, "unexpected break");
- break;
- case TAG_REDO:
- rb_raise(rb_eLocalJumpError, "unexpected redo");
- break;
case TAG_RETRY:
- if (!rb_block_given_p()) {
- rb_raise(rb_eLocalJumpError, "retry outside of rescue clause");
+ if (rb_block_given_p()) {
+ break;
}
+ /* fall through */
default:
- JUMP_TAG(state);
+ jump_tag_but_local_jump(state);
+ break;
}
}
}
@@ -5189,7 +5187,7 @@ rb_load(fname, wrap)
rb_exc_raise(ruby_errinfo);
}
TMP_PROTECT_END;
- if (state) JUMP_TAG(state);
+ if (state) jump_tag_but_local_jump(state);
if (!NIL_P(ruby_errinfo)) /* exception during load */
rb_exc_raise(ruby_errinfo);
}