diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-07 22:23:38 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-07 22:23:38 +0000 |
commit | ba6ae341bab83dfc7a624c5bf20d8d162dacaff9 (patch) | |
tree | 540581a54cefcdc817577f646f09372f7e9936d1 /lib/rdoc/encoding.rb | |
parent | bf51c067b92361007a57909c539591d3d00cdbd8 (diff) |
* lib/rdoc/*, test/rdoc/*: Update rdoc-5.0.0.beta2
Fixed ri parse defect with left-hand matched classes.
https://github.com/rdoc/rdoc/pull/420
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/encoding.rb')
-rw-r--r-- | lib/rdoc/encoding.rb | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/lib/rdoc/encoding.rb b/lib/rdoc/encoding.rb index 1056827937..44881d043c 100644 --- a/lib/rdoc/encoding.rb +++ b/lib/rdoc/encoding.rb @@ -25,43 +25,41 @@ module RDoc::Encoding RDoc::Encoding.set_encoding content - if Object.const_defined? :Encoding then - begin - encoding ||= Encoding.default_external - orig_encoding = content.encoding - - if not orig_encoding.ascii_compatible? then - content.encode! encoding - elsif utf8 then - content.force_encoding Encoding::UTF_8 - content.encode! encoding - else - # assume the content is in our output encoding - content.force_encoding encoding - end - - unless content.valid_encoding? then - # revert and try to transcode - content.force_encoding orig_encoding - content.encode! encoding - end - - unless content.valid_encoding? then - warn "unable to convert #{filename} to #{encoding}, skipping" - content = nil - end - rescue Encoding::InvalidByteSequenceError, - Encoding::UndefinedConversionError => e - if force_transcode then - content.force_encoding orig_encoding - content.encode!(encoding, - :invalid => :replace, :undef => :replace, - :replace => '?') - return content - else - warn "unable to convert #{e.message} for #{filename}, skipping" - return nil - end + begin + encoding ||= Encoding.default_external + orig_encoding = content.encoding + + if not orig_encoding.ascii_compatible? then + content.encode! encoding + elsif utf8 then + content.force_encoding Encoding::UTF_8 + content.encode! encoding + else + # assume the content is in our output encoding + content.force_encoding encoding + end + + unless content.valid_encoding? then + # revert and try to transcode + content.force_encoding orig_encoding + content.encode! encoding + end + + unless content.valid_encoding? then + warn "unable to convert #{filename} to #{encoding}, skipping" + content = nil + end + rescue Encoding::InvalidByteSequenceError, + Encoding::UndefinedConversionError => e + if force_transcode then + content.force_encoding orig_encoding + content.encode!(encoding, + :invalid => :replace, :undef => :replace, + :replace => '?') + return content + else + warn "unable to convert #{e.message} for #{filename}, skipping" + return nil end end @@ -103,11 +101,8 @@ module RDoc::Encoding remove_frozen_string_literal string - return unless Object.const_defined? :Encoding - enc = Encoding.find name string.force_encoding enc if enc end end - |