mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
rdoc: non-binary multibyte
* lib/rdoc/parser.rb (RDoc.binary?): binary read data may have incomplete multibyte sequence. [ruby-core:44798][Bug #6393] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
19be9a8d80
commit
1348e3b9ac
4 changed files with 11 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri May 4 01:31:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/rdoc/parser.rb (RDoc.binary?): binary read data may have
|
||||
incomplete multibyte sequence. [ruby-core:44798][Bug #6393]
|
||||
|
||||
Wed May 2 23:55:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/test/unit.rb (Test::Unit::RequireFiles#non_options): expand
|
||||
|
|
|
@ -80,14 +80,14 @@ class RDoc::Parser
|
|||
|
||||
have_encoding = s.respond_to? :encoding
|
||||
|
||||
if have_encoding then
|
||||
return false if s.encoding != Encoding::ASCII_8BIT and s.valid_encoding?
|
||||
end
|
||||
|
||||
return true if s[0, 2] == Marshal.dump('')[0, 2] or s.index("\x00")
|
||||
|
||||
if have_encoding then
|
||||
s.force_encoding Encoding.default_external
|
||||
mode = "r"
|
||||
s.sub!(/\A#!.*\n/, '') # assume shebang line isn't longer than 1024.
|
||||
encoding = s[/^\s*\#\s*(?:-\*-\s*)?(?:en)?coding:\s*\([^\s;]+?\)(?:-\*-)?/, 1]
|
||||
mode = "r:#{encoding}" if encoding
|
||||
s = File.open(file, mode) {|f| f.gets(nil, 1024)}
|
||||
|
||||
not s.valid_encoding?
|
||||
else
|
||||
|
|
|
@ -29,7 +29,7 @@ class TestRDocParser < MiniTest::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_class_binary_large_japanese_rdoc
|
||||
file_name = File.expand_path '../test.ja.large.rdoc', __FILE__
|
||||
file_name = File.expand_path '../test.ja.largedoc', __FILE__
|
||||
assert !@RP.binary?(file_name)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue