ruby-changes:47111
From: usa <ko1@a...>
Date: Fri, 30 Jun 2017 20:24:47 +0900 (JST)
Subject: [ruby-changes:47111] usa:r59226 (ruby_2_3): merge revision(s) 58825, 58826: [Backport #5339]
usa 2017-06-30 20:24:41 +0900 (Fri, 30 Jun 2017) New Revision: 59226 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59226 Log: merge revision(s) 58825,58826: [Backport #5339] erb.rb: Allow explicit trimming carriage return when trim_mode is "-", for Windows environments. [ruby-core:39625] [Bug #5339] erb.rb: Allow trimming CR in all trim_modes to unify a behavior with r58823 and r58825. Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/lib/erb.rb branches/ruby_2_3/test/erb/test_erb.rb branches/ruby_2_3/version.h Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 59225) +++ ruby_2_3/version.h (revision 59226) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.5" #define RUBY_RELEASE_DATE "2017-06-30" -#define RUBY_PATCHLEVEL 322 +#define RUBY_PATCHLEVEL 323 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 6 Index: ruby_2_3/lib/erb.rb =================================================================== --- ruby_2_3/lib/erb.rb (revision 59225) +++ ruby_2_3/lib/erb.rb (revision 59226) @@ -429,10 +429,10 @@ class ERB https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/erb.rb#L429 end def trim_line1(line) - line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens| + line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\r?\n|%>|\n|\z)/m) do |tokens| tokens.each do |token| next if token.empty? - if token == "%>\n" + if token == "%>\n" || token == "%>\r\n" yield('%>') yield(:cr) else @@ -465,12 +465,12 @@ class ERB https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/erb.rb#L465 end def explicit_trim_line(line) - line.scan(/(.*?)(^[ \t]*<%\-|<%\-|<%%|%%>|<%=|<%#|<%|-%>\n|-%>|%>|\z)/m) do |tokens| + line.scan(/(.*?)(^[ \t]*<%\-|<%\-|<%%|%%>|<%=|<%#|<%|-%>\r?\n|-%>|%>|\z)/m) do |tokens| tokens.each do |token| next if token.empty? if @stag.nil? && /[ \t]*<%-/ =~ token yield('<%') - elsif @stag && token == "-%>\n" + elsif @stag && token == "-%>\n" || token == "-%>\r\n" yield('%>') yield(:cr) elsif @stag && token == '-%>' @@ -533,7 +533,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/ruby_2_3/lib/erb.rb#L533 yield('<%') elsif elem == '-%>' yield('%>') - yield(:cr) if scanner.scan(/(\n|\z)/) + yield(:cr) if scanner.scan(/(\r?\n|\z)/) else yield(elem) end Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 59225) +++ ruby_2_3/ChangeLog (revision 59226) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Fri Jun 30 20:23:31 2017 Takashi Kokubun <takashikkbn@g...> + + * lib/erb.rb: Allow explicit trimming carriage return when trim_mode is + "-", for Windows environments. [Bug #5339] + + * lib/erb.rb: Allow trimming CR in all trim_modes to unify a behavior + with r58823 and r58825. + Fri Jun 30 20:16:15 2017 Takashi Kokubun <takashikkbn@g...> * lib/erb.rb: Allow trimming carriage return when trim_mode is "<>", for Index: ruby_2_3/test/erb/test_erb.rb =================================================================== --- ruby_2_3/test/erb/test_erb.rb (revision 59225) +++ ruby_2_3/test/erb/test_erb.rb (revision 59226) @@ -200,6 +200,17 @@ EOS https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/erb/test_erb.rb#L200 def test_trim_line2_with_carriage_return erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", nil, '<>') assert_equal("line\r\n" * 3, erb.result) + + erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", nil, '%<>') + assert_equal("line\r\n" * 3, erb.result) + end + + def test_explicit_trim_line_with_carriage_return + erb = @erb.new("<%- 3.times do -%>\r\nline\r\n<%- end -%>\r\n", nil, '-') + assert_equal("line\r\n" * 3, erb.result) + + erb = @erb.new("<%- 3.times do -%>\r\nline\r\n<%- end -%>\r\n", nil, '%-') + assert_equal("line\r\n" * 3, erb.result) end class Foo; end Index: ruby_2_3 =================================================================== --- ruby_2_3 (revision 59225) +++ ruby_2_3 (revision 59226) Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r58825 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/