Re: [PATCH v2 12/13] scripts: kernel-doc: handle nested struct function arguments
Em Thu, 28 Sep 2017 18:32:30 +0200 Markus Heiser escreveu: > Hi Mauro, > > this 'else' addition seems a bit spooky to me. As I commented in patch 09/13 > may it helps when you look at > > > https://github.com/return42/linuxdoc/blob/master/linuxdoc/kernel_doc.py#L2499 > > which is IMO a bit more clear. Please don't top post. It makes really hard to understand what you meant. Anyway, as I answered to patc 9/13, I opted to add a separate patch in order to solve the remaining issues. If Jon prefers, I can just fold the three patches into one, although IMHO it is better to keep them in separate. Regards, Mauro -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 12/13] scripts: kernel-doc: handle nested struct function arguments
Hi Mauro, this 'else' addition seems a bit spooky to me. As I commented in patch 09/13 may it helps when you look at https://github.com/return42/linuxdoc/blob/master/linuxdoc/kernel_doc.py#L2499 which is IMO a bit more clear. -- Markus -- > Am 27.09.2017 um 23:10 schrieb Mauro Carvalho Chehab > : > > 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 > --- > scripts/kernel-doc | 38 ++ > 1 file changed, 26 insertions(+), 12 deletions(-) > > diff --git a/scripts/kernel-doc b/scripts/kernel-doc > index 713608046d3a..376365d41718 100755 > --- a/scripts/kernel-doc > +++ b/scripts/kernel-doc > @@ -1015,18 +1015,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/; > @@ -1215,7 +1229,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/; > -- > 2.13.5 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-doc" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 12/13] 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 --- scripts/kernel-doc | 38 ++ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 713608046d3a..376365d41718 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -1015,18 +1015,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/; @@ -1215,7 +1229,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/; -- 2.13.5 -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html