string.c: GC guard
* string.c (rb_str_enumerate_chars): prevent shared copy from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5a7347a7bd
commit
c8484fb322
@ -1,3 +1,7 @@
|
|||||||
|
Wed Dec 26 07:31:14 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_enumerate_chars): prevent shared copy from GC.
|
||||||
|
|
||||||
Wed Dec 26 01:31:16 2012 Keiju Ishitsuka <keiju@ishitsuka.com>
|
Wed Dec 26 01:31:16 2012 Keiju Ishitsuka <keiju@ishitsuka.com>
|
||||||
|
|
||||||
* lib/irb/init.rb, lib/irb/context.rb: fix conf.debug_level=
|
* lib/irb/init.rb, lib/irb/context.rb: fix conf.debug_level=
|
||||||
|
12
string.c
12
string.c
@ -6389,6 +6389,7 @@ static VALUE
|
|||||||
rb_str_enumerate_chars(VALUE str, int wantarray)
|
rb_str_enumerate_chars(VALUE str, int wantarray)
|
||||||
{
|
{
|
||||||
VALUE orig = str;
|
VALUE orig = str;
|
||||||
|
VALUE substr;
|
||||||
long i, len, n;
|
long i, len, n;
|
||||||
const char *ptr;
|
const char *ptr;
|
||||||
rb_encoding *enc;
|
rb_encoding *enc;
|
||||||
@ -6421,21 +6422,24 @@ rb_str_enumerate_chars(VALUE str, int wantarray)
|
|||||||
case ENC_CODERANGE_7BIT:
|
case ENC_CODERANGE_7BIT:
|
||||||
for (i = 0; i < len; i += n) {
|
for (i = 0; i < len; i += n) {
|
||||||
n = rb_enc_fast_mbclen(ptr + i, ptr + len, enc);
|
n = rb_enc_fast_mbclen(ptr + i, ptr + len, enc);
|
||||||
|
substr = rb_str_subseq(str, i, n);
|
||||||
if (wantarray)
|
if (wantarray)
|
||||||
rb_ary_push(ary, rb_str_subseq(str, i, n));
|
rb_ary_push(ary, substr);
|
||||||
else
|
else
|
||||||
rb_yield(rb_str_subseq(str, i, n));
|
rb_yield(substr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
for (i = 0; i < len; i += n) {
|
for (i = 0; i < len; i += n) {
|
||||||
n = rb_enc_mbclen(ptr + i, ptr + len, enc);
|
n = rb_enc_mbclen(ptr + i, ptr + len, enc);
|
||||||
|
substr = rb_str_subseq(str, i, n);
|
||||||
if (wantarray)
|
if (wantarray)
|
||||||
rb_ary_push(ary, rb_str_subseq(str, i, n));
|
rb_ary_push(ary, substr);
|
||||||
else
|
else
|
||||||
rb_yield(rb_str_subseq(str, i, n));
|
rb_yield(substr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RB_GC_GUARD(str);
|
||||||
if (wantarray)
|
if (wantarray)
|
||||||
return ary;
|
return ary;
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user