#! /bin/csh -f # Last edited on 2001-05-14 01:01:34 by stolfi set usage = "$0 [RA]" # Summarizes source sizes and changes for the MP004 project hand-ins. # Reads files # ras.txt : numbers of all registered students (if the RA arg is not given). # dates.txt : dates (MM-DD) for which there are hand-ins # ${ra}/.src/${day}-{ini,fin}.pvs = Collected .pov and .inc sources for ${day}, # cleaned, sorted and uniquified. # discount.pvs = source lines that should not be counted. # For each student and each day, writes files # ${ra}/.src/${day}-hom.pvs = Lines written at home prior to today. # ${ra}/.src/${day}-cls.pvs = Lines written on that day. # ${ra}/.src/${day}-dif.pvs = Lines written since end of previous day. # For each student, writes summary ${ra}/.pov-sizes # containing the number of code lines written each day by the student. if ( $#argv > 1 ) then echo "usage: ${usage}"; exit 1 endif # Get student numbers if ( $#argv < 1 ) then set rafile = "ras.txt" set ras = ( `cat ${rafile} | egrep -v '^ *([#]|$)'` ) else set ras = ( "$1" ); shift endif # Extract and clean up the commands that should not be counted if ( ! ( -r discount.pov ) ) then echo "file discount.pov not found"; exit 1 endif cat discount.pov \ | cleanup-povray-source \ | sort | uniq \ > discount.pvs set days = ( `cat dates.txt` ) foreach ra ( ${ras} ) # Directory where the cleaned-up source files are: set srcdir = ${ra}/.src echo "${srcdir}..." if ( ! ( -d ${srcdir} ) ) then echo "directory ${srcdir} not found"; exit 1 endif # Summary file for this student set ofile = "${srcdir}/.sizes" if ( -e ${ofile} ) then /bin/mv ${ofile} ${ofile}~ endif printf "# %6s %5s %7s %7s %7s %7s %7s\n" \ "RA" "day" "ini" "fin" "hom" "cls" "dif" \ > ${ofile} printf "# %6s %5s %7s %7s %7s %7s %7s\n" \ "------" "-----" "----" "----" "----" "----" "----" \ >> ${ofile} # Var `$lastany' is the last subdirectory with non-empty sources set lastany = "/dev/null" foreach day ( $days ) # File name prefix for the sorted source files set raday = "${srcdir}/${day}" # Compute the changes in class today: if ( ! ( ( -z ${raday}-ini.pvs ) || ( -z ${raday}-fin.pvs ) ) ) then bool 1-2 ${raday}-{fin,ini}.pvs > ${raday}-cls.pvs else cat /dev/null > ${raday}-cls.pvs endif # Compute the changes at home: if ( ! ( -z ${raday}-ini.pvs ) ) then bool 1-2 ${raday}-ini.pvs ${lastany} > ${raday}-hom.pvs else if ( ! ( -z ${raday}-fin.pvs ) ) then bool 1-2 ${raday}-fin.pvs ${lastany} > ${raday}-hom.pvs else cat /dev/null > ${raday}-hom.pvs endif # Compute the changes since last day: if ( ! ( -z ${raday}-fin.pvs ) ) then bool 1-2 ${raday}-fin.pvs ${lastany} > ${raday}-dif.pvs set lastany = ${raday}-fin.pvs else if ( ! ( -z ${raday}-ini.pvs ) ) then bool 1-2 ${raday}-ini.pvs ${lastany} > ${raday}-dif.pvs set lastany = ${raday}-ini.pvs else cat /dev/null > ${raday}-dif.pvs endif # Compute the number of bytes and number of (average-size) lines set cini = `bool 1-2 ${raday}-ini.pvs discount.pvs | wc -c` @ nini = ${cini} / 20 set cfin = `bool 1-2 ${raday}-fin.pvs discount.pvs | wc -c` @ nfin = ${cfin} / 20 set chom = `bool 1-2 ${raday}-hom.pvs discount.pvs | wc -c` @ nhom = ${chom} / 20 set ccls = `bool 1-2 ${raday}-cls.pvs discount.pvs | wc -c` @ ncls = ${ccls} / 20 set cdif = `bool 1-2 ${raday}-dif.pvs discount.pvs | wc -c` @ ndif = ${cdif} / 20 printf " %6s %5s %7d %7d %7d %7d %7d\n" \ "${ra}" "${day}" "${nini}" "${nfin}" "${nhom}" "${ncls}" "${ndif}" \ >> ${ofile} end end