diff options
-rw-r--r-- | iseq.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -781,9 +781,18 @@ static VALUE iseqw_s_compile(int argc, VALUE *argv, VALUE self) { VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil; + int i; + rb_secure(1); - rb_scan_args(argc, argv, "14", &src, &file, &path, &line, &opt); + i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt); + if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5); + switch (i) { + case 5: opt = argv[--i]; + case 4: line = argv[--i]; + case 3: path = argv[--i]; + case 2: file = argv[--i]; + } if (NIL_P(file)) file = rb_fstring_cstr("<compiled>"); if (NIL_P(line)) line = INT2FIX(1); @@ -818,9 +827,14 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self) VALUE f; NODE *node; rb_compile_option_t option; + int i; rb_secure(1); - rb_scan_args(argc, argv, "11", &file, &opt); + i = rb_scan_args(argc, argv, "1*:", &file, NULL, &opt); + if (i > 1+NIL_P(opt)) rb_error_arity(argc, 1, 2); + switch (i) { + case 2: opt = argv[--i]; + } FilePathValue(file); file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */ |