1#!/bin/sh - 2# 3# $Id: chk.flags,v 12.4 2007/11/18 20:47:29 bostic Exp $ 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 '/_method.c:.*outflagsp,/d' \ 101 -e '/rep_backup.c:.*->flags,/d' \ 102 -e '/db.c:.*save_flags,/d' \ 103 -e '/((*[ ]*db_rep->rep_db)*,/d' \ 104 -e '/((*[ ]*dbc)*->dbp,/d' \ 105 -e '/((*[ ]*dbc_arg->dbp)*,/d' \ 106 -e '/((*[ ]*dbp)*,/d' \ 107 -e '/((*[ ]*dbp)*->s_primary,/d' \ 108 -e '/((D),/d' \ 109 -e '/((sdbp),/d' \ 110 -e '/(file_dbp,/d' \ 111 -e '/(ldbp,/d' \ 112 -e '/(mdbp,/d' \ 113 -e '/(pdbp,/d' \ 114 -e '/(pginfo, /d' \ 115 -e '/(sdbp,/d' \ 116 -e '/(subdbp,/d' \ 117 -e '/fop_util.c:.*(t2dbp,/d' \ 118 -e '/fop_util.c:.*(tmpdbp,/d' \ 119 -e '/rep_backup.c.*(rfp,/d' \ 120 > $t2 121[ -s $t2 ] && { 122 cat $t2 123 exit 1 124} 125 126echo 'Checking "dbc" variables flags with flags other than DBC_XXX' 127echo Checking DBC flags... 128cat $t1 | 129grep 'dbc,' | 130sed -e '/DBC_/d' \ 131 > $t2 132[ -s $t2 ] && { 133 cat $t2 134 exit 1 135} 136 137echo 'Checking DBC_XXX flags with variables other than "dbc"' 138grep 'DBC_' $t1 | 139sed -e '/((*dbc)*,/d' \ 140 -e '/(dbc_arg,/d' \ 141 -e '/(dbc_c,/d' \ 142 -e '/(dbc_n,/d' \ 143 -e '/(dbc_orig,/d' \ 144 -e '/(opd,/d' \ 145 -e '/(pdbc,/d' \ 146 -e '/(sdbc,/d' \ 147 > $t2 148[ -s $t2 ] && { 149 cat $t2 150 exit 1 151} 152 153echo Checking for bad use of macros... 154egrep 'case .*F_SET\(|case .*F_CLR\(' $d/*/*.c > $t1 155egrep 'for .*F_SET\(|for .*F_CLR\(' $d/*/*.c >> $t1 156egrep 'if .*F_SET\(|if .*F_CLR\(' $d/*/*.c >> $t1 157egrep 'switch .*F_SET\(|switch .*F_CLR\(' $d/*/*.c >> $t1 158egrep 'while .*F_SET\(|while .*F_CLR\(' $d/*/*.c >> $t1 159[ -s $t1 ] && { 160 echo 'if statement followed by non-test macro' 161 cat $t1 162 exit 1 163} 164 165exit 0 166