зеркало из https://github.com/github/ruby.git
* string.c (rb_str_each_char): iterates over a shadow.
[ruby-dev:33243] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
02f4dcca2c
Коммит
157664b9f3
|
@ -1,3 +1,8 @@
|
|||
Tue Jan 22 09:26:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_each_char): iterates over a shadow.
|
||||
[ruby-dev:33243]
|
||||
|
||||
Tue Jan 22 08:59:52 2008 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc/ri/formatter.rb: Indent labeled lists like note lists.
|
||||
|
|
13
string.c
13
string.c
|
@ -4609,22 +4609,17 @@ static VALUE
|
|||
rb_str_each_char(VALUE str)
|
||||
{
|
||||
int i, len, n;
|
||||
const char *ptr, *s;
|
||||
const char *ptr;
|
||||
rb_encoding *enc;
|
||||
|
||||
RETURN_ENUMERATOR(str, 0, 0);
|
||||
str = rb_str_new4(str);
|
||||
ptr = RSTRING_PTR(str);
|
||||
len = RSTRING_LEN(str);
|
||||
enc = rb_enc_get(str);
|
||||
n = rb_enc_mbclen(ptr, ptr + len, enc);
|
||||
for (i = 0; i < len;) {
|
||||
for (i = 0; i < len; i += n) {
|
||||
n = rb_enc_mbclen(ptr + i, ptr + len, enc);
|
||||
rb_yield(rb_str_subseq(str, i, n));
|
||||
ptr = RSTRING_PTR(str);
|
||||
len = RSTRING_LEN(str);
|
||||
if ((i += n) >= len) break;
|
||||
enc = rb_enc_get(str);
|
||||
s = rb_enc_right_char_head(ptr, ptr + i, enc);
|
||||
n = rb_enc_mbclen(s, ptr + len, enc);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче