1
.\" Copyright (c) 1985, 1991, 1993
2
.\" The Regents of the University of California. All rights reserved.
4
.\" This code is derived from software contributed to Berkeley by
5
.\" Dave Yost. Support for #if and #elif was added by Tony Finch.
7
.\" Redistribution and use in source and binary forms, with or without
8
.\" modification, are permitted provided that the following conditions
10
.\" 1. Redistributions of source code must retain the above copyright
11
.\" notice, this list of conditions and the following disclaimer.
12
.\" 2. Redistributions in binary form must reproduce the above copyright
13
.\" notice, this list of conditions and the following disclaimer in the
14
.\" documentation and/or other materials provided with the distribution.
15
.\" 3. Neither the name of the University nor the names of its contributors
16
.\" may be used to endorse or promote products derived from this software
17
.\" without specific prior written permission.
19
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31
.\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
32
.\" $dotat: things/unifdef.1,v 1.43 2003/01/20 11:36:12 fanf2 Exp $
33
.\" $FreeBSD: /repoman/r/ncvs/src/usr.bin/unifdef/unifdef.1,v 1.20 2003/02/24 22:53:24 ru Exp $
35
.Dd September 24, 2002
39
.Nm unifdef , unifdefall
40
.Nd remove preprocessor conditionals from code
46
.Fl D Ns Ar sym Ns Op = Ns Ar val
48
.Fl iD Ns Ar sym Ns Op = Ns Ar val
60
utility selectively processes conditional
63
It removes from a file
65
and any additional text that they specify should be removed,
66
while otherwise leaving the file alone.
71
.Ic #if , #ifdef , #ifndef , #elif , #else ,
75
and it understands only the commonly-used subset
76
of the expression syntax for
82
integer values of symbols defined on the command line,
85
operator applied to symbols defined or undefined on the command line,
87
.Ic \&! , < , > , <= , >= , == , != , && , || ,
88
and parenthesized expressions.
89
Anything that it does not understand is passed through unharmed.
94
directives if the symbol is specified on the command line,
95
otherwise they are also passed through unchanged.
96
By default, it ignores
100
lines with constant expressions,
101
or they may be processed by specifying the
103
flag on the command line.
107
utility also understands just enough about C
108
to know when one of the directives is inactive
111
or affected by a backslash-continued line.
112
It spots unusually-formatted preprocessor directives
113
and knows when the layout is too odd to handle.
117
can be used to remove all conditional
119
directives from a file.
124
to get lists of all the controlling symbols
125
and their definitions (or lack thereof),
128
with appropriate arguments to process the file.
132
.Bl -tag -width indent -compact
133
.It Fl D Ns Ar sym Ns Op = Ns Ar val
134
Specify that a symbol is defined,
135
and optionally specify what value to give it
136
for the purpose of handling
143
Specify that a symbol is undefined.
144
If the same symbol appears in more than one argument,
145
the last occurrence dominates.
151
then the operation of
154
i.e., the lines that would have been removed or blanked
155
are retained and vice versa.
160
processes its input one line at a time,
161
it cannot remove preprocessor directives that span more than one line.
162
The most common example of this is a directive with a multi-line
163
comment hanging off its right hand end.
167
has to process such a directive,
168
it will complain that the line is too obfuscated.
171
option changes the behaviour so that,
173
such lines are left unprocessed instead of reporting an error.
180
lines with constant expressions.
181
By default, sections controlled by such lines are passed through unchanged
182
because they typically start
184
and are used as a kind of comment to sketch out future or past development.
185
It would be rude to strip them out, just as it would be for normal comments.
188
Replace removed lines with blank lines
189
instead of deleting them.
192
Instead of processing the input file as usual,
195
to produce a list of symbols that appear in expressions
199
It is useful in conjunction with the
208
Disables parsing for C comments
209
and line continuations,
213
.It Fl iD Ns Ar sym Ns Op = Ns Ar val
219
to delimit non-C lines,
221
or code which is under construction,
224
which symbols are used for that purpose so that it will not try to parse
226
and line continuations
229
One specifies ignored symbols with
230
.Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
234
.Fl D Ns Ar sym Ns Op = Ns Ar val
242
an additional place to look for
245
This option is ignored by
247
for compatibility with
249
and to simplify the implementation of
255
utility copies its output to
257
and will take its input from
265
utility works nicely with the
275
Too many levels of nesting.
283
Obfuscated preprocessor control line.
287
(with the line number of the most recent unterminated
296
utility exits 0 if the output is an exact copy of the input,
297
1 if not, and 2 if in trouble.
299
Expression evaluation is very limited.
301
Preprocessor control lines split across more than one physical line
302
(because of comments or backslash-newline)
303
cannot be handled in every situation.
305
Trigraphs are not recognized.
307
There is no support for symbols with different definitions at
308
different points in the source file.
310
The text-mode and ignore functionality does not correspond to modern