Permalink
Browse files

Fix a crash when rdoc is told a parse an empty file.

  • Loading branch information...
1 parent 936c13d commit b11fdb53359a9f8cc0f547eedaf600c088baec02 designingpatts committed Oct 21, 2008
Showing with 15 additions and 2 deletions.
  1. +1 −0 History.txt
  2. +1 −1 lib/rdoc.rb
  3. +13 −1 lib/rdoc/parser.rb
View
@@ -9,6 +9,7 @@
* Z Bug Fixes
* Fix missing superclass in ri output.
+ * Fix an rdoc crash when told to parse an empty file.
=== 2.2.1 / 2008-09-24
This version provides some minor fixes and enhancements to 2.2.0 intended
View
@@ -372,7 +372,7 @@ class Error < RuntimeError; end
##
# RDoc version you are using
- VERSION = "2.2.1"
+ VERSION = "2.2.2"
##
# Name of the dotfile that contains the description of files to be processed
View
@@ -68,7 +68,12 @@ def self.alias_extension(old_ext, new_ext)
def self.binary?(file)
s = (File.read(file, File.stat(file).blksize) || "").split(//)
- ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
+
+ if s.size > 0 then
+ ((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
+ else
+ false
+ end
end
private_class_method :binary?
@@ -106,6 +111,13 @@ def self.for(top_level, file_name, body, options, stats)
parser = can_parse file_name
+ #
+ # This method must return a parser.
+ #
+ if !parser then
+ parser = RDoc::Parser::Simple
+ end
+
parser.new top_level, file_name, body, options, stats
end

0 comments on commit b11fdb5

Please sign in to comment.