Skip to content

Commit 7c0d7e8

Browse files
mchehabJonathan Corbet
authored andcommitted
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: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 151c468 commit 7c0d7e8

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

scripts/kernel-doc

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,18 +1041,32 @@ sub dump_struct($$) {
10411041
$id =~ s/^\*+//;
10421042
foreach my $arg (split /;/, $content) {
10431043
next if ($arg =~ m/^\s*$/);
1044-
my $type = $arg;
1045-
my $name = $arg;
1046-
$type =~ s/\s\S+$//;
1047-
$name =~ s/.*\s//;
1048-
$name =~ s/[:\[].*//;
1049-
$name =~ s/^\*+//;
1050-
next if (($name =~ m/^\s*$/));
1051-
if ($id =~ m/^\s*$/) {
1052-
# anonymous struct/union
1053-
$newmember .= "$type $name;";
1044+
if ($arg =~ m/^([^\(]+\(\*?\s*)([\w\.]*)(\s*\).*)/) {
1045+
# pointer-to-function
1046+
my $type = $1;
1047+
my $name = $2;
1048+
my $extra = $3;
1049+
next if (!$name);
1050+
if ($id =~ m/^\s*$/) {
1051+
# anonymous struct/union
1052+
$newmember .= "$type$name$extra;";
1053+
} else {
1054+
$newmember .= "$type$id.$name$extra;";
1055+
}
10541056
} else {
1055-
$newmember .= "$type $id.$name;";
1057+
my $type = $arg;
1058+
my $name = $arg;
1059+
$type =~ s/\s\S+$//;
1060+
$name =~ s/.*\s+//;
1061+
$name =~ s/[:\[].*//;
1062+
$name =~ s/^\*+//;
1063+
next if (($name =~ m/^\s*$/));
1064+
if ($id =~ m/^\s*$/) {
1065+
# anonymous struct/union
1066+
$newmember .= "$type $name;";
1067+
} else {
1068+
$newmember .= "$type $id.$name;";
1069+
}
10561070
}
10571071
}
10581072
$members =~ s/(struct|union)([^{};]+){([^{}]*)}([^{}\;]*)\;/$newmember/;
@@ -1250,7 +1264,7 @@ sub create_parameterlist($$$$) {
12501264
} elsif ($arg =~ m/\(.+\)\s*\(/) {
12511265
# pointer-to-function
12521266
$arg =~ tr/#/,/;
1253-
$arg =~ m/[^\(]+\(\*?\s*(\w*)\s*\)/;
1267+
$arg =~ m/[^\(]+\(\*?\s*([\w\.]*)\s*\)/;
12541268
$param = $1;
12551269
$type = $arg;
12561270
$type =~ s/([^\(]+\(\*?)\s*$param/$1/;

0 commit comments

Comments
 (0)