: #!/bin/sh
# Make an assortment of modifications to a list of .b files (the args).
# This is mostly used to convert .c files to .b files, but you may also
# feed it .b files directly.  Note that this script searches out calls 
# of the 2-byte debug-output macros in dbg.h, and inserts a ';' and the
# debug level at column 1.  This is usually safe, but there are a few
# cases where the resulting C is invalid when the line is suppressed.
# It's a real good idea to compile at the :0 level at least once.

for f
do	echo File: $f
	Cp $f $f.bak
	{	g=`expr $f : '\(.*\)\.'`
		echo 'g/SccsID/d'
		echo 'g/static char ID'$g'\[\]/d'
		echo 'g/^:t	/d'
		echo '1'
		echo 'i'
		echo 'static char ID'$g'[] = "@(#)'$g' %D";'
		echo '.'
		echo 'g/^		*\([DHPSV]\)\([0-9]\)(.*);/s//:\2&/'
		echo 'w'
		echo 'q'
	} | ed - $f 
done
