ifdef filter
thomas at utah-gr.UUCP
thomas at utah-gr.UUCP
Sun Jul 20 11:14:11 AEST 1986
There is such a program in 4.3 (and maybe earlier, I can't say because
we had it from:), it was also part of the Rand editor and MH
distribution (ages ago). It was written by Dave Yost, I don't know if
it is in the public domain. It is called "unifdef". Here is the man
page. (Please don't bug me for copies, I can't send them. If it turns
out to be PD, I could post it to mod.sources.)
UNIFDEF(1) UNIX Programmer's Manual UNIFDEF(1)
NAME
unifdef - remove ifdef'ed lines
SYNOPSIS
unifdef [ -t -l -c -Dsym -Usym -idsym -iusym ] ... [ file ]
DESCRIPTION
Unifdef is useful for removing ifdef'ed lines from a file
while otherwise leaving the file alone. Unifdef is like a
stripped-down C preprocessor: it is smart enough to deal
with the nested ifdefs, comments, single and double quotes
of C syntax so that it can do its job, but it doesn't do any
including or interpretation of macros. Neither does it
strip out comments, though it recognizes and ignores them.
You specify which symbols you want defined -Dsym or unde-
fined -Usym and the lines inside those ifdefs will be copied
to the output or removed as appropriate. The ifdef, ifndef,
else, and endif lines associated with sym will also be
removed. Ifdefs involving symbols you don't specify are
untouched and copied out along with their associated ifdef,
else, and endif lines. If an ifdef X occurs nested inside
another ifdef X, then the inside ifdef is treated as if it
were an unrecognized symbol. If the same symbol appears in
more than one argument, only the first occurrence is signi-
ficant.
The -l option causes unifdef to replace removed lines with
blank lines instead of deleting them.
If you use ifdefs to delimit non-C lines, such as comments
or code which is under construction, then you must tell
unifdef which symbols are used for that purpose so that it
won't try to parse for quotes and comments in those ifdef'ed
lines. You specify that you want the lines inside certain
ifdefs to be ignored but copied out with -idsym and -iusym
similar to -Dsym and -Usym above.
If you want to use unifdef for plain text (not C code), use
the -t option. This makes unifdef refrain from attempting
to recognize comments and single and double quotes.
Unifdef copies its output to stdout and will take its input
from stdin if no file argument is given. If the -c argument
is specified, then the operation of unifdef is complemented,
i.e. the lines that would have been removed or blanked are
retained and vice versa.
SEE ALSO
diff(1)
DIAGNOSTICS
Premature EOF, inappropriate else or endif.
Printed 6/8/86 April 29, 1985 1
UNIFDEF(1) UNIX Programmer's Manual UNIFDEF(1)
Exit status is 0 if output is exact copy of input, 1 if not,
2 if trouble.
BUGS
Does not know how to deal with cpp consructs such as
#if defined(X) || defined(Y)
AUTHOR
Dave Yost
Printed 6/8/86 April 29, 1985 2
--
=Spencer ({ihnp4,decvax}!utah-cs!thomas, thomas at utah-cs.ARPA)
More information about the Comp.sources.unix
mailing list