Summarize-Headers 887 Bytes
Newer Older
Per Cederqvist's avatar
.  
Per Cederqvist committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/bin/sh

#  Summarize a .h file

#  Since we write our .h files with documentation in line, they
#  tend to get rather long, and it gets somewhat difficult to get
#  a quick overview of what functions are declared in the file.
#  This script cuts out all the "unnecessary" information.

AWK=gawk

$AWK   '/^[ \t]*#[ \t]*define/ { print $0 ;
				define = 1 ;
				next ;
			}
	define != 0	{	if (substr($0, length(), 1) == "\\")
				{
					printf ("\n") ;
					next ;
				}
				else  {
					printf ("\n") ;
					define = 0 ;
					next ;
				}
			}
	/^\/\*/,/\*\/$/	{	printf ("\n") ;
				next ;
			}
	/\/\//		{	next ;				}
	(define == 0) &&	\
  	(comment == 0) 	{	print $0 ;			}
	/\/\*/		{	comment = 1 ;			}
	/\*\//		{	comment = 0 ;			}
'  $1 |
$AWK   'BEGIN		{	blank_lines = 0;		}
	$1 == ""	{		if (blank_lines++ == 0)
					print $0;
			}
	$1 != ""	{	print $0;
				blank_lines = 0;
			}
'