From 9139a48f0e661cb6342f05102fa8afe53fbc0960 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 10 May 2008 09:17:59 +0000 Subject: [PATCH] * 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 --- ChangeLog | 7 +++++++ string.c | 10 +++++++--- version.h | 6 +++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ea3a2ca63..c103715057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat May 10 18:11:18 2008 Yukihiro Matsumoto + + * 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 * vm.c (env_mark): mark env->block.self. prevent SEGV when GC occur diff --git a/string.c b/string.c index 8d4910291f..3c8cdd3f0b 100644 --- a/string.c +++ b/string.c @@ -5018,9 +5018,8 @@ rb_str_split(VALUE str, const char *sep0) * * Splits str using the supplied parameter as the record separator * ($/ by default), passing each substring in turn to the supplied - * block. If a zero-length record separator is supplied, the string is split on - * \n 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; } diff --git a/version.h b/version.h index b36ed6cc4f..351f4e1e46 100644 --- a/version.h +++ b/version.h @@ -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[];