ruby-changes:1798
From: ko1@a...
Date: 27 Aug 2007 23:32:27 +0900
Subject: [ruby-changes:1798] matz - Ruby:r13289 (trunk): * string.c (rb_str_each_line): should swallow sequence of newlines
matz 2007-08-27 23:32:15 +0900 (Mon, 27 Aug 2007)
New Revision: 13289
Modified files:
trunk/ChangeLog
trunk/string.c
Log:
* string.c (rb_str_each_line): should swallow sequence of newlines
if rs (optional argument) is an empty string. [ruby-dev:31652]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/string.c?r1=13289&r2=13288
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13289&r2=13288
Index: ChangeLog
===================================================================
--- ChangeLog (revision 13288)
+++ ChangeLog (revision 13289)
@@ -2,6 +2,9 @@
* string.c (rb_str_rstrip_bang): wrong strip point. [ruby-dev:31652]
+ * string.c (rb_str_each_line): should swallow sequence of newlines
+ if rs (optional argument) is an empty string. [ruby-dev:31652]
+
Mon Aug 27 22:39:08 2007 Yukihiro Matsumoto <matz@r...>
* encoding.c (rb_enc_codelen): raises invalid sequence exception
Index: string.c
===================================================================
--- string.c (revision 13288)
+++ string.c (revision 13289)
@@ -3919,6 +3919,12 @@
int c = rb_enc_codepoint(p, pend, enc);
int n = rb_enc_codelen(c, enc);
+ if (rslen == 0 && c == newline) {
+ while (rb_enc_codepoint(p, pend, enc) == newline) {
+ p += n;
+ }
+ p -= n;
+ }
if (c == newline &&
(rslen <= 1 || rb_memcmp(RSTRING_PTR(rs), p, rslen) == 0)) {
line = rb_str_new5(str, s, p - s + (rslen ? rslen : n));
@@ -3989,7 +3995,7 @@
* Returns an enumerator that gives each character in the string.
* If a block is given, it iterates over each character in the string.
*
- * "foo".lines.to_a #=> ["f","o","o"]
+ * "foo".chars.to_a #=> ["f","o","o"]
*/
/*
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml