summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-27 06:23:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-27 06:23:36 +0000
commitb15f76556f9da3e17a9f17c97c9b611524a8d509 (patch)
treeea65af90d9558c366ff984af99e52b12918aec34 /iseq.c
parent802e5677a4f285bf90df78f8998a5f0cfea2fbc6 (diff)
iseq.c: kwarg to compile
* iseq.c (iseqw_s_compile, iseqw_s_compile_file): allow keyword arguments as the options. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/iseq.c b/iseq.c
index 425850bde2..4f8fc29154 100644
--- a/iseq.c
+++ b/iseq.c
@@ -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 */