From d65000915192052ea5a54ece9b001a0a84aa6c4c Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 30 Jan 2015 07:13:13 +0000 Subject: merge revision(s) 49223: [Backport #10732] * lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with CR. should check if substitution occurred too. [ruby-dev:48813] [Bug #10732] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@49445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/rdoc/text.rb | 4 ++-- test/rdoc/test_rdoc_text.rb | 3 +++ version.h | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index aed3eca61b..cbc3fd6848 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 30 16:11:47 2015 Nobuyoshi Nakada + + * lib/rdoc/text.rb (expand_tabs): get rid of infinite loop with + CR. should check if substitution occurred too. + [ruby-dev:48813] [Bug #10732] + Fri Jan 30 16:00:35 2015 Nobuyoshi Nakada * lib/mkmf.rb (install_dirs): revert DESTDIR prefix by r39841, since diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index c731dde097..46b53276b5 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -68,11 +68,11 @@ module RDoc::Text expanded = [] text.each_line do |line| - line.gsub!(/^((?:.{8})*?)([^\t\r\n]{0,7})\t/) do + nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" r.force_encoding text.encoding if Object.const_defined? :Encoding r - end until line !~ /\t/ + end expanded << line end diff --git a/test/rdoc/test_rdoc_text.rb b/test/rdoc/test_rdoc_text.rb index 473bd3cadd..9e0ec6fe94 100644 --- a/test/rdoc/test_rdoc_text.rb +++ b/test/rdoc/test_rdoc_text.rb @@ -63,6 +63,9 @@ class TestRDocText < RDoc::TestCase assert_equal('. .', expand_tabs(".\t\t."), 'dot tab tab dot') + + assert_equal('a a', + Timeout.timeout(1) {expand_tabs("\ra\ta")}, "carriage return") end def test_expand_tabs_encoding diff --git a/version.h b/version.h index 1659e8e381..3b636afa1b 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2015-01-30" -#define RUBY_PATCHLEVEL 625 +#define RUBY_PATCHLEVEL 626 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 -- cgit v1.2.3