diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-25 23:50:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-25 23:50:09 +0000 |
commit | da1a1f0b6ed0b0c4284684452da4f6f290be8057 (patch) | |
tree | ce70c76d604fab1f10b157802cd0bd70ffe13508 /string.c | |
parent | c5850485042cf0e591e940c2687e6af719502e88 (diff) | |
download | ruby-da1a1f0b6ed0b0c4284684452da4f6f290be8057.tar.gz |
string.c: consistent paragraph mode with IO
* string.c (rb_str_enumerate_lines): in paragraph mode, do not
include newlines which separate paragraphs, so that it will be
consistent with IO#each_line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -7511,18 +7511,17 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, int wantarray) subptr = adjusted; continue; } - subend = hit + rslen; + subend = hit += rslen; if (paragraph_mode) { - while (subend < pend) { + while (hit < pend) { int n; - if (rb_enc_ascget(subend, pend, &n, enc) != '\r') + if (rb_enc_ascget(hit, pend, &n, enc) != '\r') n = 0; - if (!rb_enc_is_newline(subend + n, pend, enc)) break; - subend += n; - subend += rb_enc_mbclen(subend, pend, enc); + if (!rb_enc_is_newline(hit + n, pend, enc)) break; + hit += n; + hit += rb_enc_mbclen(hit, pend, enc); } } - hit = subend; if (chomp) { if (rsnewline) { subend = chomp_newline(subptr, subend, enc); @@ -7591,7 +7590,7 @@ rb_str_enumerate_lines(int argc, VALUE *argv, VALUE str, int wantarray) * "o\nworl" * "d" * Example three - * "hello\n\n\n" + * "hello\n\n" * "world" */ |