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

fix an issue that rdoc fails when running on Windows with RUBYOPT=-U #430

Merged
merged 2 commits into from Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rdoc/generator/json_index.rb
Expand Up @@ -170,7 +170,7 @@ def generate_gzipped
outfile = out_dir + "#{search_index_file}.gz"

debug_msg "Reading the JSON index file from %s" % search_index_file
search_index = search_index_file.read
search_index = search_index_file.read(mode: 'r:utf-8')

debug_msg "Writing gzipped search index to %s" % outfile

Expand Down
6 changes: 4 additions & 2 deletions lib/rdoc/parser.rb
Expand Up @@ -78,7 +78,7 @@ def self.binary?(file)

return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index("\x00")

mode = "r"
mode = 'r:utf-8' # default source encoding has been chagened to utf-8
s.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
encoding = s[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*([^\s;]+?)(?:-\*-|[\s;])/, 1]
mode = "rb:#{encoding}" if encoding
Expand Down Expand Up @@ -180,7 +180,9 @@ def self.check_modeline file_name
return nil if /coding:/i =~ type

type.downcase
rescue ArgumentError # invalid byte sequence, etc.
rescue ArgumentError
rescue Encoding::InvalidByteSequenceError # invalid byte sequence

end

##
Expand Down