1994-05-27 12:33:43 +00:00
|
|
|
.\" Copyright (c) 1985, 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
|
|
.\" Dave Yost.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 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
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
|
1999-08-28 01:08:13 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-27 12:33:43 +00:00
|
|
|
.\"
|
|
|
|
.Dd April 1, 1994
|
|
|
|
.Dt UNIFDEF 1
|
2001-07-10 14:16:33 +00:00
|
|
|
.Os
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm unifdef
|
|
|
|
.Nd remove ifdef'ed lines
|
|
|
|
.Sh SYNOPSIS
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
.Op Fl clt
|
|
|
|
.Oo
|
|
|
|
.Fl D Ns Ar sym
|
|
|
|
.Fl U Ns Ar sym
|
|
|
|
.Fl iD Ns Ar sym
|
2000-10-22 23:49:29 +00:00
|
|
|
.Fl iU Ns Ar sym
|
1994-05-27 12:33:43 +00:00
|
|
|
.Oc
|
|
|
|
.Ar ...
|
|
|
|
.Op Ar file
|
|
|
|
.Sh DESCRIPTION
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility removes ifdef'ed lines
|
1994-05-27 12:33:43 +00:00
|
|
|
from a file while otherwise leaving the file alone.
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility acts on
|
1994-05-27 12:33:43 +00:00
|
|
|
#ifdef, #ifndef, #else, and #endif lines,
|
|
|
|
and it knows only enough about C
|
|
|
|
to know when one of these is inactive
|
|
|
|
because it is inside
|
|
|
|
a comment,
|
|
|
|
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.
|
|
|
|
.Pp
|
|
|
|
Available options:
|
|
|
|
.Bl -tag -width Ds -compact
|
|
|
|
.It Fl D Ns Ar sym
|
|
|
|
.It Fl U Ns Ar sym
|
|
|
|
Specify which symbols to define or undefine.
|
2001-04-26 17:16:59 +00:00
|
|
|
The lines inside those ifdefs will be copied to the output or removed as
|
1994-05-27 12:33:43 +00:00
|
|
|
appropriate.
|
|
|
|
The ifdef, ifndef, else, and endif lines associated with
|
|
|
|
.Ar sym
|
|
|
|
will also be removed.
|
|
|
|
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.
|
|
|
|
.Pp
|
|
|
|
.It Fl c
|
|
|
|
If the
|
|
|
|
.Fl c
|
|
|
|
flag is specified,
|
|
|
|
then the operation of
|
1997-08-20 11:07:53 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
is complemented,
|
|
|
|
i.e. the lines that would have been removed or blanked
|
|
|
|
are retained and vice versa.
|
|
|
|
.Pp
|
|
|
|
.It Fl l
|
|
|
|
Replace removed lines with blank lines
|
|
|
|
instead of deleting them.
|
|
|
|
.It Fl t
|
|
|
|
Disables parsing for C comments and quotes, which is useful
|
|
|
|
for plain text.
|
|
|
|
.Pp
|
|
|
|
.It Fl iD Ns Ar sym
|
|
|
|
.It Fl iU Ns Ar sym
|
|
|
|
Ignore ifdefs.
|
|
|
|
If your C code uses ifdefs to delimit non-C lines,
|
|
|
|
such as comments
|
|
|
|
or code which is under construction,
|
|
|
|
then you must tell
|
1997-08-20 11:07:53 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
which symbols are used for that purpose so that it won't try to parse
|
|
|
|
for quotes and comments
|
|
|
|
inside those ifdefs.
|
|
|
|
One specifies ignored ifdefs with
|
|
|
|
.Fl iD Ns Ar sym
|
|
|
|
and
|
|
|
|
.Fl iU Ns Ar sym
|
|
|
|
similar to
|
|
|
|
.Fl D Ns Ar sym
|
|
|
|
and
|
|
|
|
.Fl U Ns Ar sym
|
|
|
|
above.
|
|
|
|
.El
|
|
|
|
.Pp
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility copies its output to
|
1994-05-27 12:33:43 +00:00
|
|
|
.Em stdout
|
|
|
|
and will take its input from
|
|
|
|
.Em stdin
|
|
|
|
if no
|
|
|
|
.Ar file
|
|
|
|
argument is given.
|
|
|
|
.Pp
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility works nicely with the
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl D Ns Ar sym
|
|
|
|
option added to
|
|
|
|
.Xr diff 1
|
|
|
|
as of the 4.1 Berkeley Software Distribution.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr diff 1
|
|
|
|
.Sh DIAGNOSTICS
|
2000-11-10 17:46:15 +00:00
|
|
|
.Bl -item -compact
|
|
|
|
.It
|
1994-05-27 12:33:43 +00:00
|
|
|
Inappropriate else or endif.
|
2000-11-10 17:46:15 +00:00
|
|
|
.It
|
1994-05-27 12:33:43 +00:00
|
|
|
Premature
|
|
|
|
.Tn EOF
|
|
|
|
with line numbers of the unterminated #ifdefs.
|
2000-11-10 17:46:15 +00:00
|
|
|
.El
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pp
|
|
|
|
Exit status is 0 if output is exact copy of input, 1 if not, 2 if trouble.
|
|
|
|
.Sh BUGS
|
|
|
|
Should try to deal with ``#if'' lines.
|
|
|
|
.Pp
|
|
|
|
Doesn't work correctly if input contains null characters.
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
command appeared in
|
|
|
|
.Bx 4.3 .
|