xref: /inferno-os/dis/sig (revision 2a557437fb2b2918e7ad37507a97dcf2dc164545)
1#!/dis/sh.dis
2# Usage: sig key ...
3#	prints out function signatures by grepping the manual
4# stolen from plan 9 via p9p and caerwyn
5load std
6
7x=$*
8*=`{echo $x | tr A-Z a-z | tr -dc 'a-z0-9_ \012'} # fold case, delete funny chars
9if {no $*} {
10	echo Usage: sig function ... >[1=2]
11	raise 'usage'
12}
13
14for i in $* {
15	files=`{grep -il '[ 	]*'$i':[ 	]*fn\(' /man/2/*}
16	for j in $files {
17		sect=`{basename $j}^'(2)'
18		{echo .nr LL 20i; sed -n '/^.SH SYNOPSIS/,/^.SH.*DESCR/p'  $j} |
19#			os nroff -man |
20			sed '
21				:a
22				/,$|:$/ {
23					N
24					s/\n//
25				}
26				ta
27				s/[ 	]+/ /g' |
28			grep -i '[	]*'$i':[ 	]*fn\(' | sed 's/^[ ]+/	/; s/;$/; \# '$sect'/'
29	}
30}
31
32exit
33