home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume20 / metrics / part04 < prev    next >
Text File  |  1989-09-18  |  10KB  |  348 lines

  1. Subject:  v20i011:  Tools for generating software metrics, Part04/14
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Brian Renaud <huron.ann-arbor.mi.us!bdr>
  7. Posting-number: Volume 20, Issue 11
  8. Archive-name: metrics/part04
  9.  
  10. ---- Cut Here and unpack ----
  11. #!/bin/sh
  12. # this is part 4 of a multipart archive
  13. # do not concatenate these parts, unpack them in order with /bin/sh
  14. # file src/control/altparse.prs continued
  15. #
  16. CurArch=4
  17. if test ! -r s2_seq_.tmp
  18. then echo "Please unpack part 1 first!"
  19.      exit 1; fi
  20. ( read Scheck
  21.   if test "$Scheck" != $CurArch
  22.   then echo "Please unpack part $Scheck next!"
  23.        exit 1;
  24.   else exit 0; fi
  25. ) < s2_seq_.tmp || exit 1
  26. echo "x - Continuing file src/control/altparse.prs"
  27. sed 's/^X//' << 'SHAR_EOF' >> src/control/altparse.prs
  28. X        next;
  29. X    }
  30. X
  31. X    {
  32. X        # a file name, right?
  33. X        if ( first )
  34. X            first = False;
  35. X        else
  36. X            printf("%s\t%d\n", file, changect);
  37. X        changect = 0;
  38. X        file = $1;
  39. X    }
  40. X    END {
  41. X        printf("%s\t%d\n", file, changect);
  42. X    }
  43. X    ' | sed 's/:    /    /' | sed 's@/s\.@/@'
  44. Xdone
  45. SHAR_EOF
  46. echo "File src/control/altparse.prs is complete"
  47. chmod 0644 src/control/altparse.prs || echo "restore of src/control/altparse.prs fails"
  48. echo "x - extracting src/control/example_spec (Text)"
  49. sed 's/^X//' << 'SHAR_EOF' > src/control/example_spec
  50. X/usr/pascal/src/compiler *.[cy] /usr/pascal/sccs/compiler s.*.[cy]
  51. X/usr/pascal/src/compiler *.h /usr/pascal/sccs/include s.*.h
  52. X/usr/pascal/src/lib/Arith [a-z]* /usr/pascal/sccs/lib/Arith s.[a-z]*
  53. X/usr/pascal/src/lib/Data [a-z]* /usr/pascal/sccs/lib/Data s.[a-z]*
  54. X/usr/pascal/src/lib/Date [a-z]* /usr/pascal/sccs/lib/Date s.[a-z]*
  55. X/usr/pascal/src/lib/File [a-z]* /usr/pascal/sccs/lib/File s.[a-z]*
  56. X/usr/pascal/src/lib/Sets [a-z]* /usr/pascal/sccs/lib/Sets s.[a-z]*
  57. X/usr/pascal/src/lib/String [a-z]* /usr/pascal/sccs/lib/String s.[a-z]*
  58. X/usr/pascal/src/lib/Tran [a-z]* /usr/pascal/sccs/lib/Tran s.[a-z]*
  59. X/usr/pascal/src/lib/Util [a-z]* /usr/pascal/sccs/lib/Util s.[a-z]*
  60. X/usr/pascal/src/pc [a-z]*.[ch] /usr/pascal/sccs/pc s.[a-z]*.[ch]
  61. X/usr/pascal/src/errlist *.c /usr/pascal/sccs/errlist s.*.c
  62. SHAR_EOF
  63. chmod 0644 src/control/example_spec || echo "restore of src/control/example_spec fails"
  64. echo "x - extracting src/control/gather_stats (Text)"
  65. sed 's/^X//' << 'SHAR_EOF' > src/control/gather_stats
  66. X: gather up statistics on code
  67. X
  68. Xgotsccs=0
  69. Xgotsource=0
  70. Xgotroutine=0
  71. Xgotfile=0
  72. Xswitched=0
  73. Xfiles=""
  74. X
  75. Xwhile [ $# != 0 ]
  76. Xdo
  77. X    case $1 in
  78. X    -sccs)
  79. X        gotsccs=1
  80. X        sccsbase=$2
  81. X        sccsfiles="$3"
  82. X        shift
  83. X        shift ;;
  84. X    -source)
  85. X        gotsource=1
  86. X        sourcebase=$2
  87. X        sourcefiles="$3"
  88. X        shift
  89. X        shift ;;
  90. X    -routine)
  91. X        gotroutine=1
  92. X        routineout=$2
  93. X        shift ;;
  94. X    -file)
  95. X        gotfile=1
  96. X        fileout=$2
  97. X        shift ;;
  98. X    *)
  99. X        echo "usage: $0 -routine <routine-output-file> -file <file-output-file> -source <path> <filespec> -sccs <path> <filespec>"
  100. X        exit 1
  101. X    esac
  102. X    shift
  103. Xdone
  104. X
  105. Xif [ ${gotsccs} = 0 -a ${gotsource} = 0 ]
  106. Xthen
  107. X    echo "usage: $0 -routine <routine-output-file> -file <file-output-file> -source <path> <filespec> -sccs <path> <filespec>"
  108. X    exit 1
  109. Xfi
  110. Xif [ ${gotroutine} = 0 -o ${gotfile} = 0 ]
  111. Xthen
  112. X    echo "usage: $0 -routine <routine-output-file> -file <file-output-file> -source <path> <filespec> -sccs <path> <filespec>"
  113. X    exit 1
  114. Xfi
  115. X
  116. Xt_hal=/tmp/$$.halstead
  117. Xt_kdsi=/tmp/$$.kdsi
  118. Xt_chg=/tmp/$$.changes
  119. Xtemp=/tmp/$$.temp
  120. X
  121. Xtrap '/bin/rm -f ${t_hal} ${t_kdsi} ${t_chg} ${temp}; exit 1' 1 2 15
  122. X
  123. Xcd ${sourcebase}
  124. X
  125. X
  126. X# halstead output is Filename, Length, Volume, Level, and
  127. X# Effective mental discriminations;  in halstead terms, name, N, V, L, E^
  128. X#
  129. Xhalstead ${sourcefiles} | sort > ${t_hal}
  130. X#
  131. X# altkdsi output is actual source lines (DSI), comment count
  132. X#
  133. Xaltkdsi ${sourcefiles} | sort > ${t_kdsi}
  134. X
  135. X
  136. X
  137. Xcd ${sccsbase}
  138. X#
  139. X# altparse.prs output is filename, change count
  140. X#
  141. Xaltparse.prs ${sccsfiles} | sort > ${t_chg}
  142. Xcd ${sourcebase}
  143. X
  144. X
  145. X# joining halstead and kdsi info, note the tab seperator
  146. Xjoin -j1 1 -j2 1 -a1 -a2 -e '%%%' '-t    ' -o 1.1 1.3 2.2 2.3 ${t_hal} ${t_kdsi} > ${temp}
  147. X
  148. Xfgrep -s '%%%' ${temp}
  149. Xif [ $? != 1 ]
  150. Xthen
  151. X    echo "$0: unable to matchup files on join of halstead and kdsi"
  152. X    echo "  see files ${t_hal} ${t_kdsi} ${temp} (output)"
  153. X    /bin/rm -f ${t_chg}
  154. X    exit 1
  155. Xfi
  156. X
  157. X# joining halstead/kdsi and sccs info, note the tab seperator
  158. Xjoin -j1 1 -j2 1 -a1 -a2 -e '%%%' '-t    ' -o 1.1 2.2 1.2 1.3 1.4 ${temp} ${t_chg} > ${fileout}
  159. X
  160. Xfgrep -s '%%%' ${temp}
  161. Xif [ $? != 1 ]
  162. Xthen
  163. X    echo "$0: unable to matchup files on join of halstead/kdsi and changes"
  164. X    echo "  see files ${temp} ${t_chg} ${fileout}"
  165. X    /bin/rm -f ${t_hal} ${t_kdsi}
  166. X    exit 1
  167. Xfi
  168. X
  169. Xmccabe -n ${sourcefiles} | sort > ${routineout}
  170. X
  171. Xecho "file ${fileout} contains:"
  172. Xecho "filename changecount volume kdsi comments"
  173. Xecho " "
  174. Xecho "file ${routineout} contains:"
  175. Xecho "filename routinename mccabe returns adjusted/mccabe"
  176. X
  177. X/bin/rm -f ${t_hal} ${t_kdsi} ${t_chg} ${temp}
  178. Xexit 0
  179. SHAR_EOF
  180. chmod 0644 src/control/gather_stats || echo "restore of src/control/gather_stats fails"
  181. echo "x - extracting src/control/pascal_stats (Text)"
  182. sed 's/^X//' << 'SHAR_EOF' > src/control/pascal_stats
  183. X: collect statistics for pascal
  184. X
  185. Xsccs=/usr/pascal/sccs
  186. Xsourcebase=`pwd`
  187. Xgottarget=0
  188. X
  189. Xwhile [ $# -gt 0 ]
  190. Xdo
  191. X    case $1 in
  192. X    -sourcebase)
  193. X        sourcebase=$2
  194. X        shift ;;
  195. X    -target)
  196. X        gottarget=1
  197. X        target=$2
  198. X        shift ;;
  199. X    *)
  200. X        echo "usage: $0 -target <directory> [-sourcebase <directory>]"
  201. X        exit 1
  202. X    esac
  203. X    shift
  204. Xdone
  205. X
  206. Xbase=`pwd`
  207. Xcd ${sourcebase}
  208. Xroutine=${base}/@routine_defs
  209. Xfile=${base}/@file_defs
  210. X
  211. Xgather_stats -file ${file} -routine ${routine}\
  212. X    -source ${sourcebase} 'src/*.[cy]' -sccs ${sccs} 'src/s.*.[cy]'
  213. Xif [ $? != 0 ]
  214. Xthen
  215. X    echo "unable to gather statistics on the src directory"
  216. X    exit 1
  217. Xfi
  218. Xcat ${file} > ${target}/@file_defs
  219. Xcat ${routine} > ${target}/@routine_defs
  220. X
  221. Xgather_stats -file ${file} -routine ${routine}\
  222. X    -source ${sourcebase} 'include/*.h' -sccs ${sccs} 'include/s.*.h'
  223. Xif [ $? != 0 ]
  224. Xthen
  225. X    echo "unable to gather statistics on the include directory"
  226. X    exit 1
  227. Xfi
  228. Xcat ${file} >> ${target}/@file_defs
  229. Xcat ${routine} >> ${target}/@routine_defs
  230. X
  231. X
  232. Xgather_stats -file ${file} -routine ${routine}\
  233. X    -source ${sourcebase}/lib 'Arith/[a-z]*' -sccs ${sccs}/lib 'Arith/s.[a-z]*'
  234. Xif [ $? != 0 ]
  235. Xthen
  236. X    echo "unable to gather statistics on the Arith directory"
  237. X    exit 1
  238. Xfi
  239. Xcat ${file} >> ${target}/@file_defs
  240. Xcat ${routine} >> ${target}/@routine_defs
  241. X
  242. Xgather_stats -file ${file} -routine ${routine}\
  243. X    -source ${sourcebase}/lib 'Data/[a-z]*' -sccs ${sccs}/lib 'Data/s.[a-z]*'
  244. Xif [ $? != 0 ]
  245. Xthen
  246. X    echo "unable to gather statistics on the Data directory"
  247. X    exit 1
  248. Xfi
  249. Xcat ${file} >> ${target}/@file_defs
  250. Xcat ${routine} >> ${target}/@routine_defs
  251. X
  252. Xgather_stats -file ${file} -routine ${routine}\
  253. X    -source ${sourcebase}/lib 'Date/[a-z]*' -sccs ${sccs}/lib 'Date/s.[a-z]*'
  254. Xif [ $? != 0 ]
  255. Xthen
  256. X    echo "unable to gather statistics on the Date directory"
  257. X    exit 1
  258. Xfi
  259. Xcat ${file} >> ${target}/@file_defs
  260. Xcat ${routine} >> ${target}/@routine_defs
  261. X
  262. Xgather_stats -file ${file} -routine ${routine}\
  263. X    -source ${sourcebase}/lib 'File/[a-z]*' -sccs ${sccs}/lib 'File/s.[a-z]*'
  264. Xif [ $? != 0 ]
  265. Xthen
  266. X    echo "unable to gather statistics on the File directory"
  267. X    exit 1
  268. Xfi
  269. Xcat ${file} >> ${target}/@file_defs
  270. Xcat ${routine} >> ${target}/@routine_defs
  271. X
  272. Xgather_stats -file ${file} -routine ${routine}\
  273. X    -source ${sourcebase}/lib 'Sets/[a-z]*' -sccs ${sccs}/lib 'Sets/s.[a-z]*'
  274. Xif [ $? != 0 ]
  275. Xthen
  276. X    echo "unable to gather statistics on the Sets directory"
  277. X    exit 1
  278. Xfi
  279. Xcat ${file} >> ${target}/@file_defs
  280. Xcat ${routine} >> ${target}/@routine_defs
  281. X
  282. Xgather_stats -file ${file} -routine ${routine}\
  283. X    -source ${sourcebase}/lib 'String/[a-z]*' -sccs ${sccs}/lib 'String/s.[a-z]*'
  284. Xif [ $? != 0 ]
  285. Xthen
  286. X    echo "unable to gather statistics on the String directory"
  287. X    exit 1
  288. Xfi
  289. Xcat ${file} >> ${target}/@file_defs
  290. Xcat ${routine} >> ${target}/@routine_defs
  291. X
  292. Xgather_stats -file ${file} -routine ${routine}\
  293. X    -source ${sourcebase}/lib 'Tran/[a-z]*' -sccs ${sccs}/lib 'Tran/s.[a-z]*'
  294. Xif [ $? != 0 ]
  295. Xthen
  296. X    echo "unable to gather statistics on the Tran directory"
  297. X    exit 1
  298. Xfi
  299. Xcat ${file} >> ${target}/@file_defs
  300. Xcat ${routine} >> ${target}/@routine_defs
  301. X
  302. Xgather_stats -file ${file} -routine ${routine}\
  303. X    -source ${sourcebase}/lib 'Util/[a-z]*' -sccs ${sccs}/lib 'Util/s.[a-z]*'
  304. Xif [ $? != 0 ]
  305. Xthen
  306. X    echo "unable to gather statistics on the Util directory"
  307. X    exit 1
  308. Xfi
  309. Xcat ${file} >> ${target}/@file_defs
  310. Xcat ${routine} >> ${target}/@routine_defs
  311. X
  312. X
  313. Xgather_stats -file ${file} -routine ${routine}\
  314. X    -source ${sourcebase} 'pc/[a-z]*.[ch]' -sccs ${sccs} 'pc/s.[a-z]*.[ch]'
  315. Xif [ $? != 0 ]
  316. Xthen
  317. X    echo "unable to gather statistics on the pc directory"
  318. X    exit 1
  319. Xfi
  320. Xcat ${file} >> ${target}/@file_defs
  321. Xcat ${routine} >> ${target}/@routine_defs
  322. X
  323. Xgather_stats -file ${file} -routine ${routine}\
  324. X    -source ${sourcebase} 'errlist/*.c' -sccs ${sccs} 'errlist/s.*.c'
  325. Xif [ $? != 0 ]
  326. Xthen
  327. X    echo "unable to gather statistics on the errlist directory"
  328. X    exit 1
  329. Xfi
  330. Xcat ${file} >> ${target}/@file_defs
  331. Xcat ${routine} >> ${target}/@routine_defs
  332. SHAR_EOF
  333. chmod 0644 src/control/pascal_stats || echo "restore of src/control/pascal_stats fails"
  334. echo "x - extracting src/control/proj_stats (Text)"
  335. sed 's/^X//' << 'SHAR_EOF' > src/control/proj_stats
  336. X: collect statistics for the system
  337. X# parameters:
  338. X#  -sourcebase <directory> - <directory> is the root directory for the code
  339. X#  -target <directory>     - <directory> is where to put the results of analysis
  340. X#                            (the function and file analysis results)
  341. SHAR_EOF
  342. echo "End of part 4"
  343. echo "File src/control/proj_stats is continued in part 5"
  344. echo "5" > s2_seq_.tmp
  345. exit 0
  346.  
  347.  
  348.