#!/bin/sh -
#
# $Id: chk.define,v 1.8 2000/12/12 18:20:59 bostic Exp $
#
# Check to make sure that all #defines are actually used.

# Run from the top-level directory.
[ -f db_config.h ] && cd ..

t1=/tmp/__1

egrep '^#define' include/*.h |
    sed -e '/db_185.h/d' -e '/xa.h/d' |
    awk '{print $2}' |
    sed -e '/^B_DELETE/d' \
	-e '/^B_MAX/d' \
	-e '/^CIRCLEQ/d' \
	-e '/^DB_RO_ACCESS/d' \
	-e '/^DEFINE_DB_CLASS/d' \
	-e '/^LIST/d' \
	-e '/^LOG_OP/d' \
	-e '/^MINFILL/d' \
	-e '/^MUTEX_FIELDS/d' \
	-e '/^NCACHED2X/d' \
	-e '/^NCACHED30/d' \
	-e '/^PAIR_MASK/d' \
	-e '/^POWER_OF_TWO/d' \
	-e '/^P_16_COPY/d' \
	-e '/^P_32_COPY/d' \
	-e '/^P_32_SWAP/d' \
	-e '/^SH_CIRCLEQ/d' \
	-e '/^SH_LIST/d' \
	-e '/^SH_TAILQ/d' \
	-e '/^TAILQ/d' \
	-e '/UNUSED/d' \
	-e '/^WRAPPED_CLASS/d' \
	-e '/^XA_$/d' \
	-e '/^_DB_SERVER_H_RPCGEN/d' \
	-e '/_AUTO_H$/d' \
	-e '/_H_$/d' \
        -e '/ext_h_/d' \
        -e '/^i_/d' \
	-e 's/(.*//' | sort > ${t1}

for i in `cat ${t1}`; do
	if egrep -w $i */*.c */*.cpp > /dev/null; then
		:;
	else
		f=`egrep -l $i include/*.h |
		    sed 's;include/;;' | tr -s "[:space:]" " "`
		echo "$i: $f"
	fi
done | sort +1

rm -f ${t1}
