aboutsummaryrefslogtreecommitdiffstats
path: root/range.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-25 15:42:23 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-25 15:42:23 +0000
commitec0c394b9eb142c8e72e59bfa9061675b1167ed5 (patch)
tree8ccf9841fca263acde5b82e5f09ca7116ab15639 /range.c
parenta9da574d74c87d94655b2f3a3d3db312bdace0b9 (diff)
downloadruby-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.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/range.c b/range.c
index 09dc762acf..5c77e03f73 100644
--- a/range.c
+++ b/range.c
@@ -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);
}
/*