# MK_CDECLIST

DEFAULTDIR="."
CDIR=`dirname $1`
if [ ${CDIR} = "." ]
then
	CDIR=${DEFAULTDIR}
fi
HDIR=${CDIR}
CDECLIST=""
#option: if define LLOUT="Sall.1", then output concatenated onto Sall.1;
#else get individual output files with prefix "LL";
LLOUT="Sall.1"
#LLOUT="dumdumdum"

for i in $*
do
	FILE=`basename ${i}`
	echo processing file: $i >&2
	if [ ${LLOUT} != "Sall.1" ]
	then
		LLOUT=LL${FILE}
		CDECLIST="${CDECLIST} ${LLOUT}"
	fi
	echo "\n\n/*********************************************/\n" >>${LLOUT}
	echo /*${FILE}*/ >>${LLOUT}
	echo >>${LLOUT}
	cat ${CDIR}/${FILE}|uncomment|cdeclist1|/lib/cpp -P -C -I${HDIR}|
		cdeclist2|cdeclist3|cdeclist4 >>${LLOUT}
done

#temporary++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
exit

#NOTE: what follows is an example of manipulation of the cdeclist output.

#the following cats a list of separate "LL" files onto Sall.1
echo
echo +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo combining files: ${CDECLIST}
>Sall.1
for i in ${CDECLIST}
do

	cat ${i} >>Sall.1
done

#the following extracts a list of function definitions _only_;
#(no static or external declarations; no definitions of arrays/vars/structs);
#collect comment header lines, functions, and struct declarations;
#get rid of register specs;
#strip any variable declarations trailing struct declarations;
#change return (n) -> return (0), so ok for return of pointers;
#insert VARARGS where needed;
#to include structure definitions, add to 1st egrep: |struct[ ]+[^;({]+\{
#remove several functions with "static" scope -- and that give errors in
#compilation without struct definitions (same scope);
#this gives a partial lint library - full library needs array/variables;

cat Sall.1|egrep '\/\*[^L]|\{\}|\ return[ ;]' |
	egrep -v '^static\ |INITIALIZED' |
	egrep -v '\ engr_at[(]|^del_engr[(]|\ outentry[(]|^ini_inv[(]' |
	sed -e "s/register[ ]\([^;, ][^;, ]*[;,]\)/int\ \1/g"	\
		-e "s/register[ ]//g"	\
		-e "s/\}[^;}]*\;$/\}\ \;/"	\
		-e "s/return\ .[1-3]./return\ \(0\)/g"	\
		-e "s/^panic/\/\*VARARGS1\*\/\\
panic/"	\
		-e "s/^error/\/\*VARARGS1\*\/\\
error/"	\
		-e "s/^pline/\/\*VARARGS1\*\/\\
pline/"	\
		-e "s/^impossible/\/\*VARARGS1\*\/\\
impossible/p" >Sall.2

