--------------010405090400070705070908
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Ian Macdonald wrote:
> Hello,
> 
> I've just noticed that running C source files through a default
> configuration of GNU indent breaks the ability of rdoc to find classes
> and methods in them.
> 
> The thing is, I can't figure out what the parser is running aground on?
> 
> Has anyone run into this before?

It's quite likely spaces between a function name and the following 
parentheses, GNU style recommends that, so I imagine indent might 
default to it, and I know it screws up rdoc.  I cooked up the following 
patch a while back to correct the issue, no idea if it applies to 
current releases or not, I think it was against CVS HEAD at the time.

-garrett

--------------010405090400070705070908
Content-Type: text/plain;
 namedoc-space-before-paren.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filenamedoc-space-before-paren.diff"

? rdoc-space-before-paren.diff
Index: lib/rdoc/parsers/parse_c.rb
RCS file: /src/ruby/lib/rdoc/parsers/parse_c.rb,v
retrieving revision 1.25
diff -u -r1.25 parse_c.rb
--- lib/rdoc/parsers/parse_c.rb	9 Sep 2004 02:47:35 -0000	1.25
+++ lib/rdoc/parsers/parse_c.rb	8 Jan 2005 19:17:02 -0000
@@ -249,13 +249,13 @@
     ############################################################
 
     def do_classes
-      @body.scan(/(\w+)\s*  s*rb_define_module\(\s*"(\w+)"\s*\)/mx) do 
+      @body.scan(/(\w+)\s*  s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do 
         |var_name, class_name|
         handle_class_module(var_name, "module", class_name, nil, nil)
       end
       
       # The '.' lets us handle SWIG-generated files
-      @body.scan(/([\w\.]+)\s*  s*rb_define_class
+      @body.scan(/([\w\.]+)\s*  s*rb_define_class\s*
                 \( 
                    \s*"(\w+)",
                    \s*(\w+)\s*
@@ -265,7 +265,7 @@
         handle_class_module(var_name, "class", class_name, parent, nil)
       end
       
-      @body.scan(/(\w+)\s**boot_defclass\(\s*"(\w+?)",\s*(\w+?)\)/) do
+      @body.scan(/(\w+)\s**boot_defclass\s*\(\s*"(\w+?)",\s*(\w+?)\)/) do
         |var_name, class_name, parent|
         parent  il if parent "0"
         handle_class_module(var_name, "class", class_name, parent, nil)
@@ -281,7 +281,7 @@
         handle_class_module(var_name, "module", class_name, nil, in_module)
       end
       
-      @body.scan(/([\w\.]+)\s*  s*rb_define_class_under
+      @body.scan(/([\w\.]+)\s*  s*rb_define_class_under\s*
                 \( 
                    \s*(\w+),
                    \s*"(\w+)",
@@ -304,7 +304,7 @@
                         method           |
                         module_function  |
                         private_method
-                     )
+                     )\s*
                      \(\s*([\w\.]+),
                        \s*"([^"]+)",
                        \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
@@ -325,7 +325,7 @@
                       meth_body, param_count, source_file)
       end
 
-      @body.scan(%r{rb_define_global_function\(
+      @body.scan(%r{rb_define_global_function\s*\(
                                \s*"([^"]+)",
                                \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
                                \s*(-?\w+)\s*\)
@@ -336,7 +336,7 @@
                       meth_body, param_count, source_file)
       end
   
-      @body.scan(/define_filetest_function\(
+      @body.scan(/define_filetest_function\s*\(
                                \s*"([^"]+)",
                                \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
                                \s*(-?\w+)\s*\)/xm) do  #"
@@ -350,7 +350,7 @@
     ############################################################
     
     def do_aliases
-      @body.scan(%r{rb_define_alias\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
+      @body.scan(%r{rb_define_alias\s*\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
         |var_name, new_name, old_name|
         @stats.num_methods + 
         class_name  known_classes[var_name] || var_name
@@ -482,7 +482,7 @@
     # Look for includes of the form
     #     rb_include_module(rb_cArray, rb_mEnumerable);
     def do_includes
-      @body.scan(/rb_include_module\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
+      @body.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
         if cls  classes[c]
           m  NOWN_CLASSES[m] || m
           cls.add_include(Include.new(m, ""))

--------------010405090400070705070908--