scripts: kernel-doc: handle nested struct function arguments
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Mon, 18 Dec 2017 12:30:16 +0000 (10:30 -0200)
committerJonathan Corbet <corbet@lwn.net>
Thu, 21 Dec 2017 20:41:47 +0000 (13:41 -0700)
Function arguments are different than usual ones. So, an
special logic is needed in order to handle such arguments
on nested structs.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
scripts/kernel-doc

index c97b89f47795e4218ac9f2961c6a301ce5db6439..5d03c90863235a17c9fc5972afb5492e6c404d07 100755 (executable)
@@ -1041,18 +1041,32 @@ sub dump_struct($$) {
                        $id =~ s/^\*+//;
                        foreach my $arg (split /;/, $content) {
                                next if ($arg =~ m/^\s*$/);
-                               my $type = $arg;
-                               my $name = $arg;
-                               $type =~ s/\s\S+$//;
-                               $name =~ s/.*\s//;
-                               $name =~ s/[:\[].*//;
-                               $name =~ s/^\*+//;
-                               next if (($name =~ m/^\s*$/));
-                               if ($id =~ m/^\s*$/) {
-                                       # anonymous struct/union
-                                       $newmember .= "$type $name;";
+                               if ($arg =~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) {
+                                       # pointer-to-function
+                                       my $type = $1;
+                                       my $name = $2;
+                                       my $extra = $3;
+                                       next if (!$name);
+                                       if ($id =~ m/^\s*$/) {
+                                               # anonymous struct/union
+                                               $newmember .= "$type$name$extra;";
+                                       } else {
+                                               $newmember .= "$type$id.$name$extra;";
+                                       }
                                } else {
-                                       $newmember .= "$type $id.$name;";
+                                       my $type = $arg;
+                                       my $name = $arg;
+                                       $type =~ s/\s\S+$//;
+                                       $name =~ s/.*\s+//;
+                                       $name =~ s/[:\[].*//;
+                                       $name =~ s/^\*+//;
+                                       next if (($name =~ m/^\s*$/));
+                                       if ($id =~ m/^\s*$/) {
+                                               # anonymous struct/union
+                                               $newmember .= "$type $name;";
+                                       } else {
+                                               $newmember .= "$type $id.$name;";
+                                       }
                                }
                        }
                        $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/;
@@ -1250,7 +1264,7 @@ sub create_parameterlist($$$$) {
        } elsif ($arg =~ m/\(.+\)\s*\(/) {
            # pointer-to-function
            $arg =~ tr/#/,/;
-           $arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/;
+           $arg =~ m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/;
            $param = $1;
            $type = $arg;
            $type =~ s/([^\(]+\(\*?)\s*$param/$1/;