#!/bin/sh
# Computes Java sloc in the listed directories.
# each directory must contain ansic_list.dat and cpp_list.dat.

# Change the following if it's the wrong place:

JAVA_DATA_ENV_FILE="/home/dwheeler/sloc/bin/java_lines_environment.dat"

# Unfortunately, USC's code fails when c_list.dat is 0-length,
# so we work around it.


starting_dir=`pwd`

for dir in $@
do
 if [ -d "$dir" -a -r "${dir}/filelist" ]
 then
  cd $dir
  cp $JAVA_DATA_ENV_FILE .

  if [ -s java_list.dat ]
  then
   java_lines
   extract-count < java_outfile.dat
   mv logical.sloc java-logical.sloc
   mv physical.sloc java-physical.sloc
  else
   echo 0 > java-logical.sloc
   echo 0 > java-physical.sloc
  fi

  cd $starting_dir
 fi
done
