1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
mame 2008-09-25 15:42:23 +00:00
parent a9da574d74
commit ec0c394b9e
2 changed files with 24 additions and 10 deletions

View file

@ -1,3 +1,8 @@
Fri Sep 26 00:40:30 2008 Yusuke Endoh <mame@tsg.ne.jp>
* range.c (range_inspect): fix SEGV for cyclic range object.
[ruby-core:18835]
Thu Sep 25 23:59:56 2008 Tanaka Akira <akr@fsij.org>
* common.mk: dependency updated.

29
range.c
View file

@ -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);
}
/*