summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-12-22 03:22:25 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-12-22 03:22:25 +0000
commit0e47c138c9bba4396fc7d956b05e5725000012f1 (patch)
tree54fac5b90c2ce6664e7017d954add4d06e388a09 /eval.c
parent31c53aaa7dc3da8bc9ba6b3007c183dcbeeafe11 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/eval.c b/eval.c
index ee2881f..2588427 100644
--- a/eval.c
+++ b/eval.c
@@ -4943,33 +4943,34 @@ specific_eval(argc, argv, klass, self)
VALUE *argv;
VALUE klass, self;
{
- char *file = "(eval)";
- int line = 1;
- int iter = rb_block_given_p();
-
- if (argc > 0) {
- if (ruby_safe_level >= 4) {
- Check_Type(argv[0], T_STRING);
+ if (rb_block_given_p()) {
+ if (argc > 0) {
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
}
- else {
- Check_SafeStr(argv[0]);
- }
- if (argc > 3) {
- rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
- rb_id2name(ruby_frame->last_func),
- rb_id2name(ruby_frame->last_func));
- }
- if (argc > 1) file = STR2CSTR(argv[1]);
- if (argc > 2) line = NUM2INT(argv[2]);
- }
- else if (!iter) {
- rb_raise(rb_eArgError, "block not supplied");
- }
-
- if (iter) {
return yield_under(klass, self);
}
else {
+ char *file = "(eval)";
+ int line = 1;
+
+ if (argc == 0) {
+ rb_raise(rb_eArgError, "block not supplied");
+ }
+ else {
+ if (ruby_safe_level >= 4) {
+ Check_Type(argv[0], T_STRING);
+ }
+ else {
+ Check_SafeStr(argv[0]);
+ }
+ if (argc > 3) {
+ rb_raise(rb_eArgError, "wrong # of arguments: %s(src) or %s{..}",
+ rb_id2name(ruby_frame->last_func),
+ rb_id2name(ruby_frame->last_func));
+ }
+ if (argc > 1) file = STR2CSTR(argv[1]);
+ if (argc > 2) line = NUM2INT(argv[2]);
+ }
return eval_under(klass, self, argv[0], file, line);
}
}
@@ -5551,6 +5552,9 @@ rb_obj_extend(argc, argv, obj)
{
int i;
+ if (argc == 0) {
+ rb_raise(rb_eArgError, "wrong # of arguments(0 for 1)");
+ }
for (i=0; i<argc; i++) Check_Type(argv[i], T_MODULE);
for (i=0; i<argc; i++) {
rb_funcall(argv[i], rb_intern("extend_object"), 1, obj);