home *** CD-ROM | disk | FTP | other *** search
- #!/bin/csh -f
- #
- # $Id: counts.csh,v 1.2 1994/02/07 23:13:07 chrisc Exp $
- #
- # This shell script reads stdin (which should be one of the make.deps
- # in a source directory) and tells which header files are called by
- # which files. Thus telling how many files *don't* call a particular
- # header file.
- #
- # The way I used it was I wanted to find out how many include files
- # from mdlgate were used. I preformed a grep on make.deps:
- # grep mdlgate make.deps
- # This told me that lots of files were included from mdlgate. I then
- # needed to add the include file that redefines Fortran functions to
- # append an underscore to all the functions that include from mdlgate.
- # This script told me which mdlgate header file to add an include to
- # mdlgatef2c.h.
- # grep mdlgate make.deps | counts.csh
- #
- # Revision History:
- # $Log: counts.csh,v $
- # Revision 1.2 1994/02/07 23:13:07 chrisc
- # Modified to put the counts in files. This helped because I ran out
- # of argument space in some directories.
- #
- #--------------------------------------------------------------------
-
- set noglob
-
- set allincs = /usr/var/tmp/allincs$$
- set allfiles = /usr/var/tmp/allfiles$$
- set inclist = /usr/var/tmp/inclist$$
- set tmpFile = /usr/var/tmp/tmp$$
-
- rm -f $allincs $allfiles $inclist
- touch $allincs
- touch $allfiles
- touch $inclist
-
- @ totfiles = 0
- @ totincs = 0
-
- while ( 1 )
- set line = $<
- if ( "$line" == "" ) break
- set cline = `echo $line | sed 's/://'`
- grep $cline[1] $allfiles >& /dev/null
- if ( $status ) then
- echo $cline[1] >> $allfiles
- @ totfiles = $totfiles + 1
- endif
- set find = `grep -n $cline[2] $allincs`
- if ( $status ) then
- echo $cline[2] >> $allincs
- @ totincs = $totincs + 1
- echo $cline[1] >> $inclist
- else
- set n = `echo "$find[1]" | awk -F: '{print $1}'`
- set x = `head -$n $inclist | tail -1`
- echo "$x" | grep "$cline[1]" >& /dev/null
- if ( $status ) then
- @ n1 = $n - 1
- head -$n1 $inclist > $tmpFile
- echo "$x" "$cline[1]" >> $tmpFile
- @ n1 = $totincs - $n
- tail -$n1 $inclist >> $tmpFile
- mv $tmpFile $inclist
- endif
- endif
- end
-
- @ n = 0
- while ( $n < $totincs )
- @ n = $n + 1
- set x = `head -$n $inclist | tail -1`
- set inc = `head -$n $allincs | tail -1`
- set f = ()
- foreach file ( `cat $allfiles` )
- echo $x | grep $file >& /dev/null
- if ( $status ) set f = ( $f $file )
- end
- echo "$inc is not called by $#f out of $totfiles files"
- echo " not called by $f"
- echo ""
- end
-
- rm $allincs $allfiles $inclist
-