.\" Copyright (c) 1985, 1991 The Regents of the University of California.
.\" This code is derived from software contributed to Berkeley by
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)unifdef.1 6.5 (Berkeley) 4/23/91
.Nd remove ifdef'ed lines
is useful for removing ifdef'ed lines
from a file while otherwise leaving the file alone.
#ifdef, #ifndef, #else, and #endif lines,
and it knows only enough about C
to know when one of these is inactive
or a single or double quote.
Parsing for quotes is very simplistic:
when it finds an open quote,
it ignores everything (except escaped quotes)
until it finds a close quote, and
it will not complain if it gets
to the end of a line and finds no backslash for continuation.
.Bl -tag -width Ds -compact
Specify which symbols to define or undefine.
and the lines inside those ifdefs will be copied to the output or removed as
The ifdef, ifndef, else, and endif lines associated with
Ifdefs involving symbols you don't specify
and ``#if'' control lines
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,
the last occurrence dominates.
i.e. the lines that would have been removed or blanked
are retained and vice versa.
Replace removed lines with blank lines
instead of deleting them.
C comments and quotes useful for plain text
If your C code uses ifdefs to delimit non-C lines,
or code which is under construction,
which symbols are used for that purpose so that it won't try to parse
One specifies ignored ifdefs with
and will take its input from
as of the 4.1 Berkeley Software Distribution.
Inappropriate else or endif.
with line numbers of the unterminated #ifdefs.
Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
Should try to deal with ``#if'' lines.
Doesn't work correctly if input contains null characters.