From 7c2329cd785897bd7ac1183e2db75ccd2ab299fe Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 15 Jun 2024 11:31:17 -0400 Subject: [PATCH] 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. --- build-scripts/wikiheaders.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl index 6b4dac657f..83a9664ddc 100755 --- a/build-scripts/wikiheaders.pl +++ b/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;