ifdef filter

Keith Crews keith at enmasse.UUCP
Fri Jul 18 02:00:55 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

and it would take input of the form:

#ifdef 68000
short i;
#else
int i;
#endif
#ifdef BSD
blah
#else
blech
#endif
...

and produce			or maybe

#ifdef 68000			#ifdef 68000
short i;			short i;
#endif				#else
blech				#endif
				#ifdef BSD
				#else
				blech
				#endif

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?



More information about the Comp.sources.unix mailing list