ifdef filter
Brent P. Callaghan
brent at poseidon.UUCP
Sun Jul 20 08:19:41 AEST 1986
>
> It often happens that software packages are set up to run on so many
> configurations that it is hard to read the code because of all the ifdefs.
> I would like a filter for C programs that does something like the
> following:
>
> Invoke it like this:
>
> prog <x.c >x.c.new -DSYSV -D68000
>
> That is, filter out everything that is not going to be expanded by cpp while
> retaining the ifdefs that are going to be expanded, just for comment value.
> Ideally the output, when compiled, would produce exactly the same results as the
> original. Does anyone have anything like this?
How about something simple like the following shell/awk one-liner:
awk "/# *ifdef.*$1/ , /#endif/ {print}" $2
Call it "ifdef" and invoke as:
ifdef 6800 x.c > x.c.new
--
Made in New Zealand --> Brent Callaghan
AT&T Information Systems, Lincroft, NJ
{ihnp4|mtuxo|pegasus}!poseidon!brent
(201) 576-3475
More information about the Comp.sources.unix
mailing list