]> mj.ucw.cz Git - libucw.git/blobdiff - build/doc-extract
Doc. system: detect function typedefs
[libucw.git] / build / doc-extract
index db713095563e2b6069001871df130f1a73f0307b..2ef86026c50243f7244acf70f7e16b3a6695c62a 100755 (executable)
@@ -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 );
+       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( 'def', 0, $1, $_ ) if( /#define\s+(\w+)/ );
-        return( 'fun', 1, $2, $1 ) if( /^(.*?(\w+)\([^{]*\)[^{]*)/ );
-        return( 'var', 1, $1, $_ ) if( /\s(\w+);/ );
+        return( 'def', 0, $1, $_ ) if /#define\s+(\w+)/;
+       return( 'type', 1, $2, $_ ) if /^\s*typedef[^()]+?(\(\s*?\*\s*?)?(\w+)(\s*\))?\s*\(.*\)/;
+        return( 'fun', 1, $2, $1 ) if /^(.*?(\w+)\([^{]*\)[^{]*)/;
+       return( 'type', 1, $1, $_ ) if /^\s*typedef.*?(\w+);/;
+        return( 'var', 1, $1, $_ ) if /\s(\w+);/;
         warn( "Unknown statement $_\n" );
         return( '', 0, $_, $_ );
 }