#!/bin/csh -f

set FILES

while($#argv)
	switch ("$1")
	case -v:
		set VERBOSE
		shift
		breaksw
	default:
		if (-r $1) then
			set FILES = ( $FILES $1 )
			shift
		else
			set DQ = '"'
			exec echo ${0}: "What do I do with $DQ$1$DQ?"
		endif
		breaksw
	endsw
end

set BASE = `basename $0`
set AFILE = /tmp/$BASE.awk.$$

cp /dev/null $AFILE

if ($?VERBOSE) then
	cat >> $AFILE << FOO
BEGIN	{
	VERBOSE = 1
	}
FOO
endif

cat >> $AFILE << FOO
	{
	l = length(\$0)
	if (l > ml) {
		ml = l
		mln = NR
		mll = \$0
		}
	}
END	{
	if (VERBOSE) {
		print "Line",mln,"of",FILENAME,"contains",ml,"chars:"
		print mll
		}
	else {
		print ml
		}
	}
FOO

foreach FILE ( $FILES )
	awk -f $AFILE $FILE
end

/bin/rm -f $AFILE
