#! /bin/sh

#================================================================
# diffcheck
# List files different from ones of another version.
#================================================================


# set variables
LANG=C ; export LANG
LC_ALL=C ; export LC_ALL
PATH="$PATH:/usr/local/bin:.:.." ; export PATH
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib:.:..:../.." ; export LD_LIBRARY_PATH
progname="diffcheck"
progexts='\.in|\.h|\.c|\.cc|\.cpp|\.cxx|\.java|\.pl|\.pm|\.pod|\.rb|\.rd'
docexts='\.[1-9]|spex\.html|\spex-ja\.html|\.txt'
regex="($progexts|$docexts)\$"


# check arguments
if [ $# != 1 ]
then
  printf '%s: usage: %s directory_of_oldversion\n' "$progname" "$progname" 1>&2
  exit 1
fi


# diff files
find . -type f | egrep $regex |
while read file
do
  old=`printf '%s\n' "$file" | sed 's/^\.\///'`
  printf 'Checking %s and %s ... ' "$file" "$1/$old"
  res=`diff -q "$file" "$1/$old"`
  if [ -z "$res" ]
  then
    printf 'same\n'
  else
    printf '### !!! DIFFERENT !!! ###\n'
  fi
done


# exit normally
exit 0



# END OF FILE
