#################################################################
# normalize a file before running diff or checking file in
#	change leading blanks/tabs to tabs
#	remove trailing blanks
#	be sure file ends in a newline
#################################################################

# change leading blanks/tabs to tabs
unexpand $1 >tmp.$$
rm -f $1

# add newline to end
echo >>tmp.$$

# remove trailing white space, delete last line if empty
# for readers without x-ray vision: within the brackets is a space, then
# a tab
sed '1,$s/[ 	]*$//
${
/^$/d
}' <tmp.$$ >$1

# cleanup
rm -f tmp.$$
