T=errorin.tmp
E=errorex.tmp
Z=zap.tmp
trap 'rm -f error.? $T $E $Z;exit' 0 1 2 3 4 14
echo "g/^extern/m?EXTERN?p|/###/" > extern.tmp
cat - > $T <<\TAIL
BEGIN{
	prevfile = "NONE";
	}
/^Warning/{
	error = 1
	}
/^Error/{
	error = 1
	}
	{
	if(error == 0)	next
	if($2 !~ prevfile)	{
		if(errcnt)	printf("w\n");
		errcnt = 0;
		printf("e %s\n",$2);
		printf("f\n");
		printf("%s\n",$2) > "filelist.tmp";
		}
	printf("%di\n",$3);
	printf("/* ### %s === */\n",$0);
	printf(".\n");
	errcnt += 1;
	prevfile = $2
	error = 0
	}
END{
	printf("wq\n");
	}
TAIL
S='
/^Warning/p
/^Error/p
'
sed -n -e "$S" error.? | sort +1 -2dfb +2 -3nbr > $Z
if test ! -s $Z
then
echo "no errors"
exit
else
vi +1 $Z
fi
if test -s $Z
then
awk -f $T $Z | tee $E | vi -e -
vi +1 `cat filelist.tmp`
cat - > $T <<\TAIL
/ === /d
TAIL
ksedit -f $T `cat filelist.tmp`
echo "tcc -c $CHGLIST" > recompile.tmp
echo "($0) <changed file list> recompile.tmp"
fi
