aboutsummaryrefslogtreecommitdiff
path: root/bin/sig
blob: ed4c983affeda4f57e7bd2406b481ef15b1dcb4e (plain)
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
44
45
46
#!/usr/local/plan9/bin/rc
# Usage: sig key ...
#	prints out function signatures by grepping the manual

. 9.rc
*=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'}	# fold case, delete funny chars
if(~ $#* 0){
	echo Usage: sig function ... >[1=2]
	exit 1
}

noplan9=()
for(p in $path) {
	if(! ~ $p $PLAN9/bin)
		noplan9=($noplan9 $p)
}	

for (i) {
	files=`{grep -il '[ 	]\*?'$i'\(' $PLAN9/man/man3/*.3*}
	for(j in $files) {
		{echo .nr LL 20i; 9 sed -n '/^.SH SYNOPSIS/,/^.SH.*DESCR/p'  $j } |
			nroff -man |
			sed '
				:a
				/,$/ {
					N
					s/\n//
				}
				ta
				s/[ 	]+/ /g' |
			grep -i -e '[ 	]\*?'$i'\(' | sed 's/^[ +]/	/'
	}
	{ path=$noplan9; man 2 $i; man 3 $i } >[2]/dev/null | nobs | sed -n '
		:d
		/SYNOPSIS/bp
		n
		bd
		:p
		/DESCRIPTION/bd
		p
		n
		bp
	' | grep -i -e '[ 	]\*?'$i'\(' | sed 's/^[ +]/	/'
}

exit 0