summaryrefslogtreecommitdiff
path: root/db-4.8.30/test/scr003/chk.define
blob: 52bf42134204ab65d182ec31c2cd28db54e4f0ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh -
#
# $Id$
#
# Check to make sure that all #defines are actually used.
# Check to make sure that all #defines start in column 1.

d=../..

[ -f $d/LICENSE ] || {
	echo 'FAIL: cannot find source distribution directory.'
	exit 1
}

exitv=0
t1=__1
t2=__2
t3=__3

find $d -name '*.c' -o -name '*.cpp' |
    sed -e '/\/php_db4\//d' |
    xargs egrep '^[	 ][	 ]*#' > $t1
test -s $t1 && {
	echo "FAIL: found #defines with leading white space:"
	cat $t1
	exit 1
}

egrep '^#define' $d/dbinc/*.h $d/dbinc/*.in |
    sed -e '/db_185.in/d' -e '/queue.h/d'  |
    awk '{print $2}' |
    sed -e '/^AI_CANONNAME/d' \
	-e '/^AI_NUMERICHOST/d' \
	-e '/^B_DELETE/d' \
	-e '/^B_MAX/d' \
	-e '/^CHECK_THREAD/d' \
	-e '/^DB_BTREEOLDVER/d' \
	-e '/^DB_DEGREE_2/d' \
	-e '/^DB_HASHOLDVER/d' \
	-e '/^DB_LOCKVERSION/d' \
	-e '/^DB_LOG_PERM_42_44/d' \
	-e '/^DB_LOG_RESEND_42_44/d' \
	-e '/^DB_MAX_PAGES/d' \
	-e '/^DB_PAGE_QUEUE_LEN/d' \
	-e '/^DB_QAMOLDVER/d' \
	-e '/^DB_RETURNS_A_KEY_HASH/d' \
	-e '/^DB_SPARE_FLAG/d' \
	-e '/^DB_TXNVERSION/d' \
	-e '/^DB_UNUSED/d' \
	-e '/^DEFINE_DB_CLASS/d' \
	-e '/^FHASH/d' \
	-e '/^HASH_UNUSED/d' \
	-e '/^HPUX_MUTEX_PAD/d' \
	-e '/^LOG_OP/d' \
	-e '/^MAX_ID/d' \
	-e '/^MAXHOSTNAMELEN/d' \
	-e '/^MINFILL/d' \
	-e '/^MUTEX_FIELDS/d' \
	-e '/^MUTEX_LOCK_PARTITION/d' \
	-e '/^MUTEX_UNLOCK_PARTITION/d' \
	-e '/^NAME_TO_SEQUENCE/d' \
	-e '/^NCACHED2X/d' \
	-e '/^NCACHED30/d' \
	-e '/^PAIR_MASK/d' \
	-e '/^P_16_COPY/d' \
	-e '/^P_32_COPY/d' \
	-e '/^P_32_SWAP/d' \
	-e '/^P_64_COPY/d' \
	-e '/^P_64_SWAP/d' \
	-e '/^P_TO_UINT16/d' \
	-e '/^QPAGE_CHKSUM/d' \
	-e '/^QPAGE_NORMAL/d' \
	-e '/^QPAGE_SEC/d' \
	-e '/^SIZEOF_PAGE/d' \
	-e '/^TAILQ_/d' \
	-e '/^UINT64_FMT/d' \
	-e '/^UINT64_MAX/d' \
	-e '/^VM_PAGESIZE/d' \
	-e '/^WRAPPED_CLASS/d' \
	-e '/^_WIN32_WINNT/d' \
	-e '/^__BIT_TYPES_DEFINED__/d' \
	-e '/^__DBC_INTERNAL/d' \
	-e '/^__STDC__/d' \
	-e '/^__lock_locker_hash/d' \
	-e '/^i_/d' \
	-e '/_H_/d' \
	-e 's/(.*//' | sort > $t1

find $d -name '*.c' -o -name '*.cpp' > $t2
for i in `cat $t1`; do
	if egrep -w $i `cat $t2` > /dev/null; then
	    :;
	else
	    f=`egrep -l "#define.*$i" $d/dbinc/*.h  $d/dbinc/*.in |
	    sed 's;\.\.\/\.\.\/dbinc/;;' | tr -s "[:space:]" " "`
	    echo "FAIL: $i: $f"
	fi
done | sort -k 2 > $t3

test -s $t3 && {
	cat $t3
	echo "FAIL: found unused #defines"
	exit 1
}

exit $exitv