aboutsummaryrefslogtreecommitdiffstats
path: root/range.c
diff options
context:
space:
mode:
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);
}
/*