1#!/bin/tcsh -f 2set ll = ( '*.[ch]' 'SUMA/*.[ch]' \ 3 'cox*/*.[ch]' 'rickr/*.[ch]' \ 4 'avovk/*.[ch]' 'gifti/*.[ch]' \ 5 'matlab/*.m' 'python_scripts/*.py' \ 6 'R_scripts/*.R' 'niml/*.[ch]' \ 7 'svm/*.[ch]' 'nifti/*.[ch]' ) 8 9if ($1 =~ -h*) then 10 echo "Counts lines of code in AFNI distribution." 11 echo "Files counted include:" 12 set cnt = 1 13 while ($cnt <= $#ll) 14 printf "\t%s\n" "$ll[$cnt]" 15 @ cnt ++ 16 end 17 printf "\n" 18 echo "Output is self explantory and 1Dish." 19 echo "" 20 echo "Script should be executed from the src/ directory" 21 echo "" 22 set stat = 0 23 goto END 24endif 25 26if ( ! -f afni.c || ! -d SUMA || ! -d rickr ) then 27 echo "Looks like you are not in the AFNI src directory" 28 set stat = 1 29 goto END 30endif 31 32set tblnk = ___blnk.1D 33set tn = ___nblnk.1D 34if ( -f $tn ) rm ./$tn 35if ( -f $tblnk ) rm ./$tblnk 36 37#full count, with blanks 38foreach lll ($ll) 39 set fls = ($lll) 40 wc -l $fls >> $tblnk 41end 42set N_blnkMC = `3dBrickStat -slow -mean -count $tblnk'[0]'` 43#full count, without blanks 44foreach lll ($ll) 45 set fls = ($lll) 46 foreach ff ($fls) 47 set numi = `cat $ff | sed '/^\s*$/d' | wc -l ` 48 echo $numi $ff >> $tn 49 end 50end 51set N_nMC = `3dBrickStat -slow -mean -count $tn'[0]'` 52 53set N_blnk = `ccalc -i "$N_blnkMC[1] * $N_blnkMC[2]"` 54set N_n = `ccalc -i "$N_nMC[1] * $N_nMC[2]"` 55 56echo "$N_blnk #lines of code including blanks" 57echo "$N_n #lines of code without blanks" 58echo "$N_blnkMC[2] #Number of files counted" 59set stat = 0 60 61if ( -f $tn ) rm ./$tn 62if ( -f $tblnk ) rm ./$tblnk 63 64goto END 65 66END: 67exit $stat 68