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