#! /bin/csh -f # Last edited on 2001-01-29 18:34:15 by stolfi set usage = "$0 [RA]" # Extracts cleaned-up source files for the MC930 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 # For each student and each day, writes files # ${ra}/.src/${day}-{ini,fin}.pvc = Collected .pov and .inc sources for ${day}. # ${ra}/.src/${day}-{ini,fin}.pvs = Ditto, sorted and uniquified. # The ".pvc" files have all comments removed and blanks squeezed out. # The ".pvs" files may include lines from the starting .pov. # Missing ${day}-ini or ${day}-fin directories are treated as empty sources. 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 set days = ( `cat dates.txt` ) foreach ra ( ${ras} ) # Directory whre the cleaned-up source files are: set srcdir = ${ra}/.src if ( ! ( -d ${srcdir} ) ) mkdir ${srcdir} echo "${srcdir}..." foreach day ( $days ) # File name prefix for the sorted source files set raday = "${srcdir}/${day}" # Find and cleanup the source files: foreach phase ( "ini" "fin" ) set subdir = "${day}-${phase}" set dir = "${ra}/${subdir}" # Ckeck if the POV-ray source exists: if ( -d ${dir} ) then cat '/dev/null' > ${dir}/dummy.inc if ( -r ${dir}/main-orig.pov ) then set sources = ( ${dir}/main-orig.pov ${dir}/*.inc ) else if ( -r ${dir}/main.pov ) then set sources = ( ${dir}/main.pov ${dir}/*.inc ) else set sources = ( /dev/null ) endif else set sources = ( /dev/null ) endif # Extract and clean up the commands cat ${sources} \ | cleanup-povray-source \ > ${raday}-${phase}.pvc cat ${raday}-${phase}.pvc \ | sort | uniq \ > ${raday}-${phase}.pvs end end end