(no subject)

From: Tim Waugh (tim@cyberelk.demon.co.uk)
Date: Sun Apr 02 2000 - 07:01:15 EST


Here's a first stab at getting kernel-doc to understand things like this:

struct pardevice *
parport_register_device (struct parport *port, const char *name,
                         int (*pf)(void *), void (*kf)(void *),
                         int (*irq_func)(int, void *, struct pt_regs *),
                         int flags, void *handle)

This function has 7 parameters, three of which are function pointers (yes,
it is a bit gross, but that's how it is).

This patch makes kernel-doc a bit smarter about picking parameters from
types in situations like this. Still to do: make the output routines
understand how to display types like this. With DocBook, there are
special tags for this kind of thing.

The extra regular expression should probably replace the one below it, as
I think it will always trigger instead. I hope this doesn't break
anything.

Comments?

Tim.
*/

--- linux-2.3.99-pre4-2/scripts/kernel-doc Sat Apr 1 14:20:27 2000
+++ linux/scripts/kernel-doc Sun Apr 2 12:59:53 2000
@@ -618,28 +618,43 @@
         $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
         $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
         $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/ ||
+ $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\}]*)\)/ ||
         $prototype =~ m/^(\w+\s+\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\)]*)\)/) {
         $return_type = $1;
         $function_name = $2;
         $args = $3;
 
+ # allow for up to three args to function pointers
+ $args =~ s/(\([^\),]+),/\1#/;
+ $args =~ s/(\([^\),]+),/\1#/;
+ $args =~ s/(\([^\),]+),/\1#/;
 # print STDERR "ARGS = '$args'\n";
 
         foreach $arg (split ',', $args) {
             # strip leading/trailing spaces
             $arg =~ s/^\s*//;
             $arg =~ s/\s*$//;
-# print STDERR "SCAN ARG: '$arg'\n";
- @args = split('\s', $arg);
 
-# print STDERR " -> @args\n";
- $param = pop @args;
-# print STDERR " -> @args\n";
- if ($param =~ m/^(\*+)(.*)/) {
- $param = $2;
- push @args, $1;
+ if ($arg =~ m/#/ ||
+ $arg =~ m/\(/) {
+ $arg =~ tr/#/,/;
+ $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
+ $param = $1;
+ $type = $arg;
+ $type =~ s/([^\(]+\(\*)$param/\1/;
+ } else {
+# print STDERR "SCAN ARG: '$arg'\n";
+ @args = split('\s', $arg);
+
+# print STDERR " -> @args\n";
+ $param = pop @args;
+# print STDERR " -> @args\n";
+ if ($param =~ m/^(\*+)(.*)/) {
+ $param = $2;
+ push @args, $1;
+ }
+ $type = join " ", @args;
             }
- $type = join " ", @args;
 
             if ($type eq "" && $param eq "...")
             {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Apr 07 2000 - 21:00:08 EST