ruby-changes:3676
From: ko1@a...
Date: Tue, 22 Jan 2008 09:27:04 +0900 (JST)
Subject: [ruby-changes:3676] nobu - Ruby:r15165 (trunk): * string.c (rb_str_each_char): iterates over a shadow.
nobu 2008-01-22 09:26:49 +0900 (Tue, 22 Jan 2008)
New Revision: 15165
Modified files:
trunk/ChangeLog
trunk/string.c
Log:
* string.c (rb_str_each_char): iterates over a shadow.
[ruby-dev:33243]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=15165&r2=15164&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15165&r2=15164&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15164)
+++ ChangeLog (revision 15165)
@@ -1,3 +1,8 @@
+Tue Jan 22 09:26:47 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * string.c (rb_str_each_char): iterates over a shadow.
+ [ruby-dev:33243]
+
Tue Jan 22 08:59:52 2008 Eric Hodel <drbrain@s...>
* lib/rdoc/ri/formatter.rb: Indent labeled lists like note lists.
Index: string.c
===================================================================
--- string.c (revision 15164)
+++ string.c (revision 15165)
@@ -4609,22 +4609,17 @@
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;
}
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/