00001 #!/bin/sh -
00002 #
00003 # $Id: chk.inc,v 12.0 2004/11/17 03:44:51 bostic Exp $
00004 #
00005 # Check for inclusion of db_config.h after "const" or other includes.
00006
00007 d=../..
00008
00009 # Test must be run from the top-level directory, not from a test directory.
00010 [ -f $d/LICENSE ] || {
00011 echo 'FAIL: cannot find source distribution directory.'
00012 exit 1
00013 }
00014
00015 t1=__1
00016 t2=__2
00017
00018 (cd $d && find . -name '*.[chys]' -o -name '*.cpp' |
00019 xargs egrep -l '#include.*db_config.h') | tee /tmp/o |
00020 sed -e '/dbdemo.c$/d' \
00021 -e '/db_java_wrap.c$/d' > $t1
00022
00023 (for i in `cat $t1`; do
00024 egrep -w 'db_config.h|const' /dev/null $d/$i | head -1
00025 done) > $t2
00026
00027 if egrep const $t2 > /dev/null; then
00028 echo 'FAIL: found const before include of db_config.h'
00029 egrep const $t2
00030 exit 1
00031 fi
00032
00033 :> $t2
00034 for i in `cat $t1`; do
00035 egrep -w '#include' /dev/null $d/$i | head -1 >> $t2
00036 done
00037
00038 if egrep -v db_config.h $t2 > /dev/null; then
00039 echo 'FAIL: found includes before include of db_config.h'
00040 egrep -v db_config.h $t2
00041 exit 1
00042 fi
00043
00044 exit 0