[comp.sources.unix] v20i011: Tools for generating software metrics, Part04/14

rsalz@uunet.uu.net (Rich Salz) (09/20/89)

Submitted-by: Brian Renaud <huron.ann-arbor.mi.us!bdr>
Posting-number: Volume 20, Issue 11
Archive-name: metrics/part04

---- Cut Here and unpack ----
#!/bin/sh
# this is part 4 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file src/control/altparse.prs continued
#
CurArch=4
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file src/control/altparse.prs"
sed 's/^X//' << 'SHAR_EOF' >> src/control/altparse.prs
X		next;
X	}
X
X	{
X		# a file name, right?
X		if ( first )
X			first = False;
X		else
X			printf("%s\t%d\n", file, changect);
X		changect = 0;
X		file = $1;
X	}
X	END {
X		printf("%s\t%d\n", file, changect);
X	}
X	' | sed 's/:	/	/' | sed 's@/s\.@/@'
Xdone
SHAR_EOF
echo "File src/control/altparse.prs is complete"
chmod 0644 src/control/altparse.prs || echo "restore of src/control/altparse.prs fails"
echo "x - extracting src/control/example_spec (Text)"
sed 's/^X//' << 'SHAR_EOF' > src/control/example_spec
X/usr/pascal/src/compiler *.[cy] /usr/pascal/sccs/compiler s.*.[cy]
X/usr/pascal/src/compiler *.h /usr/pascal/sccs/include s.*.h
X/usr/pascal/src/lib/Arith [a-z]* /usr/pascal/sccs/lib/Arith s.[a-z]*
X/usr/pascal/src/lib/Data [a-z]* /usr/pascal/sccs/lib/Data s.[a-z]*
X/usr/pascal/src/lib/Date [a-z]* /usr/pascal/sccs/lib/Date s.[a-z]*
X/usr/pascal/src/lib/File [a-z]* /usr/pascal/sccs/lib/File s.[a-z]*
X/usr/pascal/src/lib/Sets [a-z]* /usr/pascal/sccs/lib/Sets s.[a-z]*
X/usr/pascal/src/lib/String [a-z]* /usr/pascal/sccs/lib/String s.[a-z]*
X/usr/pascal/src/lib/Tran [a-z]* /usr/pascal/sccs/lib/Tran s.[a-z]*
X/usr/pascal/src/lib/Util [a-z]* /usr/pascal/sccs/lib/Util s.[a-z]*
X/usr/pascal/src/pc [a-z]*.[ch] /usr/pascal/sccs/pc s.[a-z]*.[ch]
X/usr/pascal/src/errlist *.c /usr/pascal/sccs/errlist s.*.c
SHAR_EOF
chmod 0644 src/control/example_spec || echo "restore of src/control/example_spec fails"
echo "x - extracting src/control/gather_stats (Text)"
sed 's/^X//' << 'SHAR_EOF' > src/control/gather_stats
X: gather up statistics on code
X
Xgotsccs=0
Xgotsource=0
Xgotroutine=0
Xgotfile=0
Xswitched=0
Xfiles=""
X
Xwhile [ $# != 0 ]
Xdo
X	case $1 in
X	-sccs)
X		gotsccs=1
X		sccsbase=$2
X		sccsfiles="$3"
X		shift
X		shift ;;
X	-source)
X		gotsource=1
X		sourcebase=$2
X		sourcefiles="$3"
X		shift
X		shift ;;
X	-routine)
X		gotroutine=1
X		routineout=$2
X		shift ;;
X	-file)
X		gotfile=1
X		fileout=$2
X		shift ;;
X	*)
X		echo "usage: $0 -routine <routine-output-file> -file <file-output-file> -source <path> <filespec> -sccs <path> <filespec>"
X		exit 1
X	esac
X	shift
Xdone
X
Xif [ ${gotsccs} = 0 -a ${gotsource} = 0 ]
Xthen
X	echo "usage: $0 -routine <routine-output-file> -file <file-output-file> -source <path> <filespec> -sccs <path> <filespec>"
X	exit 1
Xfi
Xif [ ${gotroutine} = 0 -o ${gotfile} = 0 ]
Xthen
X	echo "usage: $0 -routine <routine-output-file> -file <file-output-file> -source <path> <filespec> -sccs <path> <filespec>"
X	exit 1
Xfi
X
Xt_hal=/tmp/$$.halstead
Xt_kdsi=/tmp/$$.kdsi
Xt_chg=/tmp/$$.changes
Xtemp=/tmp/$$.temp
X
Xtrap '/bin/rm -f ${t_hal} ${t_kdsi} ${t_chg} ${temp}; exit 1' 1 2 15
X
Xcd ${sourcebase}
X
X
X# halstead output is Filename, Length, Volume, Level, and
X# Effective mental discriminations;  in halstead terms, name, N, V, L, E^
X#
Xhalstead ${sourcefiles} | sort > ${t_hal}
X#
X# altkdsi output is actual source lines (DSI), comment count
X#
Xaltkdsi ${sourcefiles} | sort > ${t_kdsi}
X
X
X
Xcd ${sccsbase}
X#
X# altparse.prs output is filename, change count
X#
Xaltparse.prs ${sccsfiles} | sort > ${t_chg}
Xcd ${sourcebase}
X
X
X# joining halstead and kdsi info, note the tab seperator
Xjoin -j1 1 -j2 1 -a1 -a2 -e '%%%' '-t	' -o 1.1 1.3 2.2 2.3 ${t_hal} ${t_kdsi} > ${temp}
X
Xfgrep -s '%%%' ${temp}
Xif [ $? != 1 ]
Xthen
X	echo "$0: unable to matchup files on join of halstead and kdsi"
X	echo "  see files ${t_hal} ${t_kdsi} ${temp} (output)"
X	/bin/rm -f ${t_chg}
X	exit 1
Xfi
X
X# joining halstead/kdsi and sccs info, note the tab seperator
Xjoin -j1 1 -j2 1 -a1 -a2 -e '%%%' '-t	' -o 1.1 2.2 1.2 1.3 1.4 ${temp} ${t_chg} > ${fileout}
X
Xfgrep -s '%%%' ${temp}
Xif [ $? != 1 ]
Xthen
X	echo "$0: unable to matchup files on join of halstead/kdsi and changes"
X	echo "  see files ${temp} ${t_chg} ${fileout}"
X	/bin/rm -f ${t_hal} ${t_kdsi}
X	exit 1
Xfi
X
Xmccabe -n ${sourcefiles} | sort > ${routineout}
X
Xecho "file ${fileout} contains:"
Xecho "filename changecount volume kdsi comments"
Xecho " "
Xecho "file ${routineout} contains:"
Xecho "filename routinename mccabe returns adjusted/mccabe"
X
X/bin/rm -f ${t_hal} ${t_kdsi} ${t_chg} ${temp}
Xexit 0
SHAR_EOF
chmod 0644 src/control/gather_stats || echo "restore of src/control/gather_stats fails"
echo "x - extracting src/control/pascal_stats (Text)"
sed 's/^X//' << 'SHAR_EOF' > src/control/pascal_stats
X: collect statistics for pascal
X
Xsccs=/usr/pascal/sccs
Xsourcebase=`pwd`
Xgottarget=0
X
Xwhile [ $# -gt 0 ]
Xdo
X	case $1 in
X	-sourcebase)
X		sourcebase=$2
X		shift ;;
X	-target)
X		gottarget=1
X		target=$2
X		shift ;;
X	*)
X		echo "usage: $0 -target <directory> [-sourcebase <directory>]"
X		exit 1
X	esac
X	shift
Xdone
X
Xbase=`pwd`
Xcd ${sourcebase}
Xroutine=${base}/@routine_defs
Xfile=${base}/@file_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase} 'src/*.[cy]' -sccs ${sccs} 'src/s.*.[cy]'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the src directory"
X	exit 1
Xfi
Xcat ${file} > ${target}/@file_defs
Xcat ${routine} > ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase} 'include/*.h' -sccs ${sccs} 'include/s.*.h'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the include directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'Arith/[a-z]*' -sccs ${sccs}/lib 'Arith/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the Arith directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'Data/[a-z]*' -sccs ${sccs}/lib 'Data/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the Data directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'Date/[a-z]*' -sccs ${sccs}/lib 'Date/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the Date directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'File/[a-z]*' -sccs ${sccs}/lib 'File/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the File directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'Sets/[a-z]*' -sccs ${sccs}/lib 'Sets/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the Sets directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'String/[a-z]*' -sccs ${sccs}/lib 'String/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the String directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'Tran/[a-z]*' -sccs ${sccs}/lib 'Tran/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the Tran directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase}/lib 'Util/[a-z]*' -sccs ${sccs}/lib 'Util/s.[a-z]*'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the Util directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase} 'pc/[a-z]*.[ch]' -sccs ${sccs} 'pc/s.[a-z]*.[ch]'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the pc directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
X
Xgather_stats -file ${file} -routine ${routine}\
X	-source ${sourcebase} 'errlist/*.c' -sccs ${sccs} 'errlist/s.*.c'
Xif [ $? != 0 ]
Xthen
X	echo "unable to gather statistics on the errlist directory"
X	exit 1
Xfi
Xcat ${file} >> ${target}/@file_defs
Xcat ${routine} >> ${target}/@routine_defs
SHAR_EOF
chmod 0644 src/control/pascal_stats || echo "restore of src/control/pascal_stats fails"
echo "x - extracting src/control/proj_stats (Text)"
sed 's/^X//' << 'SHAR_EOF' > src/control/proj_stats
X: collect statistics for the system
X# parameters:
X#  -sourcebase <directory> - <directory> is the root directory for the code
X#  -target <directory>     - <directory> is where to put the results of analysis
X#                            (the function and file analysis results)
SHAR_EOF
echo "End of part 4"
echo "File src/control/proj_stats is continued in part 5"
echo "5" > s2_seq_.tmp
exit 0


-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.