3 # remove all the #if's from a source file
5 # $dotat: things/unifdefall.sh,v 1.9 2002/09/24 19:43:57 fanf2 Exp $
6 # $FreeBSD: src/usr.bin/unifdef/unifdefall.sh,v 1.1.2.2 2002/10/20 13:44:11 fanf Exp $
7 # $DragonFly: src/usr.bin/unifdef/unifdefall.sh,v 1.2 2003/06/17 04:29:33 dillon Exp $
11 basename=`basename $0`
12 tmp
=`mktemp -d -t $basename` ||
exit 2
14 unifdef
-s "$@" |
sort |
uniq > $tmp/ctrl
16 sed -Ee 's/^#define[ ]+(.*[^ ])[ ]*$/\1/' > $tmp/hashdefs
17 sed -Ee 's/^([A-Za-z0-9_]+).*$/\1/' $tmp/hashdefs
> $tmp/alldef
18 comm -23 $tmp/ctrl
$tmp/alldef
> $tmp/undef
19 comm -12 $tmp/ctrl
$tmp/alldef
> $tmp/def
21 echo unifdef
-k \\ > $tmp/cmd
22 sed -Ee 's/^(.*)$/-U\1 \\/' $tmp/undef
>> $tmp/cmd
24 do sed -Ee '/^('"$sym"')([(][^)]*[)])?([ ]+(.*))?$/!d;s//-D\1=\4/' $tmp/hashdefs
26 sed -Ee 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/" \\/' >> $tmp/cmd
27 echo '"$@"' >> $tmp/cmd