1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (rb_str_each_line): zero length record separator should

split a string into paragraphs.  [ruby-dev:34586]

* string.c (rb_str_each_line): RDoc updated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-05-10 09:17:59 +00:00
parent 332529d45a
commit 9139a48f0e
3 changed files with 17 additions and 6 deletions

View file

@ -1,3 +1,10 @@
Sat May 10 18:11:18 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_each_line): zero length record separator should
split a string into paragraphs. [ruby-dev:34586]
* string.c (rb_str_each_line): RDoc updated.
Sat May 10 11:36:20 2008 Tanaka Akira <akr@fsij.org>
* vm.c (env_mark): mark env->block.self. prevent SEGV when GC occur

View file

@ -5018,9 +5018,8 @@ rb_str_split(VALUE str, const char *sep0)
*
* Splits <i>str</i> using the supplied parameter as the record separator
* (<code>$/</code> by default), passing each substring in turn to the supplied
* block. If a zero-length record separator is supplied, the string is split on
* <code>\n</code> characters, except that multiple successive newlines are
* appended together.
* block. If a zero-length record separator is supplied, the string is split
* into paragraphs delimited by multiple successive newlines.
*
* print "Example one\n"
* "hello\nworld".each {|s| p s}
@ -5107,8 +5106,13 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
while (p < pend) {
int c = rb_enc_codepoint(p, pend, enc);
again:
n = rb_enc_codelen(c, enc);
if (rslen == 0 && c == newline) {
p += n;
if (p < pend && (c = rb_enc_codepoint(p, pend, enc)) != newline) {
goto again;
}
while (p < pend && rb_enc_codepoint(p, pend, enc) == newline) {
p += n;
}

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2008-05-09"
#define RUBY_RELEASE_DATE "2008-05-10"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20080509
#define RUBY_RELEASE_CODE 20080510
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 5
#define RUBY_RELEASE_DAY 9
#define RUBY_RELEASE_DAY 10
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];