rdoc/rdoc — Issue #87: You should rectify the line delimeters immediately after reading a file, if you continue using binmode.
Author: unak
Created: 2011-11-07 02:46:01+00:00
State: open

# this patch is for MRI, not for rdoc. sorry.

Index: lib/rdoc/encoding.rb
===================================================================
--- lib/rdoc/encoding.rb	(revision 33648)
+++ lib/rdoc/encoding.rb	(working copy)
@@ -20,6 +20,7 @@ module RDoc::Encoding

def self.read_file filename, encoding, force_transcode = false
content = open filename, "rb" do |f| f.read end
+ content.gsub!("\r\n", "\n") if RUBY_PLATFORM =~ /mswin|mingw/

utf8 = content.sub!(/\A\xef\xbb\xbf/, '')

Index: test/rdoc/test_rdoc_markup_pre_process.rb
===================================================================
--- test/rdoc/test_rdoc_markup_pre_process.rb	(revision 33648)
+++ test/rdoc/test_rdoc_markup_pre_process.rb	(working copy)
@@ -43,11 +43,6 @@ Regular expressions (regexps) are
contents of a string.
EXPECTED

- # FIXME 1.9 fix on windoze
- # preprocessor uses binread, so line endings are \r\n
- expected.gsub!("\n", "\r\n") if
- RUBY_VERSION < "1.9.3" && RUBY_PLATFORM =~ /mswin|mingw/
-
assert_equal expected, content
end

@@ -67,11 +62,6 @@ contents of a string.

expected = "?\n"

- # FIXME 1.9 fix on windoze
- # preprocessor uses binread, so line endings are \r\n
- expected.gsub!("\n", "\r\n") if
- RUBY_VERSION < "1.9.3" && RUBY_PLATFORM =~ /mswin|mingw/
-
assert_equal expected, content
end