]> git.karo-electronics.de Git - linux-beck.git/commitdiff
doc-rst: parse-headers: better handle comments at the source code
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Thu, 7 Jul 2016 17:13:12 +0000 (14:13 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Thu, 7 Jul 2016 18:12:48 +0000 (15:12 -0300)
We should not let comments to mangle with the symbols
parsing. Unfortunately, videodev2.h has lots of those
in the middle of enums and structs. So, we need to improve
our parser to discard them.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Documentation/sphinx/parse-headers.pl

index b703f1a7f432afcc7487829c73bf362b5154358a..fc18eac1552cde9283eb7ad5a6de53e237f3d06f 100755 (executable)
@@ -27,13 +27,24 @@ my %structs;
 #
 
 my $is_enum = 0;
+my $is_comment = 0;
 open IN, $file_in or die "Can't open $file_in";
 while (<IN>) {
-       my $ln = $_;
-       $ln =~ s,/\*.*\*/,,;
-
        $data .= $_;
 
+       my $ln = $_;
+       if (!$is_comment) {
+               $ln =~ s,/\*.*(\*/),,g;
+
+               $is_comment = 1 if ($ln =~ s,/\*.*,,);
+       } else {
+               if ($ln =~ s,^(.*\*/),,) {
+                       $is_comment = 0;
+               } else {
+                       next;
+               }
+       }
+
        if ($is_enum && $ln =~ m/^\s*([_\w][\w\d_]+)\s*[\,=]?/) {
                my $s = $1;
                my $n = $1;