Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!princeton!allegra!ulysses!mhuxr!mhuxn!ihnp4!poseidon!brent From: brent@poseidon.UUCP (Brent P. Callaghan) Newsgroups: net.sources Subject: Re: ifdef filter Message-ID: <1469@poseidon.UUCP> Date: Sat, 19-Jul-86 18:19:41 EDT Article-I.D.: poseidon.1469 Posted: Sat Jul 19 18:19:41 1986 Date-Received: Mon, 21-Jul-86 04:21:06 EDT References: <323@enmasse.UUCP> Organization: AT&T Information Systems, Lincroft NJ Lines: 29 > > 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.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