#!/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/sccs_h/d'
		echo 'g/sccs_id/d'
		echo 'g/static char ID'$g'\[\]/d'
		echo 'g/static char .*_sccs_id\[/d'
		echo 'g/^:[DdTt]	/d'
		echo '1,/^#/-1d'
		echo '1'
		echo 'i'
	#	cat /home1/gbs202/nmadmin/headers/csource.hdr
	#	echo ':i	static char '$g'_sccs_id[] = "%W% %G%' $g '";'
	#	echo ':i	/* '$g'_sccs_id[] = "%W% %G%" */'
		echo '.'
		echo 'g/^		*\([DHPSV]\)\([0-9]\)(.*);/s//:\2&/'
		echo 'w'
		echo 'q'
	} | ed - $f 
done
