Переглянути джерело

wikiheaders: Fix C typedef parsing.

Before, it was treating `typedef struct x x;` as a struct typedef instead of
a datatype typedef. Worse, it was treating `typedef struct x *x` the same!

This might require us to manually clean out some incorrect CategoryAPIStruct
tags that have accumulated in various pages.
Ryan C. Gordon 10 місяців тому
батько
коміт
7c2329cd78
1 змінених файлів з 3 додано та 3 видалено
  1. 3 3
      build-scripts/wikiheaders.pl

+ 3 - 3
build-scripts/wikiheaders.pl

@@ -847,9 +847,9 @@ while (my $d = readdir(DH)) {
                     $symtype = 1;   # (forced-inline) function declaration
                 } elsif ($decl =~ /\A\s*\#\s*define\s+/) {
                     $symtype = 2;   # macro
-                } elsif ($decl =~ /\A\s*(typedef\s+|)(struct|union)/) {
+                } elsif ($decl =~ /\A\s*(typedef\s+|)(struct|union)\s*([a-zA-Z0-9_]*?)\s*(\n|\{|\Z)/) {
                     $symtype = 3;   # struct or union
-                } elsif ($decl =~ /\A\s*(typedef\s+|)enum/) {
+                } elsif ($decl =~ /\A\s*(typedef\s+|)enum\s*([a-zA-Z0-9_]*?)\s*(\n|\{|\Z)/) {
                     $symtype = 4;   # enum
                 } elsif ($decl =~ /\A\s*typedef\s+.*\Z/) {
                     $symtype = 5;   # other typedef
@@ -1075,7 +1075,7 @@ while (my $d = readdir(DH)) {
             }
         } elsif (($symtype == 3) || ($symtype == 4)) {  # struct or union or enum
             my $has_definition = 0;
-            if ($decl =~ /\A\s*(typedef\s+|)(struct|union|enum)\s*(.*?)\s*(\n|\{|\;|\Z)/) {
+            if ($decl =~ /\A\s*(typedef\s+|)(struct|union|enum)\s*([a-zA-Z0-9_]*?)\s*(\n|\{|\;|\Z)/) {
                 my $ctype = $2;
                 my $origsym = $3;
                 my $ending = $4;