summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-02 01:47:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-09-02 01:47:43 +0000
commit0465916576dd5807e9ffdb21b4c008a9069a5804 (patch)
treea069619887dfdd23318a310699c1b210f0f44aa8 /cont.c
parentcaf92db48646a0b2febcd69f2e9a9a6734074a68 (diff)
downloadruby-0465916576dd5807e9ffdb21b4c008a9069a5804.tar.gz
cont.c: fix root fiber to_s
* cont.c (fiber_to_s): fix Fiber#to_s on root fibers which have no procs. [ruby-core:82629] [Bug #13859] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/cont.c b/cont.c
index c86095775c..b27afc2158 100644
--- a/cont.c
+++ b/cont.c
@@ -1753,8 +1753,15 @@ fiber_to_s(VALUE fibval)
char status_info[0x10];
GetFiberPtr(fibval, fib);
- GetProcPtr(fib->first_proc, proc);
snprintf(status_info, 0x10, " (%s)", fiber_status_name(fib->status));
+ if (!rb_obj_is_proc(fib->first_proc)) {
+ VALUE str = rb_any_to_s(fibval);
+ strlcat(status_info, ">", sizeof(status_info));
+ rb_str_set_len(str, RSTRING_LEN(str)-1);
+ rb_str_cat_cstr(str, status_info);
+ return str;
+ }
+ GetProcPtr(fib->first_proc, proc);
return rb_block_to_s(fibval, &proc->block, status_info);
}