Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prevent ri from crashing when looking up a bogus method.

Fix an infinite loop that I introduced.
Fix a missing parameter in the C parser.
  • Loading branch information...
commit 21aed02dc7133258fb023a84b6993fbc6309c1b5 1 parent f4cd41e
designingpatts authored
View
2  History.txt
@@ -24,6 +24,8 @@ to polish RDoc for Ruby 1.9.1.
depending on the order in which RDoc processed the files. This should
ensure that the child class -> parent class relationship is correct in
ri documentation, allowing ri to lookup inherited methods (i.e., File#read).
+ * Stop ri from crashing when it looks for a completely bogus method (i.e.,
+ File#reada). Now, ri exits with a helpful error message.
=== 2.2.0 / 2008-09-19
This version includes some significant enhancements to ri. See RI.txt for
View
20 lib/rdoc/code_objects.rb
@@ -319,7 +319,7 @@ def add_method(a_method)
unmatched_alias_list = @unmatched_alias_lists[a_method.name]
if unmatched_alias_list then
unmatched_alias_list.each do |unmatched_alias|
- add_alias unmatched_alias
+ add_alias_impl unmatched_alias, a_method
@aliases.delete unmatched_alias
end
@@ -331,17 +331,21 @@ def add_attribute(an_attribute)
add_to(@attributes, an_attribute)
end
+ def add_alias_impl(an_alias, meth)
+ new_meth = AnyMethod.new(an_alias.text, an_alias.new_name)
+ new_meth.is_alias_for = meth
+ new_meth.singleton = meth.singleton
+ new_meth.params = meth.params
+ new_meth.comment = "Alias for \##{meth.name}"
+ meth.add_alias(new_meth)
+ add_method(new_meth)
+ end
+
def add_alias(an_alias)
meth = find_instance_method_named(an_alias.old_name)
if meth then
- new_meth = AnyMethod.new(an_alias.text, an_alias.new_name)
- new_meth.is_alias_for = meth
- new_meth.singleton = meth.singleton
- new_meth.params = meth.params
- new_meth.comment = "Alias for \##{meth.name}"
- meth.add_alias(new_meth)
- add_method(new_meth)
+ add_alias_impl(an_alias, meth)
else
add_to(@aliases, an_alias)
unmatched_alias_list = @unmatched_alias_lists[an_alias.old_name] ||= []
View
2  lib/rdoc/parser/c.rb
@@ -302,7 +302,7 @@ def find_body(class_name, meth_name, meth_obj, body, quiet = false)
find_modifiers(comment, meth_obj)
meth_obj.comment = mangle_comment(comment) + meth_obj.comment
when %r{^\s*\#\s*define\s+#{meth_name}\s+(\w+)}m
- unless find_body($1, meth_obj, body, true)
+ unless find_body(class_name, $1, meth_obj, body, true)
warn "No definition for #{meth_name}" unless @options.quiet
return false
end
View
16 lib/rdoc/ri/driver.rb
@@ -522,6 +522,13 @@ def create_cache_for(klassname, path)
# Finds the next ancestor of +orig_klass+ after +klass+.
def lookup_ancestor(klass, orig_klass)
+ # This is a bit hacky, but ri will go into an infinite
+ # loop otherwise, since Object has an Object ancestor
+ # for some reason.
+ if ((klass == "Kernel") && (orig_klass == "Object"))
+ return nil
+ end
+
cache = class_cache[orig_klass]
return nil unless cache
@@ -529,10 +536,13 @@ def lookup_ancestor(klass, orig_klass)
ancestors = [orig_klass]
ancestors.push(*cache.includes.map { |inc| inc['name'] })
ancestors << cache.superclass
+
+ ancestor_index = ancestors.index(klass)
- ancestor = ancestors[ancestors.index(klass) + 1]
-
- return ancestor if ancestor
+ if ancestor_index
+ ancestor = ancestors[ancestors.index(klass) + 1]
+ return ancestor if ancestor
+ end
lookup_ancestor klass, cache.superclass
end
Please sign in to comment.
Something went wrong with that request. Please try again.