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. All advertising materials mentioning features or use of this software
16 .\" must display the following acknowledgement:
17 .\" This product includes software developed by the University of
18 .\" California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\" may be used to endorse or promote products derived from this software
21 .\" without specific prior written permission.
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" @(#)unifdef.1 8.2 (Berkeley) 4/1/94
36 .\" $dotat: things/unifdef.1,v 1.43 2003/01/20 11:36:12 fanf2 Exp $
37 .\" $FreeBSD: src/usr.bin/unifdef/unifdef.1,v 1.4.2.9 2003/01/29 21:46:39 fanf Exp $
38 .\" $DragonFly: src/usr.bin/unifdef/unifdef.1,v 1.2 2003/06/17 04:29:33 dillon Exp $
40 .Dd September 24, 2002
44 .Nm unifdef , unifdefall
45 .Nd remove preprocessor conditionals from code
51 .Fl D Ns Ar sym Ns Op = Ns Ar val
53 .Fl iD Ns Ar sym Ns Op = Ns Ar val
65 utility selectively processes conditional
68 It removes from a file
70 and any additional text that they specify should be removed,
71 while otherwise leaving the file alone.
76 .Ic #if , #ifdef , #ifndef , #elif , #else ,
80 and it understands only the commonly-used subset
81 of the expression syntax for
87 integer values of symbols defined on the command line,
90 operator applied to symbols defined or undefined on the command line,
92 .Ic \&! , < , > , <= , >= , == , != , && , || ,
93 and parenthesized expressions.
94 Anything that it does not understand is passed through unharmed.
99 directives if the symbol is specified on the command line,
100 otherwise they are also passed through unchanged.
101 By default, it ignores
105 lines with constant expressions,
106 or they may be processed by specifying the
108 flag on the command line.
112 utility also understands just enough about C
113 to know when one of the directives is inactive
116 or affected by a backslash-continued line.
117 It spots unusually-formatted preprocessor directives
118 and knows when the layout is too odd to handle.
122 can be used to remove all conditional
124 directives from a file.
129 to get lists of all the controlling symbols
130 and their definitions (or lack thereof),
133 with appropriate arguments to process the file.
136 .Bl -tag -width indent -compact
137 .It Fl D Ns Ar sym Ns Op = Ns Ar val
138 Specify that a symbol is defined,
139 and optionally specify what value to give it
140 for the purpose of handling
147 Specify that a symbol is undefined.
148 If the same symbol appears in more than one argument,
149 the last occurrence dominates.
155 then the operation of
158 i.e., the lines that would have been removed or blanked
159 are retained and vice versa.
164 processes its input one line at a time,
165 it cannot remove preprocessor directives that span more than one line.
166 The most common example of this is a directive with a multi-line
167 comment hanging off its right hand end.
171 has to process such a directive,
172 it will complain that the line is too obfuscated.
175 option changes the behaviour so that,
177 such lines are left unprocessed instead of reporting an error.
184 lines with constant expressions.
185 By default, sections controlled by such lines are passed through unchanged
186 because they typically start
188 and are used as a kind of comment to sketch out future or past development.
189 It would be rude to strip them out, just as it would be for normal comments.
192 Replace removed lines with blank lines
193 instead of deleting them.
196 Instead of processing the input file as usual,
199 to produce a list of symbols that appear in expressions
203 It is useful in conjunction with the
212 Disables parsing for C comments
213 and line continuations,
217 .It Fl iD Ns Ar sym Ns Op = Ns Ar val
223 to delimit non-C lines,
225 or code which is under construction,
228 which symbols are used for that purpose so that it will not try to parse
230 and line continuations
233 One specifies ignored symbols with
234 .Fl iD Ns Ar sym Ns Oo = Ns Ar val Oc
238 .Fl D Ns Ar sym Ns Op = Ns Ar val
246 an additional place to look for
249 This option is ignored by
251 for compatibility with
253 and to simplify the implementation of
259 utility copies its output to
261 and will take its input from
269 utility works nicely with the
279 Too many levels of nesting.
287 Obfuscated preprocessor control line.
291 (with the line number of the most recent unterminated
300 utility exits 0 if the output is an exact copy of the input,
301 1 if not, and 2 if in trouble.
303 Expression evaluation is very limited.
305 Preprocessor control lines split across more than one physical line
306 (because of comments or backslash-newline)
307 cannot be handled in every situation.
309 Trigraphs are not recognized.
311 There is no support for symbols with different definitions at
312 different points in the source file.
314 The text-mode and ignore functionality does not correspond to modern