diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-25 15:42:23 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-25 15:42:23 +0000 |
commit | ec0c394b9eb142c8e72e59bfa9061675b1167ed5 (patch) | |
tree | 8ccf9841fca263acde5b82e5f09ca7116ab15639 /range.c | |
parent | a9da574d74c87d94655b2f3a3d3db312bdace0b9 (diff) | |
download | ruby-ec0c394b9eb142c8e72e59bfa9061675b1167ed5.tar.gz |
* range.c (range_inspect): fix SEGV for cyclic range object.
[ruby-core:18835]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -663,6 +663,24 @@ range_to_s(VALUE range) return str; } +static VALUE +inspect_range(VALUE range, VALUE dummy, int recur) +{ + VALUE str, str2; + + if (recur) { + return rb_str_new2(EXCL(range) ? "(... ... ...)" : "(... .. ...)"); + } + str = rb_inspect(RANGE_BEG(range)); + str2 = rb_inspect(RANGE_END(range)); + str = rb_str_dup(str); + rb_str_cat(str, "...", EXCL(range) ? 3 : 2); + rb_str_append(str, str2); + OBJ_INFECT(str, str2); + + return str; +} + /* * call-seq: * rng.inspect => string @@ -676,16 +694,7 @@ range_to_s(VALUE range) static VALUE range_inspect(VALUE range) { - VALUE str, str2; - - str = rb_inspect(RANGE_BEG(range)); - str2 = rb_inspect(RANGE_END(range)); - str = rb_str_dup(str); - rb_str_cat(str, "...", EXCL(range) ? 3 : 2); - rb_str_append(str, str2); - OBJ_INFECT(str, str2); - - return str; + return rb_exec_recursive(inspect_range, range, 0); } /* |