Skip to content

Commit

Permalink
Merge pull request #430 from dogatana/fix_Encdoing_error_on_Windows
Browse files Browse the repository at this point in the history
fix an issue that rdoc fails when running on Windows with RUBYOPT=-U
  • Loading branch information
hsbt committed Jan 18, 2017
2 parents 663c117 + b1490dd commit b59ca37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit b59ca37

Please sign in to comment.