Skip to content

Commit 65bb622

Browse files
committed
Fix expand_tabs for 1.9.1
1 parent 36feda5 commit 65bb622

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/rdoc/text.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ def self.encode_fallback character, encoding, fallback
4444
def expand_tabs text
4545
expanded = []
4646

47-
space = ' '
48-
space.force_encoding text.encoding if Object.const_defined? :Encoding
49-
5047
text.each_line do |line|
5148
line.gsub!(/^(.{8}*?)([^\t\r\n]{0,7})\t/) do
52-
"#{$1}#{$2}#{space * (8 - $2.size)}"
49+
r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
50+
r.force_encoding text.encoding if Object.const_defined? :Encoding
51+
r
5352
end until line !~ /\t/
5453

5554
expanded << line

test/test_rdoc_encoding.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def test_class_read_file_encoding_fail
6666

6767
assert_nil contents
6868

69-
assert_match %r%^unable to convert U\+03C0 from UTF-8 to US-ASCII for%, err
69+
assert_match %r%^unable to convert%, err
7070
end
7171

7272
def test_class_read_file_encoding_fancy

0 commit comments

Comments
 (0)