Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You should rectify the line delimeters immediately after reading a file, if you continue using binmode. #87

Closed
unak opened this issue Nov 7, 2011 · 2 comments

Comments

@unak
Copy link
Member

unak commented Nov 7, 2011

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 (<i>regexp</i>s) 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

@unak
Copy link
Member Author

unak commented Nov 30, 2011

r33902 of MRI

@drbrain
Copy link
Member

drbrain commented Dec 8, 2011

Thank you for the patch, it was easy to apply.

@drbrain drbrain closed this as completed Dec 8, 2011
drbrain added a commit that referenced this issue Dec 8, 2011
szuecs referenced this issue in szuecs/ruby Dec 11, 2013
  on Windows.
  see https://github.com/rdoc/rdoc/issues/87

* test/rdoc/test_rdoc_markup_pre_process.rb
  (TestRDocMarkupPreProcess#test_include_file, 
  TestRDocMarkupPreProcess#test_include_file_encoding_incompatible):
  follow above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
tenderlove referenced this issue in tenderlove/ruby Jan 24, 2014
  on Windows.
  see https://github.com/rdoc/rdoc/issues/87

* test/rdoc/test_rdoc_markup_pre_process.rb
  (TestRDocMarkupPreProcess#test_include_file, 
  TestRDocMarkupPreProcess#test_include_file_encoding_incompatible):
  follow above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants