1#!/bin/sh -
2#
3# $Id$
4#
5# Check flag name-spaces.
6
7d=../..
8t1=__1
9t2=__2
10
11if cc -g -Wall -I.. t.c -o t; then
12	:
13else
14	echo "FAIL: unable to compile test program t.c"
15	exit 1
16fi
17
18if ./t $d/*/*.[ch] $d/*/*.in > $t1; then
19	:
20else
21	echo "FAIL: test program failed"
22	exit 1
23fi
24
25echo 'Checking "dbenv" variables with flags other than DB_ENV_XXX'
26grep 'dbenv,' $t1 |
27sed -e '/DB_ENV_/d' \
28    -e '/env_method.c.*, mapped_flags*)/d' \
29    -e '/env_region.c.*, flags_orig*)/d' \
30    > $t2
31[ -s $t2 ] && {
32	cat $t2
33	exit 1
34}
35
36echo 'Checking DB_ENV_XXX flags with variables other than "dbenv"'
37grep 'DB_ENV_' $t1 |
38sed -e '/dbenv,/d' \
39    -e '/(dbenv),/d' \
40    > $t2
41[ -s $t2 ] && {
42	cat $t2
43	exit 1
44}
45
46echo 'Checking "env" variables with flags other than ENV_XXX'
47grep '[^b]env,' $t1 |
48sed -e '/[^B]ENV_/d' \
49    -e '/env_method.c.*, mapped_flags*)/d' \
50    > $t2
51[ -s $t2 ] && {
52	cat $t2
53	exit 1
54}
55
56echo 'Checking ENV_XXX flags with variables other than "env"'
57grep '[^A-Z_]ENV_' $t1 |
58sed -e '/[^b]env,/d' \
59    -e '/(env),/d' \
60    > $t2
61[ -s $t2 ] && {
62	cat $t2
63	exit 1
64}
65
66echo 'Checking dbenv "verbose" field with flags other than DB_VERB_XXX'
67grep -- 'dbenv->verbose,' $t1 |
68sed -e '/DB_VERB_/d' \
69    -e '/env_method.c.*, which)/d' \
70    > $t2
71[ -s $t2 ] && {
72	cat $t2
73	exit 1
74}
75
76echo 'Checking DB_VER_XXX flags with other than dbenv "verbose" field'
77grep -- 'DB_VERB_' $t1 |
78sed -e '/dbenv->verbose,/d' \
79    > $t2
80[ -s $t2 ] && {
81	cat $t2
82	exit 1
83}
84
85echo 'Checking "db" variables with flags other than DB_AM_XXX'
86cp $t1 /tmp/_f
87grep 'dbp,' $t1 |
88sed -e '/DB_AM_/d' \
89    -e '/dbp, mapped_flag)/d' \
90    > $t2
91[ -s $t2 ] && {
92	cat $t2
93	exit 1
94}
95
96echo 'Checking DB_AM_XXX flags with variables other than "db"'
97grep 'DB_AM_' $t1 |
98sed \
99    -e '/(&db,/d' \
100    -e '/(db,/d' \
101    -e '/_method.c:.*outflagsp,/d' \
102    -e '/partition.c:.*pdbp,/d' \
103    -e '/rep_backup.c:.*->flags,/d' \
104    -e /'rep_backup.c:.*->db_flags,/d' \
105    -e '/db.c:.*save_flags,/d' \
106    -e '/((*[	 ]*db_rep->rep_db)*,/d' \
107    -e '/((*[	 ]*dbc)*->dbp,/d' \
108    -e '/((*[	 ]*dbc_arg->dbp)*,/d' \
109    -e '/((*[	 ]*dbp)*,/d' \
110    -e '/((*[	 ]*dbp)*->s_primary,/d' \
111    -e '/((D),/d' \
112    -e '/((sdbp),/d' \
113    -e '/(fdbp,/d' \
114    -e '/(file_dbp,/d' \
115    -e '/(ldbp,/d' \
116    -e '/(msgfp->db_flags,/d' \
117    -e '/(mdbp,/d' \
118    -e '/(pdbp,/d' \
119    -e '/(pginfo, /d' \
120    -e '/(rfp->db_flags,/d' \
121    -e '/(sdbp,/d' \
122    -e '/(subdbp,/d' \
123    -e '/fop_util.c:.*(t2dbp,/d' \
124    -e '/fop_util.c:.*(tmpdbp,/d' \
125    > $t2
126[ -s $t2 ] && {
127	cat $t2
128	exit 1
129}
130
131echo 'Checking "dbc" variables flags with flags other than DBC_XXX'
132echo Checking DBC flags...
133cat $t1 |
134grep 'dbc,' |
135sed -e '/DBC_/d' \
136    -e '/db_cam.c:.*tmp_read_locking)/d' 
137    > $t2
138[ -s $t2 ] && {
139	cat $t2
140	exit 1
141}
142
143echo 'Checking DBC_XXX flags with variables other than "dbc"'
144grep 'DBC_' $t1 |
145sed -e '/((*dbc)*,/d' \
146    -e '/(dbc_arg,/d' \
147    -e '/(dbc_c,/d' \
148    -e '/(dbc_n,/d' \
149    -e '/(dbc_orig,/d' \
150    -e '/(opd,/d' \
151    -e '/(pdbc,/d' \
152    -e '/[(*]put_state[p]*,/d' \
153    -e '/(sdbc,/d' \
154    -e '/partition.c:.*_dbc,/d' \
155    -e '/partition.c:.*_cursor,/d'
156    > $t2
157[ -s $t2 ] && {
158	cat $t2
159	exit 1
160}
161
162echo Checking for bad use of macros...
163egrep 'case .*F_SET\(|case .*F_CLR\(' $d/*/*.c > $t1
164egrep 'for .*F_SET\(|for .*F_CLR\(' $d/*/*.c >> $t1
165egrep 'if .*F_SET\(|if .*F_CLR\(' $d/*/*.c >> $t1
166egrep 'switch .*F_SET\(|switch .*F_CLR\(' $d/*/*.c >> $t1
167egrep 'while .*F_SET\(|while .*F_CLR\(' $d/*/*.c >> $t1
168[ -s $t1 ] && {
169	echo 'if statement followed by non-test macro'
170	cat $t1
171	exit 1
172}
173
174exit 0
175