]> mj.ucw.cz Git - libucw.git/commitdiff
Doc. system: detect type of definition
authorMichal Vaner <vorner@ucw.cz>
Wed, 10 Sep 2008 18:49:59 +0000 (20:49 +0200)
committerMichal Vaner <vorner@ucw.cz>
Wed, 10 Sep 2008 18:49:59 +0000 (20:49 +0200)
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

index ca4e42e2874fb771ae0b5b0d7aba25206093dafb..5373a5a2898eba9e8d8966ec0a55a134a7589d92 100755 (executable)
@@ -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";