From: Michal Vaner Date: Thu, 11 Sep 2008 15:59:26 +0000 (+0200) Subject: Doc. system: recognize typedefs of structs X-Git-Tag: holmes-import~309 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=7e867a93a1d12a01ac997830e5c8e17e2af110c9;p=libucw.git Doc. system: recognize typedefs of structs Recognize patterns like this as a struct. Similar for enum. typedef struct { something; } name; --- diff --git a/build/doc-extract b/build/doc-extract index a5af0e4e..8553af94 100755 --- a/build/doc-extract +++ b/build/doc-extract @@ -24,19 +24,21 @@ if( defined $defdump ) { sub detect( $ ) { ( $_ ) = @_; + return( 'struct', 1, $1, "typedef struct { ... } $1;" ) if( /^\s*typedef\s+struct\s*{.*}\s*(\w+)\s*;\s*$/s ); + return( 'enum', 1, $1, "typedef enum { ... } $1;" ) if( /^\s*typedef\s+enum\s*{.*}\s*(\w+)\s*;\s*$/s ); my $l = length; s/\n.*//s; - return( 'struct', 0, $1 ) if( /struct\s+(\w+)\s+{/ ); - return( 'enum', 0, $1 ) if( /enum\s+(\w+)\s+{/ ); + return( 'struct', 0, $1, $_ ) if( /struct\s+(\w+)\s+{/ ); + return( 'enum', 0, $1, $_ ) if( /enum\s+(\w+)\s+{/ ); if( $l > length ) { warn( "Unknown statement $_\n" ); - return( '', 0, $_ ); + return( '', 0, $_, $_ ); } - return( 'define', 0, $1 ) if( /#define\s+(\w+)/ ); - return( 'function', 1, $1 ) if( /(\w+)\(.*\)/ ); - return( 'variable', 1, $1 ) if( /\s(\w+);/ ); + return( 'define', 0, $1, $_ ) if( /#define\s+(\w+)/ ); + return( 'function', 1, $1, $_ ) if( /(\w+)\(.*\)/ ); + return( 'variable', 1, $1, $_ ) if( /\s(\w+);/ ); warn( "Unknown statement $_\n" ); - return( '', 0, $_ ); + return( '', 0, $_, $_ ); } my @deps; @@ -49,7 +51,7 @@ sub formatNote( $$ ) { print OUT "''''\n"; chomp $head; print OUT "[[auto_$id]]\n"; - my( $type, $semicolon, $name ) = detect( $head ); + my( $type, $semicolon, $name, $oneline ) = detect( $head ); $head =~ s/;?\s*$/;/ if( $semicolon ); if( $type eq 'function' ) { print OUT "!!f!$head!!!\n\n"; @@ -59,8 +61,7 @@ sub formatNote( $$ ) { print OUT "..................\n\n"; } if( $hasdump ) { - $head =~ s/\n.*//s; - print DUMP "$outname,$id,$type,$name,$head\n"; + print DUMP "$outname,$id,$type,$name,$oneline\n"; $id ++; } print OUT "$comment\n\n";