plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

sig (829B)


      1 #!/usr/local/plan9/bin/rc
      2 # Usage: sig key ...
      3 #	prints out function signatures by grepping the manual
      4 
      5 . 9.rc
      6 *=`{echo $*|tr A-Z a-z|tr -dc 'a-z0-9_ \012'}	# fold case, delete funny chars
      7 if(~ $#* 0){
      8 	echo Usage: sig function ... >[1=2]
      9 	exit 1
     10 }
     11 
     12 noplan9=()
     13 for(p in $path) {
     14 	if(! ~ $p $PLAN9/bin)
     15 		noplan9=($noplan9 $p)
     16 }	
     17 
     18 for (i) {
     19 	files=`{grep -il '[ 	]\*?'$i'\(' $PLAN9/man/man3/*.3*}
     20 	for(j in $files) {
     21 		{echo .nr LL 20i; 9 sed -n '/^.SH SYNOPSIS/,/^.SH.*DESCR/p'  $j } |
     22 			nroff -man |
     23 			sed '
     24 				:a
     25 				/,$/ {
     26 					N
     27 					s/\n//
     28 				}
     29 				ta
     30 				s/[ 	]+/ /g' |
     31 			grep -i -e '[ 	]\*?'$i'\(' | sed 's/^[ +]/	/'
     32 	}
     33 	{ path=$noplan9; man 2 $i; man 3 $i } >[2]/dev/null | nobs | sed -n '
     34 		:d
     35 		/SYNOPSIS/bp
     36 		n
     37 		bd
     38 		:p
     39 		/DESCRIPTION/bd
     40 		p
     41 		n
     42 		bp
     43 	' | grep -i -e '[ 	]\*?'$i'\(' | sed 's/^[ +]/	/'
     44 }
     45 
     46 exit 0