mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rdoc/parser.rb (RDoc::Parser.binary?): blksize may be nil
and is irrelevant to whether a file is binary. TAB and newlines would be usually considered to be included in text data. reapplied r23071 and r24297. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5bdee08c1e
commit
06adf90ab6
2 changed files with 9 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
Fri Apr 2 14:12:24 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/rdoc/parser.rb (RDoc::Parser.binary?): blksize may be nil
|
||||
and is irrelevant to whether a file is binary. TAB and newlines
|
||||
would be usually considered to be included in text data.
|
||||
reapplied r23071 and r24297.
|
||||
|
||||
Fri Apr 2 13:59:17 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/rdoc/ri/paths.rb (RDoc::RI::Paths): Gem::Enable has been
|
||||
|
|
|
@ -67,7 +67,7 @@ class RDoc::Parser
|
|||
# content that an RDoc parser shouldn't try to consume.
|
||||
|
||||
def self.binary?(file)
|
||||
s = File.read(file, File.stat(file).blksize || 1024) || ""
|
||||
s = File.read(file, 1024) or return false
|
||||
|
||||
if s[0, 2] == Marshal.dump('')[0, 2] then
|
||||
true
|
||||
|
@ -76,10 +76,7 @@ class RDoc::Parser
|
|||
elsif s.scan(/<%|%>/).length >= 4 then
|
||||
true
|
||||
else
|
||||
# From ptools under the Artistic License 2.0, (c) Daniel Berger.
|
||||
s = s.split(//)
|
||||
|
||||
((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
|
||||
s.count("^ -~\t\r\n").fdiv(s.size) > 0.3 || s.index("\x00")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue