mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_each_char): return original string.
[ruby-core:23499] * string.c (rb_str_each_codepoint): protect string from modification. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
34cf45ab19
commit
0fd3bdac6a
2 changed files with 13 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
Sat May 23 23:52:33 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_each_char): return original string.
|
||||
[ruby-core:23499]
|
||||
|
||||
* string.c (rb_str_each_codepoint): protect string from
|
||||
modification.
|
||||
|
||||
Sat May 23 21:48:58 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/dl/handle.c (rb_dlhandle_s_sym): added a method to access
|
||||
|
|
7
string.c
7
string.c
|
@ -5925,6 +5925,7 @@ rb_str_each_byte(VALUE str)
|
|||
static VALUE
|
||||
rb_str_each_char(VALUE str)
|
||||
{
|
||||
VALUE orig = str;
|
||||
int i, len, n;
|
||||
const char *ptr;
|
||||
rb_encoding *enc;
|
||||
|
@ -5948,7 +5949,7 @@ rb_str_each_char(VALUE str)
|
|||
rb_yield(rb_str_subseq(str, i, n));
|
||||
}
|
||||
}
|
||||
return str;
|
||||
return orig;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5984,6 +5985,7 @@ rb_str_each_char(VALUE str)
|
|||
static VALUE
|
||||
rb_str_each_codepoint(VALUE str)
|
||||
{
|
||||
VALUE orig = str;
|
||||
int len, n;
|
||||
unsigned int c;
|
||||
const char *ptr, *end;
|
||||
|
@ -5991,6 +5993,7 @@ rb_str_each_codepoint(VALUE str)
|
|||
|
||||
if (single_byte_optimizable(str)) return rb_str_each_byte(str);
|
||||
RETURN_ENUMERATOR(str, 0, 0);
|
||||
str = rb_str_new4(str);
|
||||
ptr = RSTRING_PTR(str);
|
||||
len = RSTRING_LEN(str);
|
||||
end = RSTRING_END(str);
|
||||
|
@ -6000,7 +6003,7 @@ rb_str_each_codepoint(VALUE str)
|
|||
rb_yield(UINT2NUM(c));
|
||||
ptr += n;
|
||||
}
|
||||
return str;
|
||||
return orig;
|
||||
}
|
||||
|
||||
static long
|
||||
|
|
Loading…
Reference in a new issue