Commit 7c0d7e87 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Jonathan Corbet

scripts: kernel-doc: handle nested struct function arguments

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: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 151c468b
...@@ -1041,18 +1041,32 @@ sub dump_struct($$) { ...@@ -1041,18 +1041,32 @@ sub dump_struct($$) {
$id =~ s/^\*+//; $id =~ s/^\*+//;
foreach my $arg (split /;/, $content) { foreach my $arg (split /;/, $content) {
next if ($arg =~ m/^\s*$/); next if ($arg =~ m/^\s*$/);
my $type = $arg; if ($arg =~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) {
my $name = $arg; # pointer-to-function
$type =~ s/\s\S+$//; my $type = $1;
$name =~ s/.*\s//; my $name = $2;
$name =~ s/[:\[].*//; my $extra = $3;
$name =~ s/^\*+//; next if (!$name);
next if (($name =~ m/^\s*$/)); if ($id =~ m/^\s*$/) {
if ($id =~ m/^\s*$/) { # anonymous struct/union
# anonymous struct/union $newmember .= "$type$name$extra;";
$newmember .= "$type $name;"; } else {
$newmember .= "$type$id.$name$extra;";
}
} else { } 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/; $members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/;
...@@ -1250,7 +1264,7 @@ sub create_parameterlist($$$$) { ...@@ -1250,7 +1264,7 @@ sub create_parameterlist($$$$) {
} elsif ($arg =~ m/\(.+\)\s*\(/) { } elsif ($arg =~ m/\(.+\)\s*\(/) {
# pointer-to-function # pointer-to-function
$arg =~ tr/#/,/; $arg =~ tr/#/,/;
$arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/; $arg =~ m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/;
$param = $1; $param = $1;
$type = $arg; $type = $arg;
$type =~ s/([^\(]+\(\*?)\s*$param/$1/; $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment