summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-01 10:42:31 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-01 10:42:31 +0000
commita55226e008f3070de62e9aeb8dc2547e05f6120f (patch)
tree8743bda47a31c20adcb4e3375006dd1c98ac381b
parenta4f8311fe50f403d53d3bb04492429cbedc5917e (diff)
merges r20432 from trunk into ruby_1_9_1.
* cont.c (rb_fiber_start): calls with exact argument number. [ruby-core:20088] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--cont.c9
-rw-r--r--test/ruby/test_fiber.rb4
3 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 94aefd6170..d87b45caa4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Dec 1 12:00:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * cont.c (rb_fiber_start): calls with exact argument number.
+ [ruby-core:20088]
+
Mon Dec 1 16:06:15 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* signal.c (register_sigaltstack): no need to define on non-sigaltstack
diff --git a/cont.c b/cont.c
index 515e819fb1..0f805881dc 100644
--- a/cont.c
+++ b/cont.c
@@ -25,6 +25,7 @@ enum context_type {
typedef struct rb_context_struct {
enum context_type type;
VALUE self;
+ int argc;
VALUE value;
VALUE *vm_stack;
#ifdef CAPTURE_JUST_VALID_VM_STACK
@@ -558,6 +559,7 @@ rb_cont_call(int argc, VALUE *argv, VALUE contval)
}
}
+ cont->argc = argc;
cont->value = make_passing_arg(argc, argv);
cont_restore_0(cont, &contval);
@@ -685,7 +687,6 @@ rb_fiber_start(void)
rb_fiber_t *fib;
rb_context_t *cont;
rb_proc_t *proc;
- VALUE args;
int state;
GetFiberPtr(th->fiber, fib);
@@ -693,15 +694,18 @@ rb_fiber_start(void)
TH_PUSH_TAG(th);
if ((state = EXEC_TAG()) == 0) {
+ int argc;
+ VALUE *argv, args;
GetProcPtr(cont->saved_thread.first_proc, proc);
args = cont->value;
+ argv = (argc = cont->argc) > 1 ? RARRAY_PTR(args) : &args;
cont->value = Qnil;
th->errinfo = Qnil;
th->local_lfp = proc->block.lfp;
th->local_svar = Qnil;
fib->status = RUNNING;
- cont->value = vm_invoke_proc(th, proc, proc->block.self, 1, &args, 0);
+ cont->value = vm_invoke_proc(th, proc, proc->block.self, argc, argv, 0);
}
TH_POP_TAG();
@@ -798,6 +802,7 @@ fiber_switch(VALUE fibval, int argc, VALUE *argv, int is_resume)
fib->prev = rb_fiber_current();
}
+ cont->argc = argc;
cont->value = make_passing_arg(argc, argv);
if ((value = fiber_store(fib)) == Qundef) {
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index fc9a49919a..bf56b2b6d2 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -14,6 +14,10 @@ class TestFiber < Test::Unit::TestCase
assert_equal([:a, :b], Fiber.new{|a, b| [a, b]}.resume(:a, :b))
end
+ def test_argument
+ assert_equal(4, Fiber.new {|i=4| i}.resume)
+ end
+
def test_term
assert_equal(:ok, Fiber.new{:ok}.resume)
assert_equal([:a, :b, :c, :d, :e],