qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 13/29] scripts: kernel-doc: add support for typedef enum


From: Paolo Bonzini
Subject: [PATCH 13/29] scripts: kernel-doc: add support for typedef enum
Date: Tue, 17 Nov 2020 17:52:56 +0100

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

The PHY kernel-doc markup has gained support for documenting
a typedef enum.

However, right now the parser was not prepared for it.

So, add support for parsing it.

Fixes: 4069a572d423 ("net: phy: Document core PHY structures")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/kernel-doc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index c4c5640ded..073f72c7da 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1295,14 +1295,22 @@ sub show_warnings($$) {
 sub dump_enum($$) {
     my $x = shift;
     my $file = shift;
+    my $members;
+
 
     $x =~ s@/\*.*?\*/@@gos;    # strip comments.
     # strip #define macros inside enums
     $x =~ s@#\s*((define|ifdef)\s+|endif)[^;]*;@@gos;
 
-    if ($x =~ /enum\s+(\w*)\s*\{(.*)\}/) {
+    if ($x =~ /typedef\s+enum\s*\{(.*)\}\s*(\w*)\s*;/) {
+       $declaration_name = $2;
+       $members = $1;
+    } elsif ($x =~ /enum\s+(\w*)\s*\{(.*)\}/) {
        $declaration_name = $1;
-       my $members = $2;
+       $members = $2;
+    }
+
+    if ($declaration_name) {
        my %_members;
 
        $members =~ s/\s+$//;
@@ -1337,8 +1345,7 @@ sub dump_enum($$) {
                            'sections' => \%sections,
                            'purpose' => $declaration_purpose
                           });
-    }
-    else {
+    } else {
        print STDERR "${file}:$.: error: Cannot parse enum!\n";
        ++$errors;
     }
-- 
2.28.0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]