diff options
Diffstat (limited to 'lib/rdoc')
-rw-r--r-- | lib/rdoc/parser.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index e1b264bffa..a5c7de663f 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -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 |