From b5e77aab53699c98d342e91e91d89472efb53c33 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Wed, 10 Sep 2008 20:49:59 +0200 Subject: [PATCH] Doc. system: detect type of definition Just heuristics, detects type of the symbol and the name of the symbol. It is used to add semicolon to inline functions what do not have one, but more use of the detection is expected. --- build/doc-extract | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/build/doc-extract b/build/doc-extract index ca4e42e2..5373a5a2 100755 --- a/build/doc-extract +++ b/build/doc-extract @@ -22,6 +22,23 @@ if( defined $defdump ) { $hasdump = 1; } +sub detect( $ ) { + ( $_ ) = @_; + my $l = length; + s/\n.*//s; + return( 'struct', 0, $1 ) if( /struct\s+(\w+)\s+{/ ); + return( 'enum', 0, $1 ) if( /enum\s+(\w+)\s+{/ ); + if( $l > length ) { + warn( "Unknown statemen $_\n" ); + return( '', 0, $_ ); + } + return( 'define', 0, $1 ) if( /#define\s+(\w+)/ ); + return( 'function', 1, $1 ) if( /(\w+)\(.*\)/ ); + return( 'variable', 1, $1 ) if( /\s(\w+);/ ); + warn( "Unknown statemen $_\n" ); + return( '', 0, $_ ); +} + my @deps; my $id = 0; @@ -32,7 +49,9 @@ sub formatNote( $$ ) { print OUT "''''\n"; chomp $head; print OUT "[[auto_$id]]\n"; - if($head =~ /\w+\([^()]*\)/ && $head !~ /\n/) { + my( $type, $semicolon, $name ) = detect( $head ); + $head =~ s/;?\s+$/;/ if( $semicolon ); + if( $type eq 'function' ) { print OUT "!!f!$head!!!\n\n"; } else { print OUT "..................\n"; -- 2.39.5