[前][次][番号順一覧][スレッド一覧]

ruby-changes:49513

From: naruse <ko1@a...>
Date: Sat, 6 Jan 2018 05:39:07 +0900 (JST)
Subject: [ruby-changes:49513] naruse:r61628 (ruby_2_5): merge revision(s) 61513: [Backport #14257]

naruse	2018-01-06 05:39:03 +0900 (Sat, 06 Jan 2018)

  New Revision: 61628

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61628

  Log:
    merge revision(s) 61513: [Backport #14257]
    
    string.c: chomp rs at the end
    
    * string.c (rb_str_enumerate_lines): should chomp record separator
      only, but not a newline, at the end of the receiver as well as
      middle, if the separator is given.
      [ruby-core:84552] [Bug #14257]

  Modified directories:
    branches/ruby_2_5/
  Modified files:
    branches/ruby_2_5/string.c
    branches/ruby_2_5/test/ruby/test_string.rb
    branches/ruby_2_5/version.h
Index: ruby_2_5/string.c
===================================================================
--- ruby_2_5/string.c	(revision 61627)
+++ ruby_2_5/string.c	(revision 61628)
@@ -8012,7 +8012,12 @@ rb_str_enumerate_lines(int argc, VALUE * https://github.com/ruby/ruby/blob/trunk/ruby_2_5/string.c#L8012
 
     if (subptr != pend) {
 	if (chomp) {
-	    pend = chomp_newline(subptr, pend, enc);
+	    if (rsnewline) {
+		pend = chomp_newline(subptr, pend, enc);
+	    }
+	    else if (memcmp(pend - rslen, rsptr, rslen) == 0) {
+		pend -= rslen;
+	    }
 	}
 	line = rb_str_subseq(str, subptr - ptr, pend - subptr);
 	ENUM_ELEM(ary, line);
Index: ruby_2_5/version.h
===================================================================
--- ruby_2_5/version.h	(revision 61627)
+++ ruby_2_5/version.h	(revision 61628)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_5/version.h#L1
 #define RUBY_VERSION "2.5.0"
-#define RUBY_RELEASE_DATE "2018-01-04"
-#define RUBY_PATCHLEVEL 6
+#define RUBY_RELEASE_DATE "2018-01-06"
+#define RUBY_PATCHLEVEL 7
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 4
+#define RUBY_RELEASE_DAY 6
 
 #include "ruby/version.h"
 
Index: ruby_2_5/test/ruby/test_string.rb
===================================================================
--- ruby_2_5/test/ruby/test_string.rb	(revision 61627)
+++ ruby_2_5/test/ruby/test_string.rb	(revision 61628)
@@ -1119,6 +1119,10 @@ CODE https://github.com/ruby/ruby/blob/trunk/ruby_2_5/test/ruby/test_string.rb#L1119
     res = []
     S("\r\n").each_line(chomp: true) {|x| res << x}
     assert_equal([S("")], res)
+
+    res = []
+    S("a\n b\n").each_line(" ", chomp: true) {|x| res << x}
+    assert_equal([S("a\n"), S("b\n")], res)
   end
 
   def test_lines
Index: ruby_2_5
===================================================================
--- ruby_2_5	(revision 61627)
+++ ruby_2_5	(revision 61628)

Property changes on: ruby_2_5
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r61513

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]