Subject: Re: include opt_foo.h before using #ifdef FOO
To: matthew green <mrg@eterna.com.au>
From: Martin Husemann <martin@duskware.de>
List: tech-kern
Date: 06/23/2003 17:38:33
--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Tue, Jun 24, 2003 at 12:02:07AM +1000, matthew green wrote:
> perhaps you should publish these....
Hmm, no rocket science in there (I'm a lousy shell programmer).
I used the first script to grep for all defflag options w/o opt_*.h filename,
giving me a list of affected options. Sprinkled in some sort -u, and fed that
to the second script after running "mkid" in the sys tree.
Martin
--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=checkflags
#! /bin/sh
# Shell script to search for "defflag XXX" declarations in files.* files,
# used to check for missing opt_xxx.h includes after fixing config.
find /usr/src/sys -type f -name files\* | while read file
do
LIST=`fgrep defflag ${file} | egrep -v 'defflag.+[a-z0-9_]+\.h'`
if [ ! -z "$LIST" ]; then
echo "$LIST" | sed -e 's/defflag[^A-Z_]*//' -e 's/[^A-Za-z0-9_]*#.*$//'
fi
done
--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=checkincludes
#! /bin/sh
# check for proper opt_foo.h includes for option FOO
onefile()
{
case $2 in
*Makefile*)
return ;;
esac
found=`fgrep $1 $2`
if [ -z "$found" ]; then
echo $2 probably needs $1
fi
}
checkfiles()
{
file="opt_`echo $1 | tr '[A-Z0-9_]' '[a-z0-9_]'`.h"
shift
while [ $# -ge 1 ]; do
onefile "$file" $1
shift
done
}
while [ $# -ge 1 ]; do
list=`gid -R filenames -S space $1`
if [ ! -z "$list" ]; then
checkfiles $list
fi
shift
done
--zhXaljGHf11kAtnf--